• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hot Key is not working in java 1.6  RSS feed

 
R.Joe
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had added the hot key F5 in the menu item which is invisible it is working fine in jre 1.4, 1.5 but not in 1.6,
Help me out,

JMenuItem item1 = new JMenuItem("Item Listener");
item1.setAccelerator(KeyStroke.getKeyStroke("F5"));
item1.setVisible(false);
item1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// action event
}
});

thanks in advance
 
Sesh MS
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can trick Java 1.6 by remove item1.setVisible(false) and adding item1.setPreferredSize(new Dimension(0,0)).
 
Sesh MS
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can trick Java 1.6 by removing item1.setVisible(false) and adding item1.setPreferredSize(new Dimension(0,0)).
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Sesh MS.

We don't have too many rules around here but we do have a Naming Policy. Please adjust your display name accordingly. You can do so by clicking here.

Specifically, your last name, MS, doesn't comply with the policy.

Thanks a bunch.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!