This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to select JButton? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "How to select JButton?" Watch "How to select JButton?" New topic
Author

How to select JButton?

Milan Djukic
Greenhorn

Joined: Feb 14, 2011
Posts: 27
How can i programmatically select button? Like JOptionPane.showOptionDialog(......,Object initialValue) .
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 1788
    
    2
Post your SSCCE that demonstrates the problem.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32689
    
    4
Why would you want to select a button programmatically? Have you been through the Java™ Tutorials? This section might help.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to select JButton?
 
Similar Threads
How to select a folder
Selecting the directory
Who attempted Part 1 please answer
Selecting JTree node
How to select a tray in java print service?