I write project in Java in NetBeans. I created a new project and didn't check to create main class, because I create all with drag and drop, make some buttons and events on them. Then, I created two JFrame
classes: NewJFrame
and NewJFrame1
, in NewJFrame
I a have a button in both frames.
So, can you tell me how can I make event to open first frame by clicking on button in second frame, and to open second frame by clicking on button in first frame?
//Make constructor class for both JFrame then
//write this code into your JFrame where your button is accesing another JFrame
//Note:- jb=button var name,
// jf=JFrame vatr name,
// addnew()=JFrame Class to be open.
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
new addnew();
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.