Results 1 to 4 of 4
  1. #1
    mew
    mew is offline Member
    Join Date
    Nov 2007
    Posts
    70
    Rep Power
    0

    Default Changing icon of JOptionPane

    JOptionPane defines icons for different types of messages. I want to use my own icons.

    Can I use my own icon specific to my application with JOptionPane?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    To change all JOptionPanes try
    Java Code:
    ImageIcon icon = yourIcon
    UIManager.put(icon, "OptionPane.informationIcon");
    Before you create any dialogs.
    Other string properties: errorIcon, questionIcon, warningIcon.

  3. #3
    mew
    mew is offline Member
    Join Date
    Nov 2007
    Posts
    70
    Rep Power
    0

    Default

    Thanks. But where I have to mention the image name and path?

  4. #4
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    ImageIcon icon = new ImageIcon(new File(imagePath));
    See ImageIcon class api Constructors Summary section for other options.

Similar Threads

  1. How to change Window Icon
    By sharafat in forum AWT / Swing
    Replies: 7
    Last Post: 01-15-2010, 12:37 AM
  2. Icon initialization problem
    By saz25 in forum AWT / Swing
    Replies: 1
    Last Post: 12-24-2007, 10:37 PM
  3. Custom icon for Frame
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-21-2007, 08:38 AM
  4. How to set an Icon in a Label?
    By Soda in forum New To Java
    Replies: 2
    Last Post: 12-07-2007, 12:38 PM
  5. To add an icon to my project
    By Albert in forum AWT / Swing
    Replies: 1
    Last Post: 07-13-2007, 03:14 PM

Posting Permissions

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