Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

GUI won't appear

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I start up my server and client applications, no errors occur and both operate as expected except my server GUI doesn't appear. It functions properly though. What could be causing the problem? I would appreciate any assistance!

Note: My server's gui was operating perfectly until I tried to implement threads

I added various System.out.println(jtaResults.getText()); throughout the constructor and the text area had the correct data although the GUI not appearing.
in public void run the program executes the line ServerApp gui = new ServerApp(); but never executes gui.setVisible(true); How do i force it to set the gui to visible?

ServerApp class - constructor




init components in the serverApp class:

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a while(true) loop in the constructor, so your code never hits the setVisible(true) in main(...).

However, the real issue here is that a server application is not a JFrame, so shouldn't extend it. You should create a server application that runs independent of any GUI; then link a GUI and make sure that any long running tasks execute on a Thread other than the EDT, and that all Swing methods and constructors are called on the EDT. For more, see Concurrency in Swing.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
Donio Teixeira
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where else would I create the while loop then? In some tutorials I was following they create the while loop in the same way i did. Or am i seriously confused?
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you gone through the tutorial I linked to?
 
Donio Teixeira
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, i'm a lot more confused now
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic