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 3 of 3

Thread: JDialog Failing to Render...

  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 JDialog Failing to Render...

    I have made a class called ProgressGUI, which is an extension of JDialog. Right now, I am attempting to get an instance of ProgressGUI to show progress as the values of a function are stored into a cache (so that the values don't have to be computer again upon regraphing of the function). However, when the ProgressGUI pops up, its contents are not rendered properly...

    The ProgressGUI window pops up okay, but then all of its content area shows up white, and the progress bar doesn't show at all. I'm confused as to why this is happening... No errors occur and the dialog goes away when all the values have been stored into the cache.

    For more clarification, here's the code using the ProgressGUI:
       public void setFunction(String equation) {
           func.function = equation;
           repaint();
           valueCache = new double[(int)((xMax - xMin) / xstep)][(int)((yMax - yMin) / ystep)];
           ProgressGUI p = new ProgressGUI("Storing Values", "Computing and storing to cache...");
           int n = valueCache.length * valueCache.length;
           int f = 0;
           for(int x = 0; x < valueCache.length; x++) {
              for(int y = 0; y < valueCache[x].length; y++) {
                 valueCache[x][y] = func.evaluate(xMin + x * xstep, yMin + y * ystep);
                 p.setProgress((++f * 100) / n);
              }
           }
           cacheReady = true;
           p.dispose();
       }

    See the images below for what it is supposed to look like, and what it's doing...
    The ProgressGUI is small and in the center, but you'll get the idea.
    Bad...
    progress-bar-bad.jpg
    Good...
    progress-bar-good.jpg

    Any help would be appreciated!
    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

    Default Re: JDialog Failing to Render...

    Well, this is a common problem. The code that updates the progress bar should be executed by a separate thread other than the event dispatching thread (EDT). It looks like you haven't used any thread for that, right?

  3. The Following User Says Thank You to nambill For This Useful Post:

    snowguy13 (April 7th, 2012)

  4. #3
    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: JDialog Failing to Render...

    Thank you! It works great now!
    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. [SOLVED] sending a parameter to a new JDialog
    By luisp88 in forum AWT / Java Swing
    Replies: 4
    Last Post: October 5th, 2011, 10:31 AM
  2. [SOLVED] Click button to open JDialog
    By susieferrari in forum Java Theory & Questions
    Replies: 6
    Last Post: March 30th, 2011, 10:24 AM
  3. Render data on next page
    By Rajat in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: March 25th, 2011, 10:46 AM
  4. close JDialog on button click
    By Christophe in forum AWT / Java Swing
    Replies: 4
    Last Post: April 5th, 2010, 12:04 AM
  5. Unable to render printing the complete JPanel
    By Stephen Douglas in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 13th, 2010, 11:48 AM