Using JoptionPane icon in other dialogs

I was originally using a ProgressMonitor. but this wasn't flexible enough so i created my own subclass of JDialog which contained a JProgressBar.
This work fine but I want it to display the Information Icon that you get with ProgressMonitor and some JoptionPanes. How can I do this without subclassing JOptionPane.

I think....
Icon icon = UIManager.getDefaults().getIcon(key);
where key is one of...
OptionPane.errorIcon
OptionPane.informationIcon
OptionPane.questionIcon
OptionPane.warningIcon

Similar Messages

  • How to change the icon for print dialog?

    Hello,
    I have a JTable, and with the print() method, I'm able to bring up the Print dialog and successfully print the contents of the table. Example:
    myTable.print( JTable.PrintMode.FIT_WIDTH, myHeaderFormat, myFooterFormat );This works great, but one small detail I'd like to change is the icon in the top-left corner of the dialog. The icon is currently the default Java coffee cup icon, while the rest of my application uses my custom icon. I couldn't find any documentation in the API or tutorials that Java has listed which shows how to change the icon, so I'm not even sure if it's possible (but why shouldn't it be?).
    My question is this: Is it possible to change the default icon in the print dialog? Or do I have to either make my own print dialog somehow, or use a third-party print dialog?
    Thanks

    tjacobs01: Appreciate the assistance (despite your sass). I've already searched the API, tutorials, and this forum. I'm already well aware of the setIconImage() method for JFrame -- after all, that's how I set the icon for my other frames as I previously mentioned. However, I want to set the icon for the print dialog called from the print() method of JTable.
    How would I use setIconImage() for the print() method of JTable? The print() method returns a boolean value, not a JFrame, so I'm just not sure how to implement what you're saying.
    Thanks

  • I would like to use the windows explorer open dialog box instead of the adobe open dialog box. How can I change that?

    I would like to use the windows explorer open dialog box instead of the adobe open dialog box. How can I change that?

    The top screenshot is the Windows Open dialog box. All File > Open... commands in all Windows programs bring it up.   Try File > Open in Notepad for example.
    It belongs to Windows not Adobe. You cannot change this because there is no such thing as an Adobe Open dialog box.
    The bottom screenshot is Windows Explorer. It is Windows' OS File Browser, not an Open dialog.  It is not called up by Photoshop or any Windows program.
    You have to click on "My Computer" or a Folder icon to get to it. You can double-click a psd, jpeg or other image file in the Explorer window so that it opens in Photoshop.
    There is Adobe Bridge and Minibridge   Alt + Ctrl + O or File > Browse in Bridge

  • JOptionPane Icons

    Hello, all!
    JOptionPane icons are usually available by invoking
    UIManager.getIcon("OptionPane.errorIcon");
    UIManager.getIcon("OptionPane.informationIcon");
    UIManager.getIcon("OptionPane.questionIcon");
    UIManager.getIcon("OptionPane.warningIcon");This all works well, except for native GTK Look & Feel, where nulls are returned (all is ok with synthetic GTK Look & Feel). How can I fix the problem?

    You are using OK_OPTION when you should be using a message type:
    JOptionPane.showMessageDialog(MainFrame.getInstance(), message,
    windowTitle, JOptionPane.INFORMATION_MESSAGE);
    there are
    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE

  • Using JOptionPane in a non-event dispatching thread

    I am currently working on a screen that will need to called and displayed from a non-event dispatching thread. This dialog will also capture a user's selection and then use that information for later processing. Therefore, the dialog will need to halt the current thread until the user responds.
    To start, I tried using the JOptionPane.showInputDialog() method and set the options to a couple of objects. JOptionPane worked as advertised. It placed the objects into a combobox and allowed the user to select one of them. However, it also gave me something unexpected. It actually paused the non-event handling thread until the user had made a selection. This was done without the JOptionPane code being wrapped in a SwingUtilities.invokeLater() or some other device that would force it to be launched from an Event Handling Thread.
    Encouraged, I proceeded to use JOptionPane.showInputDialog() substituting the "message" Object with a fairly complex panel (JRadioButtons, JLists, JTextFields, etc.) that would display all of the variety of choices for the user. Now, when the screen pops up, it doesn't paint correctly (like what commonly occurs when try to perform a GUI update from a non-event dispatching thread) and the original thread continues without waiting for a user selection (which could be made if the screen painted correctly).
    So, here come the questions:
    1) Is what I am trying to do possible? Is it possible to create a fairly complex GUI panel and use it in one of the static JOptionPane.showXXXDialog() methods?
    2) If I can't use JOptionPane for this, should I be able to use JDialog to perform the same type function?
    3) If I can use JDialog or JFrame and get the threading done properly, how do I get the original thread to wait for the user to make a selection before proceeding?
    I have been working with Java and Swing for about 7-8 years and have done some fairly complex GUIs, but for some reason, I am stumped here. Any help would be appreciated.
    Thanks.

    This seems wierd that it is functioning this way. Generally, this is what is supposed to happen. If you call a JOptionPane.show... from the Event Dispatch Thread, the JOptionPane will actually begin processing events that normally the Event Dispatch Thread would handle. It does this until the user selects on options.
    If you call it from another thread, it uses the standard wait and notify.
    It could be that you are using showInputDialog for this, try showMessageDialog and see if that works. I believe showInputDialog is generally used for a single JTextField and JLabel.

  • Comple errors using JOptionPane

    I'm trying to write a Java program using JOptionPane dialog/display boxes that reads an integer and checks whether it is even using true/false statements. I also want the program must check if the number the user entered is between 1 and 1000.
    I haven't found alot of help in the book I have and i've found some help in another forum but it doesn't seem to compile well, I get the following errors:
    IntegerRead.java:39: cannot find symbol
    symbol : method valueOf(java.lang.String)
    location: class Integer
    int number = Integer.valueOf(s);
    ^
    Integer.java:13: cannot find symbol
    symbol : class Scanner
    location: class Integer
    Scanner input = new Scanner( System.in );
    ^
    Integer.java:13: cannot find symbol
    symbol : class Scanner
    location: class Integer
    Scanner input = new Scanner( System.in );
    Here is the code:
    // Assignment 2.1: IntegerRead.java
    // This program reads an integer, checks if it's even and is between 1 and 1000.
    import javax.swing.JOptionPane; // program uses class JOptionPane
    public class IntegerRead
    public static boolean isNumber(String args)
    if(args.length() > 3)
    throw new IllegalArgumentException("Invalid argument");
    else
    boolean isNumber = false;
    for(int i = 0; i < args.length(); i++)
    char c = args.charAt(i);
    if(Character.isDigit(c))
    isNumber = true;
    else
    isNumber = false;
    return isNumber;
    public static boolean isEven(int aNumber)
    int a = aNumber & 1;
    return (a == 0);
    public static void main(String args[])
    String s = JOptionPane.showInputDialog("Please enter number between 0 to 999");
    System.out.println("Is Number " + isNumber(s));
    if(isNumber(s))
    int number = Integer.valueOf(s);
    System.out.println("Number " + number + "is Even " + isEven(number));
    for(int i = 0; i < 999; i++)
    System.out.println(i + " is " + isEven(i));
    I know i'm missing very simple. I'm new and have tried to build upon what I have so far, but I can't figure it out.
    Thanks....
    Edited by: Scott.Dishman on Jul 9, 2008 4:07 PM

    You have a class named Integer somewhere on your class path. Get rid of it or rename it. If you've already renamed your Integer.java file, you still need to delete the Integer.class file. You should never create your own class that has the same name as a class in the standard java.lang package.

  • Reading Integer using JOptionPane

    I'm trying to write a Java program using JOptionPane dialog/display boxes that reads an integer and checks whether it is even using true/false statements. I also want the program must check if the number the user entered is between 1 and 1000.
    I haven't found alot of help in the book I have, so I'm hoping somone has some example modules.
    Thank you....
    Scott

    Hi,
    Hope this helps you a bit. Just Uncomment the for your even number testing.
    import javax.swing.JOptionPane;
    public class OptionPaneTest {
         public static boolean isNumber(String args)
              if(args.length() > 3)
                   throw new IllegalArgumentException("Invalid argument");
              else
              boolean isNumber = false;
              for(int i = 0; i < args.length(); i++)
                   char c = args.charAt(i);
                   if(Character.isDigit(c))
                        isNumber = true;
                   else
                      isNumber = false;
              return isNumber;
         public static boolean isEven(int aNumber)
              int a = aNumber & 1;
              return (a == 0);          
          * @param args
         public static void main(String[] args) {          
              String s = JOptionPane.showInputDialog("Please enter number between 0 to 999");
              System.out.println("Is Number " + isNumber(s));
              if(isNumber(s))
              int number = Integer.valueOf(s);
              System.out.println("Number " + number + "is Even " + isEven(number));          
    //          for(int i = 0; i < 999; i++)
    //          System.out.println(i + " is " + isEven(i));
    }

  • Help using JOptionPane

    please tell me how can i do following:
    I want to add strings using JOptionPane.showInputDialog( ) method. in an ArrayList() of strings only.
    I want to show input dialog box to user continously till user presses "enter" from keyboard.
    please tell me the way to stop the loop when user presses "Enter" from keyboard.
    //what i have done:
    //created new ArrayList()
    myStrings = new ArrayList();
    while(1)
        String theString = JOptionPane.showInputDialog("Enter string ");
        myStrings.add(theString);
    }

    I want to show input dialog box to user continously
    till user presses "enter" from keyboard.
    please tell me the way to stop the loop when user
    presses "Enter" from keyboard.You probably want to end the loop when the user clicks the cancel button on the dialog. Clicking the enter button invokes the button that has focus.

  • Using JoptionPane.ShowInternalDialog

    I'm using the following code to open an JInternalFrame as model from another JinternalFrame.
    partNumberMaintenanceFrame = new PartNumberMaintenance_4_1 (this,null,data);
    JPanel glass = new JPanel();
    glass.setOpaque(false);
    glass.setLayout(null);
    glass.add(partNumberMaintenanceFrame);
    mainDesktopFrame.setGlassPane(glass);
    glass.setVisible(true);
    partNumberMaintenanceFrame.setVisible(true);
    Now, the problem is , When i try to use JoptionPane.ShowInternalDialog from the partNumberMaintenanceFrame the messagedialog goes behind the frame.
    I guess this is bcoz i use glasspane. What shoup i do to make the dialog to show on the frame?
    Thanks

    You might need to post a little more code for people to help you.

  • Using JOptionPane to exit program & Using toString method

    Hello,
    In my program I have to use a toString method below
    public String toString(Hw1NCBEmployee[] e)
            String returnMe = String.format(getStoreName() + "\n" + getStoreAddress() + "\n" + getCityState() +  "\nYou have " + getEmpCount() + "employee(s)");
            return returnMe;
    }Now, at first, when I initially tested my code, it was working just fine, printing out the right way
    Point is -- now that Im practically finished with my program, and am going back and running it - calling the toString method gives me the address rather than the information . . . Can anyone help me with this issue??
    Also, Im using JOptionPane to display everything, but -- at first, it worked fine, then (around the same time I started having the above problem) it stopped exiting the do-while loop:
    while(go)
                 int option = JOptionPane.showConfirmDialog(null, "Do you want to enter employee information?", "Welcome!", JOptionPane.YES_NO_OPTION);
                     if(option == JOptionPane.NO_OPTION)
                        go = false;  //exit loop
            

    ncjb wrote:
    well, for the toString - I have to print out the info inside the array -- am I right in thinking that the only way to do this is to pass in the array ??If the array is part of the class then there is no need to pass it as a parameter. If it is being passed in from outside the class then I have to question your design. Why should class X being formatting data that is not a representation of itself?
    and i have 2 other files that go with this program . . . I just want to know if there is a way to make sure that when the user presses the NO option, it will exit the loop -- the piece of code you see if apart of an entire method (not long) -- do you want me to include this??You read that link I provided REAL quick!

  • How do you use the Multiple Item Information dialog box ???

    How do you use the Multiple Item Information dialog box ???
    Where are the instructions on how the information in the Multiple Item Information dialog box equates to ...
    1. The way iTunes sorts tracks and albums
    2. The reason to select a leading check box
    3. Why there are Option selections (Yes /No) and leading check boxes.
    4. Why some changes remain in the track info, but do not "take effect" in iTunes (Part of a compilation is an example)
    Looked in Help, Support, went to the local Genius bar for an hour, even arrainged a call from apple support ...
    Thanks

    As Christopher says, it's a compilation. Different tracks are by different artists.
    Setting the *Album Artist* field to *Various Artists* and setting *Part of a compilation* to Yes should be all that is required. Depending on your *Group compilations when browsing* setting ( I recommend On ) either should suffice but I suggest doing both.
    Based on your commentary, I selected all the "O Brother" tracks, and checked the boxes for everything line that was blank in the Info and the Sort panes. Only exceptions were the album name and the disc number 1 of 1 and the artwork. I blanked and checked anything else.
    That's not what I meant. When you select multiple tracks, only those values which +are already common+ to all tracks are displayed. Typically these will include Artist, though not with compilation albums, Album Artist, Album, No. of Tracks, Genre plus various sort fields. A blank value may indicate that different tracks have different values or it may be that the value is blank for all tracks. For the drop down values on the Options tab the value shown may not reflect the information in every tag. If values you expect to be common, such as Album Artist or the Album title are not displayed you can simply type these in and click OK. This will often be enough to group the album.
    If you place a checkmark against the blank boxes and apply changes then you will clear those fields so you should only do this if that is the effect you want. Putting a checkmark next to an empty (representing different values) *Track No.* box, for example, will just clear the all the track numbers which is very rarely useful.
    Adding then removing extra text is for a specific problem where despite all common values being identical across the tracks of the album iTunes seems to "remember" that it should see two albums. A typical example would be when an album originally listed as *Album CD1* & *Album CD2* is given disc numbers X of Y and then has the Album name changed to Album. I've seen iTunes merge all but one track into the new album, but insist on listing one remaining track separately, despite both albums having the same title. In this case I've found overtyping the album title again has no effect whereas changing it to AlbumX and then back to Album does what I was trying to achieve in the first place.
    Don't forget that even properly organsied albums may still break up if you don't chose an album-friendly view. Sorting on the track name or track number columns can be useful in some circumstances but in general I revert to Album by Artist when browsing through my library.
    tt2

  • When I put a website Icon on my desktop, how do I make firefox use the Icon native to that website instead of the default Firefox Icon?

    When I drag and drop a website onto my desktop, how can I make Firefox use the icon native to that website instead of the default firefox icon?
    I have even gone painstakingly (SEVERAL TIMES) to the sites with IE, dragged the site onto my desktop in order to obtain the site native icons for my desktop (and deleted the ones with the Firefox icon) .... but they all soon revert to the default Firefox icon.
    E X T R E M E L Y F R U S T R A T I N G !!!!!!!!!

    I don't want icons from the Firefox library.
    I want the icon that comes from the website I'm making the shortcut for.
    (If you go to a site in IE you will see the site generated icon at the left end of the URL in the address field.)
    If I make IE my default browser I am able to get (and keep) those icons as shortcuts on my desktop without a problem.
    I want to keep Firefox as my default browser.
    So I want to know how to make Firefox accept the icon that comes from the website like IE does.
    I have even gone to the trouble to use IE to create the shortcuts with the site specific icons.....but after I do that...... FIREFOX CONVERTS THEM TO THE FIREFOX DEFAULT ICON as soon as I re-boot or refresh my desktop.
    I generally prefer Firefox as a browser....but If there's no fix.....I'm going to dump Firefox.

  • How to Use different icons for JTree in the same level

    Hi guys, i come cross a problem with JTree. The module need a JTree which need to represent items in the same level using different icons. For example:
    [Icon for Root]Root
    |
    |_____________[Icon for Table] TABLES
    |
    |_____________[Icon for Index] INDEXS
    |
    |_____________[Icon for Views] VIEWS
    As i know, the default behavior for JTree is using the same icon for all leaves and
    the same icon for all node that has children. How can i achieve that?
    Thansk a lot!

    subclass DefaultTreeCellRenderer. if you overwrite the method below, then you can set the icon to whatever you want....!
        public Component getTreeCellRendererComponent(JTree tree, Object value,
                                    boolean sel,
                                    boolean expanded,
                                    boolean leaf, int row,
                                    boolean hasFocus) {
         String         stringValue = tree.convertValueToText(value, sel,
                               expanded, leaf, row, hasFocus);
            this.tree = tree;
         this.hasFocus = hasFocus;
         setText(stringValue);
         if(sel)
             setForeground(getTextSelectionColor());
         else
             setForeground(getTextNonSelectionColor());
         // There needs to be a way to specify disabled icons.
         if (!tree.isEnabled()) {
             setEnabled(false);
             if (leaf) {
              setDisabledIcon(getLeafIcon());
             } else if (expanded) {
              setDisabledIcon(getOpenIcon());
             } else {
              setDisabledIcon(getClosedIcon());
         else {
             setEnabled(true);
             if (leaf) {
              setIcon(getLeafIcon());
             } else if (expanded) {
              setIcon(getOpenIcon());
             } else {
              setIcon(getClosedIcon());
            setComponentOrientation(tree.getComponentOrientation());
         selected = sel;
         return this;
        }

  • How do I resize a toolbar button? It is larger than the standard buttons, even on use small icon.

    I have an extension for clearing cache and it has a convenient button on my toolbar. But, the button is larger than the other buttons on the toolbar, even with "use small icons" turned on. Can I talk to the button in the userChrome.css or some other way to scale it down?

    Which extension did you install?
    This one:
    *Clear Cache Button: https://addons.mozilla.org/en-US/firefox/addon/clear-cache-button/
    <pre><nowiki>#clearcache-toolbarbutton .toolbarbutton-icon {
    height: 16px !important;
    width: 16px !important;
    }</nowiki></pre>

  • Anyone know how to create/use particular icons for stack icons?

    Hiya!
    I currently have the following folders as some of my individual stacks in my dock.
    Pictures
    Applications
    Music
    Movies
    Home
    Now if I right-click on any of them and select 'Display as Stack' then the first file in the folder gets used as the dock icon for that stack folder. So obviously this could change from time to time as more files get added to folders.
    Does anyone know how I can use a particular picture/icon to remain as the icon for a specific stack please?
    So for example I would like to drag the 'Downloads' folder down to the dock and have it as a stack. But it never uses the circular green icon as its icon when I select 'Display as Stack'. Instead simply displays the stack as a blue folder with an arrow pointing down. Anyone know how I can set it to the circular green icon please?
    Thanks for any help, its appreciated.
    Shams.

    yes, you need to apply a custom icon to your Downloads folder using the link I gave you. then that icon will display in the dock instead of the blue folder icon. there are lots of places to get custom icons like Interface lift
    http://interfacelift.com/icons-mac/
    you can also use Liteicon http://www.freemacsoft.net/LiteIcon/ or Candybar http://www.panic.com/candybar/ to easily manipulate system icons.

Maybe you are looking for

  • CSS works only in layout?

    Never seen this before- I have a link to an external CSS file; it seems to work fine in layout mode, but in Preview or a browser, it doesn't completely take - some items work and some don't. It's very simple and the only CSS the page uses. Any ideas?

  • Forte 30N2 : Message duration SO restart after a crash issue

    In our application, the batch processes are based on a 'Controller-Processor' pattern. A controller starts many processor tasks as parallel processes. The problem is that our Controller process crashed. However, by that time, many processor processes

  • How to upgrade to latest Numbers 2.0.3?

    My existing Numbers version is 2.0.2. Recently I got a notice that 2.0.3 is available for update when I open Numbers. Then I click the button to allow update download and installation. However, after software update and rebooting my MacBookPro, my Nu

  • Time Machine backups onto new hard drive

    My hard drive recently failed and I had it replaced. I am trying without success to restore my data using the Time Machine external drive that backed up my old hard drive. When installing Snow Leopard, it wouldn't recognize my TM drive, so I just did

  • Why do I have 4.41 GB in my Other storage

    Why do I have 4.41 GB in my Other storage.  I can't even download anymore apps or take pictures.