• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding JTable to a null layout  RSS feed

 
Talal Mohammed
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, First I'd like to point out that this is my first post so go easy on me, second I'm a sort of beginner so if I don't make any sense just go on, however I don't need a very elaborate answers I can afford a Google search. Lets Begin:

I want to add a JTable to a null layout if possible
Thank you
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Why are you using a null layout? The layout managers are all designed to maintain the arrangement of child components when the display is resized, so you would do better to use a specific layout. I know they take time to learn, but it is worth the effort.
What is wrong with this?You will of course have to ensure there are no other child components being added which occupy the same space.
There are details about layouts in the Java Tutorials, and there is a helper class for GirdBagLayout here. If you can find a copy of Horstmann’s book, it tells you a lot more about GridBagLayout; the classic tutorial (no, classic anti-tutorial ) shows how awkward GridBag can be. It is worth Googling for MigLayout, which I have never tried, but a lot of people say it is better and easier to use than GridBag.
That will give you a layout, only the button on the right will probably appear rather tall and thin.
 
Talal Mohammed
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mate, I never knew about setting bounds for tables guess it works for most containers as well. that fixed my problem..
I was using this prior to your solution
myTable.setPreferredScrollableViewportSize(new Dimension(100, 450));
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!