本文整理了Java中javax.swing.JTextPane.getFont()
方法的一些代码示例,展示了JTextPane.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.getFont()
方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:getFont
暂无
代码示例来源:origin: libgdx/libgdx
int size = sampleTextPane.getFont().getSize();
if (size < 14) size = 14;
sampleTextPane.setFont(unicodeFont.getFont().deriveFont((float)size));
代码示例来源:origin: net.sf.squirrel-sql.plugins/graph
private void recalculateDDLFrameSize(JInternalFrame ddlFrame, JTextPane txtDDL, String[] lines)
{
FontMetrics fm = txtDDL.getFontMetrics(txtDDL.getFont());
int txtHeight = fm.getHeight() * lines.length;
int txtWidht = 0;
for (int i = 0; i < lines.length; i++)
{
txtWidht = Math.max(txtWidht, fm.stringWidth(lines[i]));
}
BasicInternalFrameUI ui = (BasicInternalFrameUI) ddlFrame.getUI();
int titleHeight = ui.getNorthPane().getHeight();
ddlFrame.setSize(txtWidht + 20, txtHeight + titleHeight + 20);
}
代码示例来源:origin: libgdx/libgdx
int size = sampleTextPane.getFont().getSize();
if (size < 14) size = 14;
sampleTextPane.setFont(unicodeFont.getFont().deriveFont((float)size));
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
/**
* Returns the width, in pixels
*/
private int lineNumberWidth(JTextPane textPane) {
int lineCount = getEtalon();
setLineNumberWidth(textPane.getFontMetrics(textPane.getFont())
.stringWidth(lineCount + " "));
return getLineNumberWidth();
}
代码示例来源:origin: marytts/marytts
/** Creates new form SpeakerWindow */
public SpeakerWindow() {
initComponents(); // Auto-generated in NetBeans
defaultPromptFont = jTextPane_PromptDisplay.getFont();
// Set icon image in upper left corner to the 16 x 16 pixel image
this.setIconImage(Toolkit.getDefaultToolkit().getImage(IconSet.LOGO_16x16_URL));
}
代码示例来源:origin: stackoverflow.com
/**
* Return an int containing the wrapped line index at the given position
* @param component JTextPane
* @param int pos
* @return int
*/
public int getLineNumber(JTextPane component, int pos)
{
int posLine;
int y = 0;
try
{
Rectangle caretCoords = component.modelToView(pos);
y = (int) caretCoords.getY();
}
catch (BadLocationException ex)
{
}
int lineHeight = component.getFontMetrics(component.getFont()).getHeight();
posLine = (y / lineHeight) + 1;
return posLine;
}
代码示例来源:origin: marytts/marytts
/**
* Further initialization of components on startup (These can be edited in NetBeans, initComponents() cannot)
*/
private void initMoreComponents() {
// Center window in the user's screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
setLocation(new Point((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2));
// Set application icon in title bar left-hand corner
this.setIconImage(Toolkit.getDefaultToolkit().getImage(IconSet.LOGO_16x16_URL));
// Change status icon in Admin window
jLabel_SessionStatus.setIcon(IconSet.STOP_48X48);
defaultPromptFont = jTextPane_PromptDisplay.getFont();
speakerWin.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
jCheckBoxMenuItem_SpeakerWindow.setSelected(false);
}
});
optionsDialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
speakerWin.showOrHidePromptCount();
}
});
}
代码示例来源:origin: RaiMan/SikuliX2
jtp.setFont(new Font(Font.DIALOG, Font.PLAIN, 14));
if (!header.isEmpty()) {
aText = String.format(header, jtp.getFont().getFamily()) + aText;
代码示例来源:origin: org.orbisgis/orbisgis-view
public void resetFont() {
final Font currFont = textPane.getFont();
textPane.setFont(new Font(Font.MONOSPACED, currFont.getStyle(), currFont.getSize()));
}
代码示例来源:origin: stackoverflow.com
JTextPane pane = new JTextPane();
Font font = pane.getFont();
pane.setContentType("text/html");
pane.setText("<html><font face=\"" + font.getFamily() + "\" size=\"" + font.getSize() + "\"></font>This is some text!</html>");
代码示例来源:origin: orbisgis/orbisgis
public void resetFont() {
final Font currFont = textPane.getFont();
textPane.setFont(new Font(Font.MONOSPACED, currFont.getStyle(), currFont.getSize()));
}
代码示例来源:origin: org.gdl-lang.gdl-tools/openehr-utils-gui-swing
private JPanel getPanelMsg() {
if (panelMsg == null) {
panelMsg = new JPanel(new BorderLayout());
JPanel aux = new JPanel();
aux.add(new JLabel(getImageIcon()));
panelMsg.add(aux, BorderLayout.WEST);
JTextPane textPane = new JTextPane();
textPane.setText(msg);
textPane.setFont(textPane.getFont().deriveFont(Font.BOLD));
textPane.setBackground(null);
textPane.setEditable(false);
panelMsg.add(textPane, BorderLayout.CENTER);
}
return panelMsg;
}
代码示例来源:origin: omegat-org/omegat
@Override
public Component getDetailComponent() {
IssueDetailSplitPanel panel = new IssueDetailSplitPanel();
panel.firstTextPane.setText(sourceEntry.getSrcText());
panel.lastTextPane.setText(targetEntry.translation);
panel.setMinimumSize(new Dimension(0, panel.firstTextPane.getFont().getSize() * 6));
return panel;
}
}
代码示例来源:origin: com.davidbracewell/hermes-core
private void savePreferences() {
properties.setProperty("font_size", Integer.toString(editorPane.getFont().getSize()));
try {
propertiesFile.getParent().mkdirs();
properties.storeToXML(propertiesFile.outputStream(), "");
} catch (IOException e1) {
e1.printStackTrace();
}
}
代码示例来源:origin: com.davidbracewell/hermes-core
@Override
public void keyReleased(KeyEvent e) {
if (e.isControlDown() && e.getKeyChar() == '+') {
Font font = editorPane.getFont();
if (font.getSize() < 24) {
Font f2 = new Font(font.getName(), font.getStyle(), font.getSize() + 2);
editorPane.setFont(f2);
StyleConstants.setFontSize(editorPane.getStyle(StyleContext.DEFAULT_STYLE), f2.getSize());
}
} else if (e.isControlDown() && e.getKeyChar() == '-') {
Font font = editorPane.getFont();
if (font.getSize() > 12) {
Font f2 = new Font(font.getName(), font.getStyle(), font.getSize() - 2);
editorPane.setFont(f2);
}
}
savePreferences();
lines.setFont(new Font(Font.MONOSPACED, Font.PLAIN, editorPane.getFont().getSize()));
super.keyPressed(e);
}
});
代码示例来源:origin: RPTools/maptool
public void handleAppEvent(AppEvent event) {
commandTextArea.setFont(commandTextArea.getFont().deriveFont((float) AppPreferences.getFontSize()));
doLayout();
}
});
代码示例来源:origin: omegat-org/omegat
@Override
public Component getDetailComponent() {
IssueDetailSplitPanel panel = new IssueDetailSplitPanel();
panel.firstTextPane.setText(ste.getSrcText());
panel.lastTextPane.setText(targetText);
StyledDocument doc = panel.lastTextPane.getStyledDocument();
doc.setCharacterAttributes(result.start, result.end - result.start, ERROR_STYLE, false);
panel.setMinimumSize(new Dimension(0, panel.firstTextPane.getFont().getSize() * 6));
return panel;
}
代码示例来源:origin: omegat-org/omegat
@Override
public Component getDetailComponent() {
IssueDetailSplitPanel panel = new IssueDetailSplitPanel();
panel.firstTextPane.setText(ste.getSrcText());
panel.lastTextPane.setText(tmxEntry.translation);
StyledDocument doc = panel.lastTextPane.getStyledDocument();
for (Token tok : misspelledTokens) {
doc.setCharacterAttributes(tok.getOffset(), tok.getLength(), ERROR_STYLE, false);
}
panel.setMinimumSize(new Dimension(0, panel.firstTextPane.getFont().getSize() * 6));
return panel;
}
代码示例来源:origin: omegat-org/omegat
private Component getSplitPanel() {
IssueDetailSplitPanel splitPanel = new IssueDetailSplitPanel();
splitPanel.firstTextPane.setText(ste.getSrcText());
splitPanel.lastTextPane.setText(tmxEntry.translation);
StyledDocument doc = splitPanel.firstTextPane.getStyledDocument();
for (Token[] toks : Core.getGlossaryManager().searchSourceMatchTokens(ste, glossaryEntry)) {
for (Token tok : toks) {
doc.setCharacterAttributes(tok.getOffset(), tok.getLength(), ERROR_STYLE, false);
}
}
splitPanel.setMinimumSize(new Dimension(0, splitPanel.firstTextPane.getFont().getSize() * 6));
return splitPanel;
}
代码示例来源:origin: antlr/antlrworks
@SuppressWarnings("deprecation")
public static void createTabs(JTextPane textPane) {
int tabSize = AWPrefs.getEditorTabSize();
int charWidth = AWPrefs.getEditorFontSize();
try {
charWidth = Toolkit.getDefaultToolkit().getFontMetrics(textPane.getFont()).stringWidth("m");
} catch(Exception e) {
// ignore exception
}
TabStop[] tstops = new TabStop[100];
for(int i = 0; i<100; i++) {
tstops[i] = new TabStop(i*tabSize*charWidth);
}
TabSet tabs = new TabSet(tstops);
Style style = textPane.getLogicalStyle();
if(style != null) {
StyleConstants.setTabSet(style, tabs);
textPane.setLogicalStyle(style);
}
}
内容来源于网络,如有侵权,请联系作者删除!