Java Code Examples for javax.swing.text.StyleConstants#setLineSpacing()
The following examples show how to use
javax.swing.text.StyleConstants#setLineSpacing() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OurConsole.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
static MutableAttributeSet style(String fontName, int fontSize, boolean boldness, boolean italic, boolean strike, Color color, int leftIndent) { fontName = AlloyGraphics.matchBestFontName(fontName); MutableAttributeSet s = new SimpleAttributeSet(); StyleConstants.setFontFamily(s, fontName); StyleConstants.setFontSize(s, fontSize); StyleConstants.setLineSpacing(s, -0.2f); StyleConstants.setBold(s, boldness); StyleConstants.setItalic(s, italic); StyleConstants.setForeground(s, color); StyleConstants.setLeftIndent(s, leftIndent); StyleConstants.setStrikeThrough(s, strike); return s; }
Example 2
Source File: MainPanel.java From java-swing-tips with MIT License | 6 votes |
private MainPanel() { super(new GridLayout(3, 1)); JTextPane label1 = new JTextPane(); // MutableAttributeSet attr = new SimpleAttributeSet(); Style attr = label1.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setLineSpacing(attr, -.2f); label1.setParagraphAttributes(attr, true); label1.setText("JTextPane\n" + DUMMY_TEXT); // [XP Style Icons - Download](https://xp-style-icons.en.softonic.com/) ImageIcon icon = new ImageIcon(getClass().getResource("wi0124-32.png")); add(makeLeftIcon(label1, icon)); JTextArea label2 = new JTextArea("JTextArea\n" + DUMMY_TEXT); add(makeLeftIcon(label2, icon)); JLabel label3 = new JLabel("<html>JLabel+html<br>" + DUMMY_TEXT); label3.setIcon(icon); add(label3); setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); setPreferredSize(new Dimension(320, 240)); }
Example 3
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private MainPanel() { super(new BorderLayout()); MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.RED); StyleConstants.setFontSize(attr, 32); MutableAttributeSet a = new SimpleAttributeSet(); StyleConstants.setLineSpacing(a, .5f); // StyleConstants.setSpaceAbove(a, 5f); // StyleConstants.setSpaceBelow(a, 5f); // StyleConstants.setLeftIndent(a, 5f); // StyleConstants.setRightIndent(a, 5f); JTextPane editor1 = new JTextPane(); editor1.setParagraphAttributes(a, false); setDummyText(editor1, attr); // StyleSheet styleSheet = new StyleSheet(); // styleSheet.addRule("body {font-size: 24pt; line-height: 2.0}"); // XXX // HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); // htmlEditorKit.setStyleSheet(styleSheet); // editor1.setEditorKit(htmlEditorKit); // editor1.setText("<html><body>12341234<br />***<br />111<font size='32'>12341234<br />999</font></body></html>"); JTextPane editor2 = new JTextPane(); editor2.setEditorKit(new BottomInsetEditorKit()); setDummyText(editor2, attr); JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT); sp.setTopComponent(new JScrollPane(editor1)); sp.setBottomComponent(new JScrollPane(editor2)); sp.setResizeWeight(.5); add(sp); setPreferredSize(new Dimension(320, 240)); }