可以通过一个鼠标点击事件,进入一个新的窗体,当前的窗体被关闭或者隐藏吗? 基本的程序如下(Java) 200
publicclassWelcomeextendsJFrame{privateMyPanelcontentPane;publicstaticvoidmain(String...
public class Welcome extends JFrame {
private MyPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Welcome frame = new Welcome();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Welcome() {
setTitle("欢迎光临");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new MyPanel("H://food//欢迎光临.jpg",450,300);
contentPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
Menu menu = new Menu();
menu.setVisible(true);
}
});
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
} 展开
private MyPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Welcome frame = new Welcome();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Welcome() {
setTitle("欢迎光临");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new MyPanel("H://food//欢迎光临.jpg",450,300);
contentPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
Menu menu = new Menu();
menu.setVisible(true);
}
});
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
} 展开
1个回答
2016-07-16
展开全部
让当前窗口做 setVisible(false) 隐藏就是了。。。。。。。。。
追问
可以在我的程序上改一下吗
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询