Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Dialog Woes...

  1. #1
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Dialog Woes...

    Hello everybody!

    I've run into a bit of a problem. I've made a ProgressGUI class (I'm aware that some already exist; I just wanted to make a more simple, custom version) that I'm using in collaboration with some save() and load() methods I'm using with Roster objects (that I've created to hold information for players, teams, etc.).

    So, to test this I made a ProgressGUI to be used with my loadRoster() method, which is implemented roughly in a test class I've made.

    Here's the load method's call in the test class:

    //If I put a println here, the program prints it just fine
    Roster load = FileUtility.loadRoster("Test Roster");
    //println's put here are not displayed

    Here's what the part of the loadRoster() method with the ProgressGUI looks like:
    //println's put here are displayed
    ProgressGUI p = new ProgressGUI("Loading roster:");
    //println's put here are not displayed
    Roster roster = new Roster();
    File rosterDirectory = new File(ROSTER_DIRECTORY + "/" + rosterSaveName);

    And here's the ProgressGUI constructor:
       public ProgressGUI(String title, String message, double progress)
       {
     
          super(new JFrame(), title, JDialog.ModalityType.APPLICATION_MODAL);
          setSize(400, 100);
          setResizable(false);
          setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
     
          build();
          setMessage(message);
     
          javax.swing.JOptionPane.showMessageDialog(null, "Now setting location!"); //This message works
          setLocationRelativeTo(null);
          //println's put here are displayed
          setVisible(true);
          //println's put here are not displayed
     
       }

    So, since all println's are displayed until after the ProgressGUI is displayed, I think the problem has something to do with the ProgressGUI wanting some sort of input, or needing to be disposed of before the program can continue...

    Does anyone know how to allow this dialog to exist and update its display while other methods are executing (preferably avoiding adding a Thread, if possible)?
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.


  2. #2
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: Dialog Woes...

    Well, typical, I figured out the problem right after I made this thread. The issue was the ModalityType (APPLICATION_MODAL), which I now know doesn't only block the activation of parent windows, but also prevents code that is not from the dialog from executing...

    So I've fixed it. Sorry for wasting your time!
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

Similar Threads

  1. Default Dialog box changes size
    By anu21g in forum AWT / Java Swing
    Replies: 3
    Last Post: January 2nd, 2012, 05:46 AM
  2. Saving the dialog box data
    By nrao in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: February 24th, 2011, 02:53 PM
  3. Saving a file using a dialog box
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 5th, 2010, 05:21 PM
  4. Simple Input Dialog Question
    By tabutcher in forum Java Theory & Questions
    Replies: 0
    Last Post: March 1st, 2010, 11:10 PM
  5. [SOLVED] Help with dialog box
    By 03EVOAWD in forum AWT / Java Swing
    Replies: 5
    Last Post: August 4th, 2009, 11:06 AM