aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes could someone look at my code and help me with a JScrollPane in a JTextPane please? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "could someone look at my code and help me with a JScrollPane in a JTextPane please?" Watch "could someone look at my code and help me with a JScrollPane in a JTextPane please?" New topic
Author

could someone look at my code and help me with a JScrollPane in a JTextPane please?

Sebastion Hill
Ranch Hand

Joined: Jul 10, 2009
Posts: 48
Hi I am trying to get a JScrollPane going vertically in my JTextPane but I am having no luck at this. Is my gridbaglayout the reason why my scrollpane fails to work? :-/

Could someone offer any help or suggestions for fixing this and understanding what is going on?

Sebastion Hill
Ranch Hand

Joined: Jul 10, 2009
Posts: 48
actually, I am slow ... I don't know how I missed the tutorial for this ... bout to check it out now (hopefully i can figure it out on my own first)

Update! Reading is fundamental ... i think i solved my problem ... is there a way to delete this thread? so it doesn't take up space?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38394
    
  23
If you have difficulties with anything like that in Swing, always try a tiny application which simply does one thing. Then you can sort out one problem at a time. It was really difficult to try your app, particularly since the Activity class was missing, but eventually I found you aren't adding "scrollPane" to your panel anywhere . . .

Look at Cai Horstmann's website; there is a class called GBC which makes GridBag much easier to use.

We usually discuss this sort of thing on the Swing forum, so I shall move you there.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38394
    
  23
Sebastion Hill wrote:is there a way to delete this thread?
We don't delete threads, unless there is "something wrong with them." The discussion might be useful for somebody else in future. Also you may get other helpful opinions after you think the problem has been finished with.
Sebastion Hill
Ranch Hand

Joined: Jul 10, 2009
Posts: 48
Hi Campbell, about to look at Cai Horstmann's website for the class you mentioned. Also, sounds good that you all keep the threads for others. Just FYI, the link I forgot to read for this was: http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html

Also, sorry about not putting ALL of my code up for people to try out ... here it is, late (sorry). Btw, is my ActivityTab clas proper use of OO programming?





Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38394
    
  23
I have only had a 5-second look at your Activity class, but it looks mostly right to me. If you are doing something, and call it an Activity, with those attributes, then that is the sort of class you would want. You should consider overriding the equals() hashCode() and toString() methods. You should also consider whether the number you are returning adds anything to the boolean values about importance and urgency, and whether it is necessary at all.
Thank you for posting the code, but often an abbreviated application which reproduces the problem (called SCCEE or something like that) (more details here, with correct spelling!) is much easier to read.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: could someone look at my code and help me with a JScrollPane in a JTextPane please?