How to Edit Margins in JEditorPane
The "JEditorPane" is a Java control that contains controls for users to input text or select options. You use the Inset class' "setMargin" function to set the JEditorPane's margin settings. The margin is the space and padding between the controls and the edge of your JEditorPane control. By default, no margin is set, so controls render on the edge of the frame.
Instructions
-
-
1
Right-click the Java file that contains your JEditorPane and click "Open With." Click your Java editor to open the code in the editor.
-
2
Create a JEditorPane, if you do not already have one created. The following code creates the JEditorPane:
JEditorPane pane = new JEditorPane();
-
-
3
Create the "Inset" class variable to set the margin. The following code sets up the margins for the JEditorPane:
Insets margins;
margins.left = 5;
margins.right = 5;Replace the "5" setting with the space you want to set around your JEditorPane.
-
4
Bind the new margins to the JEditorPane control. The following code binds margins to the JEditorPane:
pane.setMargin(margins);
-
1