Results 1 to 2 of 2
  1. #1
    chirag123 is offline Member
    Join Date
    Apr 2011
    Rep Power

    Exclamation Change colour of JOptionPane

    I need to change the colour of a button in a JOptionPane. How my program works is when a button is pressed a JOptionPane appears and displays a message and I need to change the colour of the button text in the JOptionPane. Here's the code for the option pane:

    Java Code:
    UIManager um=new UIManager();
    um.put("OptionPane.background",new ColorUIResource(100,200,255));
    um.put("Panel.background",new ColorUIResource(100,200,255));
    button.titleLabel.textColor = (UIColor blueColor);
    JOptionPane.showMessageDialog(null, "It takes approximately 1 hour and 5 minutes to go from Nottingham to Leicester", "Time", JOptionPane.PLAIN_MESSAGE);

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    London, UK
    Blog Entries
    Rep Power


    JOptionPane is a JComponent, so you can use JComponents setBackground() method

    Java Code:
    javax.swing.JOptionPane j = new javax.swing.JOptionPane();

Similar Threads

  1. Jtable colour cell problem
    By fuzzdn in forum New To Java
    Replies: 10
    Last Post: 07-30-2011, 05:30 PM
  2. changing JFrame colour
    By simo_mon in forum AWT / Swing
    Replies: 0
    Last Post: 08-08-2009, 02:15 AM
  3. Changing text colour in code
    By dbashby in forum New To Java
    Replies: 2
    Last Post: 04-29-2009, 03:32 PM
  4. Colour Specific Cell within Table
    By poddy88 in forum New To Java
    Replies: 2
    Last Post: 04-14-2009, 08:20 AM
  5. Replies: 0
    Last Post: 03-26-2009, 01:23 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts