Reputation: 57
I'm new to Java and I would like to know how to position an image within a JTextPane
. Is it possible? Is there any other methods for positioning an image in a JLabel
?
Upvotes: 1
Views: 217
Reputation: 57381
You can create a JLabel for the image, call setBounds() for the image and call jTextPaneInstance.add(theImageLabel).Or you can specify any desired LayoutManager for the jTextPaneInstance and just add the label with appropriate constraint.
If you mean something like text flow around the image it's much much more difficult to implement but also possible (depends on EditorKit you use there).
Upvotes: 1
Reputation: 919
The gridBagLayout can be used to position components within a JFrame.
Take a look here: http://docs.oracle.com/javase/7/docs/api/java/awt/GridBagLayout.html
I usually use gridLayout,it is less flexible, but easy to use for simple layouts.
Upvotes: 1