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?