Я хочу, чтобы dispose()
мой текущий jFrame
и перейти к следующему jFrame (StudentProfilepage()), но он показывает ошибку в this.dispose()
.Как переместить один кадр в другой в MouseListener
Как я могу сделать that.Here я использовал MouseListner
в jLabel 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] (http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html), этот набор лучше в данной ситуации. Для [примера] (http://stackoverflow.com/a/9349137/1057230) :-) –