本文整理了Java中javax.swing.text.JTextComponent.getFont()
方法的一些代码示例,展示了JTextComponent.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getFont()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getFont
暂无
代码示例来源:origin: groovy/groovy-core
protected synchronized void damage(Rectangle r) {
if (r != null) {
JTextComponent component = getComponent();
x = r.x;
y = r.y;
Font font = component.getFont();
width = component.getFontMetrics(font).charWidth('w');
height = r.height;
repaint();
}
}
}
代码示例来源:origin: wiztools/rest-client
@Override
public Font getEditorFont() {
return se_response.getEditorComponent().getFont();
}
代码示例来源:origin: SonarSource/sonarqube
FontMetrics fontMetrics = component.getFontMetrics(component.getFont());
Insets insets = getInsets();
int availableWidth = getSize().width - insets.left - insets.right;
代码示例来源:origin: wiztools/rest-client
@Override
public Font getEditorFont() {
return se_req_body.getEditorComponent().getFont();
}
代码示例来源:origin: omegat-org/omegat
@Override
protected void paint(Graphics g, Rectangle rect, JTextComponent c) {
g.setColor(color);
FontMetrics fm = c.getFontMetrics(c.getFont());
int baseline = rect.y + rect.height - fm.getDescent() + 1;
g.drawLine(rect.x, baseline, rect.x + rect.width, baseline);
}
}
代码示例来源:origin: SonarSource/sonarqube
/**
* Create a line number component for a text component.
*
* @param component the related text component
* @param minimumDisplayDigits the number of digits used to calculate
* the minimum width of the component
*/
public TextLineNumber(JTextComponent component, int minimumDisplayDigits) {
this.component = component;
setFont(component.getFont());
setBorderGap(5);
setCurrentLineForeground(Color.RED);
setDigitAlignment(RIGHT);
setMinimumDisplayDigits(minimumDisplayDigits);
component.getDocument().addDocumentListener(this);
component.addCaretListener(this);
component.addPropertyChangeListener("font", this);
}
代码示例来源:origin: omegat-org/omegat
protected void paint(Graphics g, Rectangle rect, JTextComponent c) {
Font f = c.getFont();
FontMetrics fm = c.getFontMetrics(f);
int y = rect.y - 1 + fm.getAscent();
g.setFont(f);
g.setColor(color);
g.drawString(symbol, rect.x, y);
}
}
代码示例来源:origin: ron190/jsql-injection
default void drawPlaceholder(JTextComponent textComponent, Graphics g, String placeholderText) {
int w = textComponent.getWidth();
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
Insets ins = textComponent.getInsets();
FontMetrics fm = g.getFontMetrics();
int c0 = textComponent.getBackground().getRGB();
int c1 = textComponent.getForeground().getRGB();
int m = 0xfefefefe;
int c2 = ((c0 & m) >>> 1) + ((c1 & m) >>> 1);
g.setColor(new Color(c2, true));
g.setFont(textComponent.getFont().deriveFont(Font.ITALIC));
g.drawString(
placeholderText,
textComponent.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT
? w - (fm.stringWidth(placeholderText) + ins.left + 2)
: ins.left + 2,
fm.getAscent() + 2
);
}
代码示例来源:origin: omegat-org/omegat
@Override
protected void paint(Graphics g, Rectangle rect, JTextComponent c) {
g.setColor(color);
FontMetrics fm = c.getFontMetrics(c.getFont());
int baseline = rect.y + rect.height - fm.getDescent() + 1;
g.drawLine(rect.x, baseline, rect.x + rect.width, baseline);
g.drawLine(rect.x, baseline + 1, rect.x + rect.width, baseline + 1);
}
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
g.setFont(font!=null ? font : textComponent.getFont());
代码示例来源:origin: org.codehaus.groovy/groovy-console
protected synchronized void damage(Rectangle r) {
if (r != null) {
JTextComponent component = getComponent();
x = r.x;
y = r.y;
Font font = component.getFont();
width = component.getFontMetrics(font).charWidth('w');
height = r.height;
repaint();
}
}
}
代码示例来源:origin: omegat-org/omegat
public FontFallbackListener(final JTextComponent comp) {
defaultFont = comp.getFont();
comp.addPropertyChangeListener("font", evt -> {
if (evt.getNewValue() != null && !evt.getNewValue().equals(evt.getOldValue())) {
defaultFont = (Font) evt.getNewValue();
Document doc = comp.getDocument();
doStyling(doc, 0, doc.getLength());
}
});
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation
void mouseClicked(JTextComponent c, Point p) {
Point position = new Point(p);
position.y += c.getFontMetrics(c.getFont()).getHeight();
SwingUtilities.convertPointToScreen(position, c);
performGoToAction(position);
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
private void updateCursor( MouseEvent e )
{
//noinspection deprecation
FontMetrics fm = getToolkit().getFontMetrics( _editor.getFont() );
int iLineHeight = fm.getHeight();
if( _lineInfoMgr != null )
{
setCursor( _lineInfoMgr.getCursor( (e.getY() - 2) / iLineHeight + 1 ) );
}
}
}
代码示例来源:origin: org.kohsuke.droovy/groovy
protected synchronized void damage(Rectangle r) {
if (r != null) {
JTextComponent component = getComponent();
x = r.x;
y = r.y;
Font font = component.getFont();
width = component.getFontMetrics(font).charWidth('w');
height = r.height;
repaint();
}
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
private void updateCursor( MouseEvent e )
{
//noinspection deprecation
FontMetrics fm = getToolkit().getFontMetrics( _editor.getFont() );
int iLineHeight = fm.getHeight();
if( _lineInfoMgr != null )
{
setCursor( _lineInfoMgr.getCursor( (e.getY() - 2) / iLineHeight + 1 ) );
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
protected synchronized void damage(Rectangle r) {
if (r != null) {
JTextComponent component = getComponent();
x = r.x;
y = r.y;
Font font = component.getFont();
width = component.getFontMetrics(font).charWidth('w');
height = r.height;
repaint();
}
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
@Override
public Dimension getPreferredSize()
{
Dimension dim = new Dimension();
dim.height = _editor.getHeight();
FontMetrics fm = _editor.getFontMetrics( _editor.getFont() );
dim.width = fm.stringWidth( String.valueOf( dim.height / fm.getHeight() + 1 ) );
dim.width = Math.max( dim.width, GosuEditor.MIN_LINENUMBER_WIDTH );
dim.width += getLineInfoRequiredWidth();
return dim;
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
protected synchronized void damage(Rectangle r) {
if (r != null) {
JTextComponent component = getComponent();
x = r.x;
y = r.y;
Font font = component.getFont();
width = component.getFontMetrics(font).charWidth('w');
height = r.height;
repaint();
}
}
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
protected synchronized void damage(Rectangle r) {
if (r != null) {
JTextComponent component = getComponent();
x = r.x;
y = r.y;
Font font = component.getFont();
width = component.getFontMetrics(font).charWidth('w');
height = r.height;
repaint();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!