• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't instantiate JPanel and add it to JFrame.  RSS feed

 
Josh Borg
Ranch Hand
Posts: 37
Chrome Eclipse IDE Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am try to do an application based in multiples JFrames, each one with its particular responsabilities, and use one JPanel as a menu with buttons that connect one JFrame to another, But this menu is instantiated at run in view (layout made by netbeans) the Main Jframe appears with its internal JPanel, but the instantiated JPanel does not appear or does not show it's buttons. (Thanks, it's a big code but you can notice only run method in the second class):

JPanel Menu that will be used in all alone JFrames of application:





One of the View JFrames:





 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I'm confused about this line of code. Since the panel doesn't have a parent when that line of code runs, how can it do anything? If you intended to set the size of the panel, that really isn't a good way to do it. Just use the setPreferredSize() method if you want to set a component's size.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!