• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenuItem

 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using an actionperformed or other event how do you write a code that saves and or opens something? Also, how would you disable right clikcing on a certain frame/panel/etc?
Thank you
Jesse
 
omar bili
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesse ,
when you use the actionPerformed Method :

public void actionPerformed(ActionEvent e) {
if (e.getSource() == /*name of the button or the Label or ..*/) {
// you write here the code that you want to execute
// for example:
JFrame frm = new JFrame() ;
frm.setSize(400,400) ;
frm.setDefaultCloseOperation(3) ;
frm.show() ;
}
}
//so when you click on the button the JFrame frm will appeare

Regards Omar
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / AWT / SWT / JFace forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!