Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

re: Could I add a scroll bar to my JTable?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

  My JTable is getting too big where I have all eight columns to display , May I add an horizontal or vertical scroll bar to my JTable?

May I explain to you my situation so your may have a better understanding of my situation.

I have a Jframe . In the Jframe, I create a North Panel, a West Panel, and a South Panel for display different kind of data.

In my West Panel, I have a GridBagConstraint called tableGC as in the code below. TableGC have two rows. The first row contains my table, and the

second row contain the submit button.










My question is that could I make my table scroll-able on both horizontal and vertical direction . I was googling and someone told me that I need

to create a JScrolPanel and instantiated it with my Jtable and,  add the new tableScrollPanel to my westPanel as my gridbaglayout element.

I followed them and did what I was taught as followed in the following code  



But it did not work, it only showed me a very little bit tiny table on my westPanel.

So I would like to seek your help and expertise on how should I make my table scroll-able and my table is in the first row of a gridbaglayout , and the

gridbaglayout is in the westPanel?



Many Thanks for all of your helps!!
 
Rancher
Posts: 3191
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want horizontal scrolling then you need to use:


 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic