This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to specify JEditorPane initial size ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to specify JEditorPane initial size ??" Watch "How to specify JEditorPane initial size ??" New topic

How to specify JEditorPane initial size ??

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
I know for JTextArea i can give rows and columns
but the JEditorPane, just is big enough initialluy
to accomodate the displayed text and not more
this is inconvenient when there is no text to begin with.
how can i set a particular initial preferred size ?
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
the layout manager sets the size of the components.
if the JEditorPane is inside a JScrollPane, you can specify the preferred size of its viewport. for the frame that contains the scrollpane, you should call pack() (instead of setSize()). the layout manager will then take the preferred sizes of the components to lay them out.
scrollPane.getViewport().setPreferredSize(new Dimension(300,300);
It is sorta covered in the JavaRanch Style Guide.
subject: How to specify JEditorPane initial size ??