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 / August 2004

Tip: Looking for answers? Try searching our database.

Just a Great Big Scrollable Line

Thread view: 
Aviv Gurwitz - 31 Aug 2004 22:08 GMT
Hello,
I am a bit new to java and the java swing GUI.
I am writing a JApplet.
What I am trying to do is draw a line (say from (0, 0) to (1000, 1000)) and
have the applet supply automatic scrollbars so that the user can see the
whole line (sounds stupid - I know, but its a step in my direction).
Anyway, I tried to inherit from a JLabel, change the inherited comopnent's
paintComponent method to draw a line and put the inherited component in a
JScrollPane.  However, this only resulted in a Line which was only partially
seen and no scrollbars.  Moreover, I discovered that if I just add text to
my label with the setText method then I get auto scrollbars if I make the
applet smaller than the text size.  This means that the setText method is
doing something that defines it's boundaries for the JScrollPane to react
to.  So, my question is: How do I tell the JScrollPane that my inherited
JLabel is 1000x1000 (and not just the size of the text)?
Thanks,
Aviv.
Cid - 31 Aug 2004 22:04 GMT
>Hello,
>I am a bit new to java and the java swing GUI.
[quoted text clipped - 13 lines]
>Thanks,
>Aviv.

Well, you could subclass JLabel and implement the Scrollable interface
(see javadoc for JScrollPane and Scrollable to see how JScrollPane
interacts with that interface).

But are you sure you don't just want to use a JTextArea instead?


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.