• Post Reply Bookmark Topic Watch Topic
  • New Topic

Panel not showing components  RSS feed

 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My panel named panelIncomeInfo are not showing the components that I have added. I am pretty sure this is a simple fix but I couldn't find what was wrong. Need help and I welcome all critism on ways to improve my code.

 
Stephan van Hulst
Saloon Keeper
Posts: 7722
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are making your frame visible before finishing the layout.

Always perform all the add operations first, then set the size of the frame, and finally make the frame visible. You don't have to mess with the visibility of components inside the frame.

Don't forget to initialize your frame on the event dispatch thread (maybe using SwingUtilities.invokeLater() ).
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:You are making your frame visible before finishing the layout.

Always perform all the add operations first, then set the size of the frame, and finally make the frame visible. You don't have to mess with the visibility of components inside the frame.

Don't forget to initialize your frame on the event dispatch thread (maybe using SwingUtilities.invokeLater() ).


Made these suggestions and now nothing shows in the frame but a single black line......
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That thin line is probably all your components flattened and on top of each other, jammed in to the top-left corner. If you are going to use MigLayout, you will need to specify layout constraints for the layout manager and/or each component which you add.
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:That thin line is probably all your components flattened and on top of each other, jammed in to the top-left corner. If you are going to use MigLayout, you will need to specify layout constraints for the layout manager and/or each component which you add.


ok
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried something very quick and at least some of your components popped-out.

private MigLayout layout = new MigLayout("", "[500]", "[300]");

 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:I just tried something very quick and at least some of your components popped-out.

private MigLayout layout = new MigLayout("", "[500]", "[300]");



I basically have the same thing now except different layout constraints. My nested panels are not showing any components and I can't figure out what is wrong as to why. I have tried using different component constraints but nothing worked. I also used the debug layout constraint and the nest panels aren't showing any columns or rows.
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean the JLabels? If you didn't set a value for them they will be empty.
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:Do you mean the JLabels? If you didn't set a value for them they will be empty.


Im an idiot.....thank you....maybe next time I should try different components before asking.....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!