Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to select JButton?

 
Milan Djukic
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i programmatically select button? Like JOptionPane.showOptionDialog(......,Object initialValue) .
 
Rob Camick
Ranch Hand
Posts: 2580
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE that demonstrates the problem.
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to select a button programmatically? Have you been through the Java™ Tutorials? This section might help.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that requestFocus or requestFocusInWindow should do the trick. You may have to use EventQueue.invokeLater to call this, even if you call it from the EDT itself, because I think a delayed event will be necessary.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic