Results 1 to 5 of 5
Thread: use while loop in jframe
- 02-09-2011, 03:09 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 6
- Rep Power
- 0
use while loop in jframe
i am writting a program need to render new object into the scene graph continuously
the program is connect to other program and use a while loop to read message from it, so the program know which object need to render into the scene graph next and renew the frame
the problem is the frame only visible after the method is end
if the while loop dont end, the frame show nothing
so... how can i solve this problem? is it need to use other method to renew the frame instead of using while loop?Last edited by vinci; 02-09-2011 at 03:11 PM.
- 02-09-2011, 03:12 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,638
- Rep Power
- 13
You question is hard to understand, especially without an SSCCE that demonstrates the problem. What I can guess is that you have a loop that is tying up the EDT...place this work in another Thread or use a SwingWorker.
- 02-09-2011, 03:21 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 6
- Rep Power
- 0
here is my code
it is expected to get new object info in the while loop and renew the scene geaph
but the frame don't show anything, unless i remove the while loop
Java Code:public void init() { ... snip setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); JPanel p = new JPanel(); p.add(forward); p.add(backward); p.add(left); p.add(right); p.add(up); p.add(down); p.add(quit); add("North", p); universe = new SimpleUniverse(c); ... snip while(true){ msg = s.readLine(); if(msg.equals(".")) { con.sendmessage(msg); con.readmessage(); System.out.println("client got:" + msg); break; } con.sendmessage(msg); con.readmessage(); System.out.println("client got:" + msg); } client.close(); } catch (IOException e) { e.printStackTrace(); } }
- 02-09-2011, 03:23 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,638
- Rep Power
- 13
Read my post above...place long running tasks in a Thread or SwingWorker
- 02-09-2011, 03:28 PM #5
Member
- Join Date
- Jan 2011
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
to pass a parameter from a jframe children to its jframe mother
By anix in forum NetBeansReplies: 5Last Post: 06-14-2010, 06:10 PM -
JFrame from a JFrame in project
By anah in forum AWT / SwingReplies: 2Last Post: 04-19-2010, 06:20 PM -
Passing data from one JFrame to another JFrame. - need help.
By Unsub in forum New To JavaReplies: 6Last Post: 04-12-2010, 11:33 AM -
Passing data from one JFrame to another JFrame
By tarami in forum New To JavaReplies: 3Last Post: 08-06-2009, 05:44 PM -
How to make a Jframe un-focusable when another Jframe is active?
By Robert_85 in forum Advanced JavaReplies: 4Last Post: 04-22-2009, 11:02 PM
Bookmarks