The Artima Developer Community
Sponsored Link

Java Answers Forum
Scrollbar - need help

3 replies on 1 page. Most recent reply: Apr 21, 2002 1:03 AM by Neva Mohammad

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Neva Mohammad

Posts: 28
Nickname: neva
Registered: Apr, 2002

Scrollbar - need help Posted: Apr 20, 2002 7:23 AM
Reply to this message Reply
Advertisement
Am trying to create a Panel with a Scrollbar. I have the scrollbars positioned horizontally and vertically but I can't seem to come up with a method to get the page to scroll down/across when I use it.
Can someone help pls?
Thanks


Jay Kandy

Posts: 77
Nickname: jay
Registered: Mar, 2002

Re: Scrollbar - need help Posted: Apr 20, 2002 11:31 AM
Reply to this message Reply
Instead of adding scroll bars to panel and implementing listeners to those scroll bars, you could save much time by adding your panel to JScrollPane as they have JScrollBars and JViewPort within.
JScrollPane scrollPane = new JScrollPane(thePanel);

This is a helpful tut-http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Scrollbar - need help Posted: Apr 20, 2002 3:01 PM
Reply to this message Reply
You might also try setting the size of your Panel with either the:
setSize(Dimension d);
or

setSize(int width, int height);
methods.
If you panel is a JPanel or if using a JScrollPane, use

setPreferredSize(Dimension d);

or
setPreferredSize(new Dimension (int width, int height));


etc..

Neva Mohammad

Posts: 28
Nickname: neva
Registered: Apr, 2002

Re:setting the Cursor to a new TextField Posted: Apr 21, 2002 1:03 AM
Reply to this message Reply
Thanks for the help. Managed to do it! The scrollpane worked.

Would anyone know how to set the cursor to a TextField? For example I have 10 TextFields, all asking for input. For usability purposes, I would like the user to be able to enter their input, press "Enter" and follow on to the next TextField. At the moment I have to use tab to move to the next TextField.
I tried using t1.setCursor() (where t1 is my TextField) but I get the compilor error message:
setCursor() not found in java.awt.TextField

does anybody know what I should do?
Thanks

Flat View: This topic has 3 replies on 1 page
Topic: swing , when mouse moves over jlabel  not firing the event Previous Topic   Next Topic Topic: Need help in tesing a Java tool

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use