Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Can I nest a JEditorPane inside a JScrollPane inside a JPanel?

Reply
Thread Tools

Can I nest a JEditorPane inside a JScrollPane inside a JPanel?

 
 
Mike
Guest
Posts: n/a
 
      12-02-2003
The title pretty much says it all. I've created a class that extends
JPanel and have attempted to place a JScrollPane inside of it with a
JEditorPane inside the scroll pane with no luck. When I run the
applet the scroll pane shows up but the JEditorPane doesn't render. I
am able to nest a JTextArea inside the scroll pane just fine.

Thanks for you help,

Mike
A Java Noob
 
Reply With Quote
 
 
 
 
Woebegone
Guest
Posts: n/a
 
      12-02-2003

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> The title pretty much says it all. I've created a class that extends
> JPanel and have attempted to place a JScrollPane inside of it with a
> JEditorPane inside the scroll pane with no luck. When I run the
> applet the scroll pane shows up but the JEditorPane doesn't render. I
> am able to nest a JTextArea inside the scroll pane just fine.
>
> Thanks for you help,
>
> Mike
> A Java Noob


Well, the short answer is "yes," but I think it requires some tinkering. See
http://java.sun.com/docs/books/tutor...extSamplerDemo
or if you're not at 1.4 yet
http://java.sun.com/docs/books/tutor...mplerDemo.java

Here is a short example: not an applet, but that at least shows it's
possible...

//==========
package news.exp;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class Main {
private static String DOC =
"<html><head>Testing some scrolling</head>" +
"<body><h1>Hello World!</h1>" +
"<p>An editor pane inside a scroll pane.</p></body></html>";
public static void main(String[] args) {
JFrame frame = new JFrame("Test the scrollers");
JPanel panel = new JPanel();
JEditorPane editor = new JEditorPane("text/html", DOC) {
// See justification in javax.swing.Scrollable
public boolean getScrollableTracksViewportWidth() {
return false;
}};
JScrollPane scroller =
new JScrollPane(
editor,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
panel.add(scroller);
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.pack();
frame.show();
}
}

//========

HTH!
Sean.


 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      12-02-2003
"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> The title pretty much says it all.


It is always a good idea to repeat the Subject:
line in the body - I think I heard because certain
newsreaders do not show the headers (shrugs)

Also, and this is far more important.

Please do not multi-post Mike. If you
did not like the answer Harald gave you
over on c.l.j.g, it is best to follow it up there,
rather than bring the discussion over here.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      12-02-2003
Thanks for the tip. I actually posted over here first, and then saw another
message saying that gui questions should be posted over there, so that's
what I did.

"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:maXyb.36070$(E-Mail Removed)...
> "Mike" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > The title pretty much says it all.

>
> It is always a good idea to repeat the Subject:
> line in the body - I think I heard because certain
> newsreaders do not show the headers (shrugs)
>
> Also, and this is far more important.
>
> Please do not multi-post Mike. If you
> did not like the answer Harald gave you
> over on c.l.j.g, it is best to follow it up there,
> rather than bring the discussion over here.
>
> --
> Andrew Thompson
> * http://www.PhySci.org/ PhySci software suite
> * http://www.1point1C.org/ 1.1C - Superluminal!
> * http://www.AThompson.info/andrew/ personal site
>
>



 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      12-02-2003
"Mike" <(E-Mail Removed)> wrote in message
news:bqi2jp$8a5$(E-Mail Removed)...
> Thanks for the tip. I actually posted over here first, and then saw

another
> message saying that gui questions should be posted over there, so that's
> what I did.


As reasonable an answer as I've ever heard, but you
might have saved some bother by acknowledging
you had multi-posted and explaining why.

It's good that you are reading the posts of the
group though.

You might also Google for the recently established
FAQ through the c.l.j.g group. I will leave further
discussion for that group.

(Hope you get a solution BTW!)

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      12-02-2003
Okey dokey smokey.

"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:7o0zb.36529$(E-Mail Removed)...
> "Mike" <(E-Mail Removed)> wrote in message
> news:bqi2jp$8a5$(E-Mail Removed)...
> > Thanks for the tip. I actually posted over here first, and then saw

> another
> > message saying that gui questions should be posted over there, so that's
> > what I did.

>
> As reasonable an answer as I've ever heard, but you
> might have saved some bother by acknowledging
> you had multi-posted and explaining why.
>
> It's good that you are reading the posts of the
> group though.
>
> You might also Google for the recently established
> FAQ through the c.l.j.g group. I will leave further
> discussion for that group.
>
> (Hope you get a solution BTW!)
>
> --
> Andrew Thompson
> * http://www.PhySci.org/ PhySci software suite
> * http://www.1point1C.org/ 1.1C - Superluminal!
> * http://www.AThompson.info/andrew/ personal site
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
latest 500 lines in a JtextArea inside a JScrollPane etantonio Java 3 07-22-2009 04:52 PM
Do you nest classes inside classes? Mike Stephens Ruby 10 05-27-2009 07:44 AM
How can I nest variadic functions? Boltar C Programming 2 09-17-2007 10:56 PM
Set size of JTable inside a JScrollPane Allan Valeriano Java 1 06-16-2007 05:22 AM
Can't Nest Tables in Excel Adrienne HTML 12 02-25-2005 11:01 PM



Advertisments