This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Using Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Using Swing" Watch "Using Swing" New topic
Author

Using Swing

Karis Brown
Ranch Hand

Joined: Nov 13, 2003
Posts: 33
Why does does a JPanel work in a main public class but not in the subclass?


So Cold & So Outa Control
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

It would help if you said why it didn't "work"...

I'm assuming that you mean that the components you're adding to the JPanel inner class aren't showing up. This is because you put them in a method called "init()" in the inner class. Only applets automatically call their init() method. You'll have to either change the inner class's init() method to a constructor, or call init() on the sClass instance after you create it.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Swing