Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable resize?  RSS feed

 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've put a JTable in a TabbedPane, but the JTable takes only a part of the TabbedPane, why?
I want it to take all the free place, how can I do it?
Do i need to use renderer?
Thx for help!
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try putting it on a panel with BorderLayout (In the Center). It should then stretch to fit the entire tab.
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have already tried it, but it doesn't work!
table =new JTable(rangee,enTeteColonne);
JScrollPane defiler =new JScrollPane(table);
add(defiler,BorderLayout.CENTER);
Any other suggestion?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Younes,
I haven't worked much with JTabbedPane and this is only a hunch (which means it probably won't work ) but have you thought about setting the layout manager on the JTabbedPane? Maybe to a GridLayout with a single cell?
Just a thought,
Michael Morris
SCJP
 
Wahid Sadik
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try following
(1) Add a JPanel in JTabbedPane
(2) Set BorderLayout to the JPanel
(3) Add JScrollPane to the JPanel in "Center"
(4) Add the JTable in the JScrollPane (i.e. set the JTable as the viewport of the JScrollPane)
This should work, as it did in my current project.. if further help is required, plz mail
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx for helping. I will try it as soon as I get home.
Thx everybody!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!