Results 1 to 6 of 6
  1. #1
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default how to run JoptionPane.showMessageDialog - in the background

    hello

    I want in the GUI to show messege - but not wait for the user confirmation for continue with the program . in other word - show the messeger, leave it open and continue

    How can I do it ?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You should create a JDialog and display it in a non-modal fashion. You can do this either by creating a JOptionPane and extracting a JDialog from this (the API will tell you how) or by creating a JDialog de-novo, which is quite similar to creating a JFrame. Again, the API will show you the constructors.

  3. #3
    josemoncas's Avatar
    josemoncas is offline Member
    Join Date
    Jul 2009
    Location
    Madrid (Spain)
    Posts
    11
    Rep Power
    0

    Default

    You should use your own JDialog and use it as non-modal.

    The easiest way is to create a JOptionPane and add it to a non-modial JDialog:

    Java Code:
    JDialog dialog = new JDialog(frame, false); // Sets its owner but makes it non-modal 
    JOptionPane optionPane = new JOptionPane("Message"); // Same arguments as in JOptionPane.showMessageDialog(...)
    dialog.getContentPane().add(optionPane); // Adds the JOptionPane to the dialog
    dialog.pack(); // Packs the dialog so that the JOptionPane can be seen
    dialog.setVisible(true); // Shows the dialog
    Hope it helps.
    Last edited by josemoncas; 07-28-2009 at 02:53 PM.
    The web that offers Java utilities (classes) which make programming Swing applications an easier task: JMC Java utilities

  4. #4
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default

    thanks
    You should use your own JDialog and use it as non-modal.

    The easiest way is to create a JOptionPane and add it to a non-modial JDialog:
    it helped

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by josemoncas View Post
    You should use your own JDialog and use it as non-modal. The easiest way is to create a JOptionPane and add it to a non-modial JDialog:
    The reason I recommended inspecting the API is that there's an even easier way of creating a JDialog from a JOptionPane, one that creates the dialog directly from the JOptionPane using its createDialog method:
    Java Code:
        // assuming a JFrame called frame...
        JOptionPane optionPane = new JOptionPane("Message"); 
        JDialog myDialog = optionPane.createDialog(frame, "Dialog Title");
        myDialog.setModal(false);
        myDialog.setVisible(true);

  6. #6
    josemoncas's Avatar
    josemoncas is offline Member
    Join Date
    Jul 2009
    Location
    Madrid (Spain)
    Posts
    11
    Rep Power
    0

    Default

    No conocía esa forma :)

    Algo nuevo pa'l librito :P
    The web that offers Java utilities (classes) which make programming Swing applications an easier task: JMC Java utilities

Similar Threads

  1. help with JOptionPane.showMessageDialog()
    By gmn1 in forum New To Java
    Replies: 8
    Last Post: 03-30-2009, 10:31 AM
  2. Sick of duplicating JOptionPane.showMessageDialog
    By gdanelian in forum New To Java
    Replies: 2
    Last Post: 11-18-2008, 06:53 PM
  3. Replies: 1
    Last Post: 10-29-2008, 08:50 AM
  4. About JOptionPane.showMessageDialog
    By jhetfield18 in forum AWT / Swing
    Replies: 2
    Last Post: 11-02-2007, 11:45 PM
  5. About JOptionPane.showMessageDialog
    By jhetfield18 in forum Advanced Java
    Replies: 0
    Last Post: 11-02-2007, 11:56 AM

Posting Permissions

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