【发布时间】:2013-08-14 15:13:11
【问题描述】:
我想dispose()我当前的jFrame并移动到下一个jFrame(StudentProfilepage())。但它在this.dispose()显示错误。
我该怎么做。这里我用MouseListnerjLabel l1
我的代码如下
l1.setCursor(Cursor.getDefaultCursor());
l1.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
//added check for MouseEvent.BUTTON1 which is left click
if (e.isPopupTrigger() || e.getButton() == MouseEvent.BUTTON1) {
this.dispose(); //error here(i want to close my current frame and move to StudentProfile() page
new StudentProfilePage().setVisible(true);
}
}
});
【问题讨论】:
-
你的班级名称是什么?
-
请查看CardLayout,这个套件更适合这种情况。对于example :-)
标签: java swing jframe multiple-instances mouselistener