Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2005

Tip: Looking for answers? Try searching our database.

Can't scroll horizontal scrollbar

Thread view: 
Kurt Underhay - 11 Apr 2005 10:04 GMT
I've got an app with a GUI that includes a JTable. I'd like for the
table to be scrollable, so I've created a JScrollPane on it. However,
the horizontal scrollbar doesn't have a scroll knob on it, and using the
left/right scroll buttons doesn't cause it to scroll. How can I get the
horizontal scrolling working?

Relevant code fragment below.
-----------------------------------------------

JFrame frame = new JFrame(title);
JDesktopPane JDPane = new JDesktopPane();
frame.getContentPane().add(JDPane);
       
JInternalFrame JIFrame1 = new JInternalFrame(title + " JIFrame1");
JDPane.add(JIFrame1);

JTable table = new JTable(100,100);
JIFrame1.getContentPane().add(table);
table.setVisible(true);

JScrollPane JSPane = new JScrollPane(table);
JSPane.setPreferredSize(new Dimension(100,100));

JSPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JSPane.getHorizontalScrollBar().setEnabled(true);
JIFrame1.getContentPane().add(JSPane);

JIFrame1.setClosable(true);
JIFrame1.setResizable(true);
JIFrame1.setSize(200,200);
JIFrame1.setVisible(true);
frame.setSize(800,700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Richard F.L.R.Snashall - 11 Apr 2005 11:40 GMT
> I've got an app with a GUI that includes a JTable. I'd like for the
> table to be scrollable, so I've created a JScrollPane on it. However,
[quoted text clipped - 4 lines]
> Relevant code fragment below.
> -----------------------------------------------

> JSPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

This sounds a lot like the symptoms I had once.  The only way I
found to fix it was (I accidently found this) to set the layout
to BoxLayout in the outer frame.  I do not know if that will
work in your case, though.
Christian Kaufhold - 11 Apr 2005 12:11 GMT
> I've got an app with a GUI that includes a JTable. I'd like for the
> table to be scrollable, so I've created a JScrollPane on it. However,
> the horizontal scrollbar doesn't have a scroll knob on it, and using the
> left/right scroll buttons doesn't cause it to scroll. How can I get the
> horizontal scrolling working?

table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

Christian
Kurt Underhay - 11 Apr 2005 12:41 GMT
>>I've got an app with a GUI that includes a JTable. I'd like for the
>>table to be scrollable, so I've created a JScrollPane on it. However,
[quoted text clipped - 5 lines]
>
> Christian
Perfect - works fine now, thanks.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.