• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add panel in from other class  RSS feed

 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I have two classes. I need to display the JPanel from second class. The code is below

Login.java



Main.java



I get the error at line 59 i.e mpanel = new JPanel(si);

I need a little help please point at the mistake.

Thanks and Regards
alexander
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPanel does not have a constructor that takes an ActionListener as an argument.

Can you tell us, in words, what you are trying to do on that line?
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Main application isn't a JPanel and doesn't offer a JPanel that can be used anywhere. Instead it is geared to create a JFrame and displays an app in the JFrame. Fortunately it can be modified to allow us to extract its JPanel. Have a look at some changes I've made:



and then in Login:
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!