Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running Swing

 
Bill Ostaski
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am completely new to Swing, but am not a java novice.

I've created a couple of swing classes, but do not get a gui when I run them from command line or eclipse.

Sorry in advance for the lengthy code below, but I couldn't attach them to this post for some reason.

Here's the main class:


and UpdateView:


Anyone have a clue what I am doing wrong?

Thanks!
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're trying to display a JPanel without first putting it into a top-level container such as a JFrame, JDialog, JApplet or the like, and this simply won't work. I suggest you go through the Sun Swing tutorials, in particular focus on the one about using JFrames and top level containers, and you'll find your solution:

Using JFrames
Using Top-Level Containers

Much luck!
 
Rob Spoor
Sheriff
Pie
Posts: 20751
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill, try to keep the lines a bit shorter. I've split the array creation over multiple lines so no horizontal scrolling is needed anymore.
 
Bill Ostaski
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Rob: Thanks, I knew I was missing something important.

@Pete: Didn't think of that, but will do in the future.

Thanks again folks!
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill Ostaski wrote:
@Pete: Didn't think of that, but will do in the future.


Huh? My suggestions were for right now, not the future. Perhaps you confused me with Rob? We kind of look alike.
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete stein wrote:Huh? My suggestions were for right now, not the future. Perhaps you confused me with Rob? We kind of look alike.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic