• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Swing

 
Karis Brown
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does does a JPanel work in a main public class but not in the subclass?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic