PDA

View Full Version : Java: Possible to make JOptionPane with icon that changes based on user selection?




wrldwzrd89
May 22, 2009, 07:46 PM
I want to create a dialog that looks and behaves like a JOptionPane, but also changes its icon based on what the user selected in the input dialog. I only care about the input dialog case - the other types of JOptionPanes don't need variable/dynamic icons. Is this possible? I haven't found a way to do this yet.

I did, however, manage to build a custom JFrame with a default button, a cancel button (pressing Escape when focus isn't on the JComboBox closes the JFrame, as it should), and the desired behavior. I just can't figure out how to make it look better - or is there a better solution, say, involving extending JOptionPane?



wrldwzrd89
May 24, 2009, 01:06 PM
An update: I managed to figure out that the best way to do what I want is to add an ActionListener to the JComboBox the JOptionPane uses to display options... but, try as I might, the JOptionPane doesn't give me direct (or even indirect) access to that portion. Oh well... :(