Results 1 to 5 of 5
  1. #1
    aoen is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default JFrame not rendering until logic is complete

    So basically I create a JFrame and it's contents, then I hide it.
    I then open it, and run some memory-intensive file-opening afterwards.
    My problem is that the JFrame's contents don't load until after the logic is complete (all I see is the JFrame's box filled with white).
    How can I make sure the JFrame updates it's display properly before running the logic without using threads?
    Last edited by aoen; 07-12-2010 at 06:22 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by aoen View Post
    So basically I create a JFrame and it's contents, then I hide it.
    I then open it, and run some memory-intensive file-opening afterwards.
    My problem is that the JFrame's contents don't load until after the logic is complete (all I see is the JFrame's box filled with white).
    How can I make sure the JFrame updates it's display properly before running the logic without using threads?
    The symptoms you describe are a sure sign that you're running your logic in the EDT (Event Dispatch Thread) so it can't do any painting in the mean time. Take away your logic from that thread and see what happens. (i.e. use another Thread for your logic).

    kind regards,

    Jos

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

  4. #4
    aoen is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default

    Oh sorry didn't know this wasn't allowed :S.


    So I tried making a SwingWorker to do the intensive code for me, but for some reason it only runs the first time I call mySwingWorker.execute() (the second time it does nothing).

    public static void main (String [] args)
    {
    setUp.execute();
    }

    public static SwingWorker <Void,Void> setUp = new SwingWorker<Void, Void>() {
    public Void doInBackground() {
    //Do Intensive Code
    }
    };

    Is there really no way to just give the JFrame time to display it's contents before moving on?

    It seems like I'm going to have to completely restructure all of my code just to put the logic in it's own thread.
    Last edited by aoen; 07-12-2010 at 08:48 PM.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

Similar Threads

  1. JTree rendering problem
    By kmm1977 in forum AWT / Swing
    Replies: 5
    Last Post: 07-07-2010, 01:02 PM
  2. Problem in JSP rendering
    By srkumarj2ee@gmail.com in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 03:02 AM
  3. manual BMP rendering colour issues
    By Goseph in forum AWT / Swing
    Replies: 0
    Last Post: 02-24-2009, 09:26 PM
  4. Help with JTable rendering
    By daniel2008 in forum AWT / Swing
    Replies: 8
    Last Post: 01-18-2009, 04:51 AM
  5. JLabel Rendering
    By random4534 in forum New To Java
    Replies: 3
    Last Post: 12-16-2008, 09:55 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
  •