本文整理了Java中javax.swing.JScrollPane.getFont()
方法的一些代码示例,展示了JScrollPane.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JScrollPane.getFont()
方法的具体详情如下:
包路径:javax.swing.JScrollPane
类名称:JScrollPane
方法名:getFont
暂无
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction(jsDoc = FONT_JSDOC)
@Override
public Font getFont() {
return super.getFont();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-notifications
private void updateTableColumnSizes() {
ETable table = notificationTable;
Font font = notificationScroll.getFont();
FontMetrics fm = notificationScroll.getFontMetrics(font.deriveFont(Font.BOLD));
int maxCharWidth = fm.charWidth('A'); // NOI18N
int inset = 10;
TableColumnModel columnModel = table.getColumnModel();
TableColumn priorityColumn = columnModel.getColumn(0);
String priorName = priorityColumn.getHeaderValue().toString();
priorityColumn.setPreferredWidth(fm.stringWidth(priorName) + inset);
TableColumn dateColumn = columnModel.getColumn(2);
dateColumn.setPreferredWidth(15 * maxCharWidth + inset);
TableColumn categoryColumn = columnModel.getColumn(3);
categoryColumn.setPreferredWidth(7 * maxCharWidth + inset);
TableColumn messageColumn = columnModel.getColumn(1);
Border border = notificationScroll.getBorder();
Insets insets;
if (border != null) {
insets = border.getBorderInsets(notificationScroll);
} else {
insets = new Insets(0, 0, 0, 0);
}
int remainingWidth = notificationScroll.getParent().getWidth() - insets.left - insets.right;
remainingWidth -= 3 * columnModel.getColumnMargin();
remainingWidth -= priorityColumn.getPreferredWidth();
remainingWidth -= dateColumn.getPreferredWidth();
remainingWidth -= categoryColumn.getPreferredWidth();
messageColumn.setPreferredWidth(remainingWidth);
}
代码示例来源:origin: org.scijava/scijava-ui-swing
private synchronized void initGui() {
setLayout(new MigLayout("inset 0", "[grow,fill]", "[grow,fill,align top]"));
textPane = new JTextPane();
textPane.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
textPane.setEditable(false);
doc = textPane.getStyledDocument();
stdoutLocal = createStyle("stdoutLocal", null, Color.black, null, null);
stderrLocal = createStyle("stderrLocal", null, Color.red, null, null);
stdoutGlobal = createStyle("stdoutGlobal", stdoutLocal, null, null, true);
stderrGlobal = createStyle("stderrGlobal", stderrLocal, null, null, true);
// NB: We wrap the JTextPane in a JPanel to disable
// the text pane's intelligent line wrapping behavior.
// I.e.: we want console lines _not_ to wrap, but instead
// for the scroll pane to show a horizontal scroll bar.
// Thanks to: https://tips4java.wordpress.com/2009/01/25/no-wrap-text-pane/
final JPanel textPanel = new JPanel();
textPanel.setLayout(new BorderLayout());
textPanel.add(textPane);
scrollPane = new JScrollPane(textPanel);
scrollPane.setPreferredSize(new Dimension(600, 600));
// Make the scroll bars move at a reasonable pace.
final FontMetrics fm = scrollPane.getFontMetrics(scrollPane.getFont());
final int charWidth = fm.charWidth('a');
final int lineHeight = fm.getHeight();
scrollPane.getHorizontalScrollBar().setUnitIncrement(charWidth);
scrollPane.getVerticalScrollBar().setUnitIncrement(2 * lineHeight);
add(scrollPane);
}
// -- Helper methods --
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
private Dimension getScrollPanePreferredSize(){
Font scrollPaneFont = listScrollPane.getFont();
Graphics gr = listScrollPane.getGraphics();
if (scrollPaneFont != null && gr != null){
FontMetrics fm = gr.getFontMetrics(scrollPaneFont);
if (fm!=null){
return new Dimension(fm.stringWidth("o")*60, fm.getHeight()*12); // NOI18N
}
}
return listScrollPane.getPreferredSize();
}
代码示例来源:origin: cytoscape/application
FontMetrics fm = box.getFontMetrics(scrollPane.getFont());
w = (int)fm.stringWidth(wsp.getWidest());
h = (int)scrollPane.getMinimumSize().getHeight();
内容来源于网络,如有侵权,请联系作者删除!