Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Button 为什么我的按钮移动有问题?_Button_Move - Fatal编程技术网

Button 为什么我的按钮移动有问题?

Button 为什么我的按钮移动有问题?,button,move,Button,Move,我正在写一个程序,我想通过按下按钮打开一个类。我在一个窗口上有两个按钮,第一个按钮工作正常,但我似乎无法移动第二个按钮(称为“教师”)。这是代码。我正在拼命寻找解决办法。谢谢 class MyHandler implements ActionListener{ public void actionPerformed(ActionEvent e){ System.exit(0); } } 类MyFrame扩展了JFrame{ private int size;

我正在写一个程序,我想通过按下按钮打开一个类。我在一个窗口上有两个按钮,第一个按钮工作正常,但我似乎无法移动第二个按钮(称为“教师”)。这是代码。我正在拼命寻找解决办法。谢谢

class MyHandler implements ActionListener{

    public void actionPerformed(ActionEvent e){
    System.exit(0);
     }
}
类MyFrame扩展了JFrame{

    private int size;
    private String font;

    MyFrame (String name){
        super (name);
        setBounds(500,500,600,400);
        setResizable(false);

        setDefaultCloseOperation(EXIT_ON_CLOSE);

        //log in text
        JLabel lbl = new JLabel("Log in");
        lbl.setBounds(250, 60, 600, 50);

        size = 40;
        font = "Arial";
        lbl.setFont(new Font(name,Font.PLAIN,size));
        add(lbl);

        //adding button
        JButton btn = new JButton("Student");
        btn.setBounds(150, 260, 60, 40);
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dispose();
                new Frame("StudentLogIn");
            }
        });
        add(btn);



        //adding second button
        JButton teach = new JButton("Teacher");
        teach.setBounds(100,260,60,40);
        teach.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dispose();
                new FrameTeach("TeacherLogIn");
            }
        });
        add(teach);


        setVisible(true);



    }
}





public class StartingWindow {

    public static void main(String[] args) {

        new MyFrame("Starting Window");

    }

}