Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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: 2542
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE that demonstrates the problem.
 
Campbell Ritchie
Sheriff
Posts: 48445
56
  • 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: 20495
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