JLabel label = new JLabel(FocusableTip.getString("FocusHotkey")); Color fg = UIManager.getColor("Label.disabledForeground"); Font font = textArea.getFont(); font = font.deriveFont(font.getSize2D() - 1.0f); label.setFont(font);
FontMetrics fm = editorPane.getFontMetrics(editorPane.getFont()); int size = 2*fm.getLeading() + fm.getMaxAscent() + fm.getMaxDescent() + 2; editorPane.setPreferredSize(new Dimension(30*size, (int) (1*size)));
@Override public void scrollSourceCodeTo(@Nullable AstNode astNode) { if (astNode != null && astNode.hasToken()) { int visibleLines = sourceCodeEditorPane.getVisibleRect().height / sourceCodeEditorPane.getFontMetrics(sourceCodeEditorPane.getFont()).getHeight(); int line = astNode.getToken().getLine() + visibleLines / 2; try { sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(0)); sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(lineOffsets.getOffset(line, 0))); } catch (BadLocationException e) { throw Throwables.propagate(e); } } }
@Override public void scrollSourceCodeTo(@Nullable AstNode astNode) { if (astNode != null && astNode.hasToken()) { int visibleLines = sourceCodeEditorPane.getVisibleRect().height / sourceCodeEditorPane.getFontMetrics(sourceCodeEditorPane.getFont()).getHeight(); int line = astNode.getToken().getLine() + visibleLines / 2; try { sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(0)); sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(lineOffsets.getOffset(line, 0))); } catch (BadLocationException e) { throw new RuntimeException(e); } } }
/** Set to a sane font (not proportional!). */ @Override public void install(JEditorPane pane) { super.install(pane); pane.setFont(new Font("Monospaced", Font.PLAIN, pane.getFont().getSize() + 1)); //NOI18N } }
@Override public void scrollSourceCodeTo(@Nullable AstNode astNode) { if (astNode != null && astNode.hasToken()) { int visibleLines = sourceCodeEditorPane.getVisibleRect().height / sourceCodeEditorPane.getFontMetrics(sourceCodeEditorPane.getFont()).getHeight(); int line = astNode.getToken().getLine() + visibleLines / 2; try { sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(0)); sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(lineOffsets.getOffset(line, 0))); } catch (BadLocationException e) { throw new RuntimeException(e); } } }
/** Set to a sane font (not proportional!). */ public void install (JEditorPane pane) { super.install (pane); pane.setFont (new Font ("Monospaced", Font.PLAIN, pane.getFont().getSize() + 1)); //NOI18N } }
private void scrollToFirstSelectedPath() { TreePath selectedPath = astTree.getSelectionPath(); if (selectedPath != null) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) selectedPath.getLastPathComponent(); AstNode astNode = getAstNodeFromUserObject(treeNode.getUserObject()); int visibleLines = codeEditor.getVisibleRect().height / codeEditor.getFontMetrics(codeEditor.getFont()).getHeight(); int line = astNode.getToken().getLine() + visibleLines / 2; try { codeEditor.scrollRectToVisible(codeEditor.modelToView(0)); codeEditor.scrollRectToVisible(codeEditor.modelToView(lineOffsets.getOffset(line, 0))); } catch (BadLocationException e) { LOG.error("Error with the scrolling", e); } } }
/** Set to a sane font (not proportional!). */ public void install (JEditorPane pane) { super.install (pane); pane.setFont (new Font ("Monospaced", Font.PLAIN, pane.getFont().getSize() + 1)); //NOI18N } }
protected AboutUIBuilder addTab0(String tabTitle, String tabContent, boolean html) { JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); JTabbedPane tabs = ui.getTabs(); tabs.addTab(tabTitle, scrollPane); final JEditorPane jEditorPane = new JEditorPane(); jEditorPane.setBorder(null); if (html) { // must be done before set in text jEditorPane.setContentType("text/html"); } jEditorPane.setText(tabContent); jEditorPane.setEditable(false); jEditorPane.setFont(jEditorPane.getFont().deriveFont((float) 11)); jEditorPane.addHyperlinkListener(SwingUtil::openLink); scrollPane.getViewport().add(jEditorPane); SwingUtilities.invokeLater(() -> jEditorPane.setCaretPosition(0)); return this; }
private void addPreviewPane(JDialog dialog) { String content = getText(); try { FormulaUtils.evalIfScript(getNode(), content); } catch (ExecuteScriptException e) { final StringWriter out = new StringWriter(); try(PrintWriter writer = new PrintWriter(out)) { e.printStackTrace(writer); } final JTextArea exceptionView = new JTextArea(out.toString()); exceptionView.setBackground(Color.LIGHT_GRAY); exceptionView.setForeground(Color.RED.darker()); final Font font = textEditor.getFont(); exceptionView.setFont(font.deriveFont(font.getSize2D() * 0.8f)); exceptionView.setEditable(false); final JScrollPane scrollPane = new JScrollPane(exceptionView, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); final Rectangle availableScreenBounds = UITools.getAvailableScreenBounds(UITools.getCurrentRootComponent()); final Dimension maximumSize = new Dimension(availableScreenBounds.width * 3 / 4, Integer.MAX_VALUE); final Dimension preferredSize = scrollPane.getPreferredSize(); preferredSize.width = Math.min(preferredSize.width, maximumSize.width); scrollPane.setPreferredSize(preferredSize); final Box resisablePreview = Direction.RIGHT.createBox(scrollPane); dialog.add(resisablePreview, BorderLayout.EAST); } }
pane.add(titleLabel); Font f = errorMessage.getFont(); if (f != null) { errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
pane.add(titleLabel); Font f = errorMessage.getFont(); if (f != null) { errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
pane.add(titleLabel); Font f = errorMessage.getFont(); if (f != null) { errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
pane.add(titleLabel); Font f = errorMessage.getFont(); if (f != null) { errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
pane.add(titleLabel); Font f = errorMessage.getFont(); if (f != null) { errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
@Override public void install(final JEditorPane editor) { this.editor = editor; setFont(editor.getFont()); // setMinimumDisplayDigits(3); editor.getDocument().addDocumentListener(this); editor.addCaretListener(this); editor.addPropertyChangeListener(this); JScrollPane sp = getScrollPane(editor); sp.setRowHeaderView(this); mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { GotoLineDialog.showForEditor(editor); } }; addMouseListener(mouseListener); status = Status.INSTALLING; }
@Override public void install(final JEditorPane editor) { this.editor = editor; setFont(editor.getFont()); // setMinimumDisplayDigits(3); Insets ein = editor.getInsets(); if (ein.top != 0 || ein.bottom != 0) { Insets curr = getInsets(); setBorder(BorderFactory.createEmptyBorder(ein.top, curr.left, ein.bottom, curr.right)); } editor.getDocument().addDocumentListener(this); editor.addCaretListener(this); editor.addPropertyChangeListener(this); JScrollPane sp = getScrollPane(editor); if (sp != null) sp.setRowHeaderView(this); mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { GotoLineDialog.showForEditor(editor); } }; addMouseListener(mouseListener); setPreferredWidth(false); // required for toggle-lines to correctly repaint status = Status.INSTALLING; }