• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding JTable to a null layout

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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));
reply
    Bookmark Topic Watch Topic
  • New Topic