本文整理了Java中javax.swing.JEditorPane.getFont()
方法的一些代码示例,展示了JEditorPane.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getFont()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getFont
暂无
代码示例来源:origin: bobbylight/RSyntaxTextArea
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);
代码示例来源:origin: dcaoyuan/nbscala
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)));
代码示例来源:origin: com.googlecode.jannocessor/jannocessor-ui
protected void decrease() {
logger.info("Decreasing font size");
input.setFont(new Font("Courier New", Font.BOLD, Math.max(input.getFont().getSize() - 1, 8)));
editor.setFont(new Font("Courier New", Font.BOLD, Math.max(editor.getFont().getSize() - 1, 8)));
}
代码示例来源:origin: org.codehaus.sonar.sslr/sslr-toolkit
@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);
}
}
}
代码示例来源:origin: com.googlecode.jannocessor/jannocessor-ui
protected void increase() {
logger.info("Increasing font size");
input.setFont(new Font("Courier New", Font.BOLD, input.getFont().getSize() + 1));
editor.setFont(new Font("Courier New", Font.BOLD, editor.getFont().getSize() + 1));
}
代码示例来源:origin: SonarSource/sslr
@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);
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-text
/** 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
}
}
代码示例来源:origin: org.sonarsource.sslr/sslr-toolkit
@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);
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** 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
}
}
代码示例来源:origin: org.codehaus.sonar.sslr/sslr-devkit
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);
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** 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
}
}
代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-about
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;
}
代码示例来源:origin: freeplane/freeplane
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);
}
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
pane.add(titleLabel);
Font f = errorMessage.getFont();
if (f != null) {
errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
pane.add(titleLabel);
Font f = errorMessage.getFont();
if (f != null) {
errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
pane.add(titleLabel);
Font f = errorMessage.getFont();
if (f != null) {
errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
代码示例来源:origin: org.swinglabs.swingx/swingx-all
pane.add(titleLabel);
Font f = errorMessage.getFont();
if (f != null) {
errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
pane.add(titleLabel);
Font f = errorMessage.getFont();
if (f != null) {
errorMessage.setFont(f.deriveFont(f.getSize() - 2f));
代码示例来源:origin: de.sciss/jsyntaxpane
@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;
}
代码示例来源:origin: de.sciss/syntaxpane
@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;
}
内容来源于网络,如有侵权,请联系作者删除!