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

Discussion in 'Mac Programming' started by wrldwzrd89, May 22, 2009.

  1. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #1
    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?
     
  2. wrldwzrd89 thread starter macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #2
    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... :(
     

Share This Page