javax.swing.text.JTextComponent.getBackground()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中javax.swing.text.JTextComponent.getBackground()方法的一些代码示例,展示了JTextComponent.getBackground()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getBackground()方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getBackground

JTextComponent.getBackground介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

public void paint(Graphics g) {
  if (isVisible()) {
    try {
      JTextComponent component = getComponent();
      Rectangle r = component.getUI().modelToView(component, getDot());
      Color c = g.getColor();
      g.setColor(component.getBackground());
      g.setXORMode(component.getCaretColor());
      r.setBounds(r.x, r.y,
          g.getFontMetrics().charWidth('w'),
          g.getFontMetrics().getHeight());
      g.fillRect(r.x, r.y, r.width, r.height);
      g.setPaintMode();
      g.setColor(c);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
  }
}

代码示例来源: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: ron190/jsql-injection

g.setXORMode(comp.getBackground());

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial

private Color backgroundColor() {
  if (textComponent != null) {
    return textComponent.getBackground();
  }
  return backgroundColor;
}

代码示例来源:origin: pentaho/pentaho-reporting

public TextComponentEditHandler( final Class type, final String keyName, final JTextComponent textComponent,
  final ParameterUpdateContext updateContext, final Format formatter ) {
 this.type = type;
 this.keyName = keyName;
 this.textComponent = textComponent;
 this.updateContext = updateContext;
 this.formatter = formatter;
 this.color = this.textComponent.getBackground();
 if ( color == null ) {
  color = SystemColor.text;
 }
}

代码示例来源:origin: pentaho/pentaho-reporting

public TextComponentEditHandler( final JTextComponent textComponent ) {
 this.textComponent = textComponent;
 this.color = this.textComponent.getBackground();
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

protected void initComponentDefaults() {
  this.errorColor = ValidatorDialog.WARNING_COLOR;
  this.defaultBGColor = textComponent.getBackground();
  this.defaultToolTip = textComponent.getToolTipText();
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

/**
 * Get the background color of the <code>textComponent</code>, when no
 * text is present. If no color has been set, the <code>textComponent</code>s
 * background color color will be returned.
 * 
 * @param textComponent
 * @return the the background color of the text component, when no text is
 *         present
 */
public static Color getBackground(JTextComponent textComponent) {
  if (textComponent.getClientProperty(BACKGROUND) == null) {
    return textComponent.getBackground();
  }
  return (Color) textComponent.getClientProperty(BACKGROUND);
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

/**
 * Get the background color of the <code>textComponent</code>, when no
 * text is present. If no color has been set, the <code>textComponent</code>s
 * background color color will be returned.
 * 
 * @param textComponent
 * @return the the background color of the text component, when no text is
 *         present
 */
public static Color getBackground(JTextComponent textComponent) {
  if (textComponent.getClientProperty(BACKGROUND) == null) {
    return textComponent.getBackground();
  }
  return (Color) textComponent.getClientProperty(BACKGROUND);
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * Get the background color of the <code>textComponent</code>, when no
 * text is present. If no color has been set, the <code>textComponent</code>s
 * background color color will be returned.
 * 
 * @param textComponent
 * @return the the background color of the text component, when no text is
 *         present
 */
public static Color getBackground(JTextComponent textComponent) {
  if (textComponent.getClientProperty(BACKGROUND) == null) {
    return textComponent.getBackground();
  }
  return (Color) textComponent.getClientProperty(BACKGROUND);
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Get the background color of the <code>textComponent</code>, when no
 * text is present. If no color has been set, the <code>textComponent</code>s
 * background color color will be returned.
 * 
 * @param textComponent
 * @return the the background color of the text component, when no text is
 *         present
 */
public static Color getBackground(JTextComponent textComponent) {
  if (textComponent.getClientProperty(BACKGROUND) == null) {
    return textComponent.getBackground();
  }
  return (Color) textComponent.getClientProperty(BACKGROUND);
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

public void undoUnderline( Highlighter.Highlight highlight, JTextComponent editor )
{
 paintUnderline( editor.getGraphics(), highlight.getStartOffset(), highlight.getEndOffset(), editor, editor.getBackground() );
}

代码示例来源:origin: com.eas.platypus/platypus-js-scalable-widget

protected void clearEditingTexts() {
  Iterator<JTextComponent> lit = editingTexts.iterator();
  if (lit != null) {
    while (lit.hasNext()) {
      JTextComponent ltc = lit.next();
      ltc.putClientProperty(TEXT_COMPS_EDITABLE, ltc.isEditable());
      ltc.putClientProperty(TEXT_COMPS_BACKGROUND, ltc.getBackground());
      ltc.putClientProperty(TEXT_COMPS_HINT, ltc.getToolTipText());
      ltc.setEditable(false);
      ltc.setBackground(Color.lightGray);
      ltc.setToolTipText(localizations.getString("Click2Edit"));
      if (ltc.getCaret() != null) {
        ltc.getCaret().setVisible(false);
      }
    }
  }
  editingTexts.clear();
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintBackground(Graphics g) {
  g.setColor(getComponent().getBackground());
  if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
    Boolean doShow = (Boolean) getComponent().getClientProperty("doShowFocusFrame");
    if (doShow == null || doShow.booleanValue()) {
      if (getComponent().hasFocus() && getComponent().isEditable()) {
        g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
      }
    }
  }
  g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintBackground(Graphics g) {
  g.setColor(getComponent().getBackground());
  if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
    if (getComponent().hasFocus() && getComponent().isEditable()) {
      g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
    }
  }
  g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintBackground(Graphics g) {
  g.setColor(getComponent().getBackground());
  if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
    if (getComponent().hasFocus() && getComponent().isEditable()) {
      g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
    }
  }
  g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintBackground(Graphics g) {
  g.setColor(getComponent().getBackground());
  if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
    if (getComponent().hasFocus() && getComponent().isEditable()) {
      g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
    }
  }
  g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintBackground(Graphics g) {
  g.setColor(getComponent().getBackground());
  if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
    if (getComponent().hasFocus() && getComponent().isEditable()) {
      g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
    }
  }
  g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}

代码示例来源:origin: com.jtattoo/JTattoo

private void updateBackground() {
    JTextComponent c = getComponent();
    if (c.getBackground() instanceof UIResource) {
      if (!c.isEnabled() || !c.isEditable()) {
        c.setBackground(AbstractLookAndFeel.getDisabledBackgroundColor());
      } else {
        c.setBackground(AbstractLookAndFeel.getInputBackgroundColor());
      }
    }
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

private void updateBackground() {
    JTextComponent c = getComponent();
    if (c.getBackground() instanceof UIResource) {
      if (!c.isEnabled() || !c.isEditable()) {
        c.setBackground(AbstractLookAndFeel.getDisabledBackgroundColor());
      } else {
        c.setBackground(AbstractLookAndFeel.getInputBackgroundColor());
      }
    }
  }
}

相关文章

JTextComponent类方法