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

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

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

JComboBox.getBackground介绍

暂无

代码示例

代码示例来源:origin: leMaik/swing-material

@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
  g.setColor(comboBox.getBackground());
  g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
}

代码示例来源:origin: org.japura/japura-gui

@Override
public Color getBackground() {
 return getComboBox().getBackground();
}

代码示例来源:origin: com.github.insubstantial/substance

/**
 * Creates combo popup for the specified combobox.
 * 
 * @param combo
 *            Combobox.
 */
public SubstanceComboPopup(JComboBox combo) {
  super(combo);
  // fix for defect 154
  this.setOpaque(true);
  this.list.setBackground(combo.getBackground());
}

代码示例来源:origin: org.java.net.substance/substance

/**
 * Creates combo popup for the specified combobox.
 * 
 * @param combo
 *            Combobox.
 */
public SubstanceComboPopup(JComboBox combo) {
  super(combo);
  // fix for defect 154
  this.setOpaque(true);
  this.list.setBackground(combo.getBackground());
}

代码示例来源:origin: google/sagetv

private boolean isEditableSolid(int i)
{
 switch (editables[i].type)
 {
  case EDIT_FILE:
  case EDIT_IMAGE_FILE:
  case EDIT_COLOR:
  case EDIT_FLOAT_RANGE:
  case EDIT_INT_RANGE:
   return ((EditableResult) editableComps[i]).isSolid();
  case EDIT_CHECK:
   return "true".equals(((javax.swing.JCheckBox) editableComps[i]).getClientProperty("solid"));
  case EDIT_CHOICE:
   return ((javax.swing.JComboBox) editableComps[i]).getBackground() == java.awt.Color.white;
  case EDIT_ENUM:
   return ((javax.swing.JComboBox) editableComps[i]).getBackground() == java.awt.Color.white;
  default:
   return ((javax.swing.JTextField) editableComps[i]).getBackground() == java.awt.Color.white;
 }
}
private String getEditableResult(int i)

代码示例来源:origin: com.github.insubstantial/substance

@Override
protected void configureEditor() {
  super.configureEditor();
  // This for Mustang - setting Substance once again adds a border on
  // the text field in the combo editor.
  if (this.editor instanceof JComponent) {
    Insets ins = SubstanceSizeUtils
        .getComboTextBorderInsets(SubstanceSizeUtils
            .getComponentFontSize(this.editor));
    ((JComponent) this.editor).setBorder(new EmptyBorder(ins.top,
        ins.left, ins.bottom, ins.right));
    this.editor.setBackground(this.comboBox.getBackground());
    // ((JComponent) this.editor).setBorder(new LineBorder(Color.red));
  }
}

代码示例来源:origin: org.java.net.substance/substance

@Override
protected void configureEditor() {
  super.configureEditor();
  // This for Mustang - setting Substance once again adds a border on
  // the text field in the combo editor.
  if (this.editor instanceof JComponent) {
    Insets ins = SubstanceSizeUtils
        .getComboTextBorderInsets(SubstanceSizeUtils
            .getComponentFontSize(this.editor));
    ((JComponent) this.editor).setBorder(new EmptyBorder(ins.top,
        ins.left, ins.bottom, ins.right));
    this.editor.setBackground(this.comboBox.getBackground());
    // ((JComponent) this.editor).setBorder(new LineBorder(Color.red));
  }
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public void setEnabled(boolean enabled) {
  super.setEnabled(enabled);
  // Set the background and foreground to the combobox colors.
  if (enabled) {
    setBackground(comboBox.getBackground());
    setForeground(comboBox.getForeground());
  } else {
    setBackground(UIManager.getColor("ComboBox.disabledBackground"));
    setForeground(UIManager.getColor("ComboBox.disabledForeground"));
  }
}

代码示例来源:origin: leMaik/swing-material

public Popup(JComboBox combo) {
  super(combo);
  setBackground(combo.getBackground());
  setOpaque(true);
  setBorderPainted(false);
}

代码示例来源:origin: org.java.net.substance/substance

if (comboBox.isEditable()) {
  comboBox.getEditor().getEditorComponent().setBackground(
      comboBox.getBackground());
  popup.getList().setBackground(comboBox.getBackground());

代码示例来源:origin: com.github.insubstantial/substance

if (comboBox.isEditable()) {
  comboBox.getEditor().getEditorComponent().setBackground(
      comboBox.getBackground());
  popup.getList().setBackground(comboBox.getBackground());

代码示例来源:origin: CallForSanity/Gaalop

errorTextArea.setBackground(getBackground());
add(errorTextArea);
defaultColor = generator.getBackground();

代码示例来源:origin: com.github.arnabk/pgslookandfeel

if (comboBox.isEnabled()) {
  c.setForeground(comboBox.getForeground());
  c.setBackground(comboBox.getBackground());
} else {
  c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));

代码示例来源:origin: com.synaptix/SynaptixTattoo

/**
 * Configures the list which is used to hold the combo box items in the
 * popup. This method is called when the UI class is created.
 * 
 * @see #createList
 */
protected void configureList() {
  list.setFont(comboBox.getFont());
  list.setForeground(comboBox.getForeground());
  list.setBackground(comboBox.getBackground());
  list.setSelectionForeground(UIManager
      .getColor("ComboBox.selectionForeground"));
  list.setSelectionBackground(UIManager
      .getColor("ComboBox.selectionBackground"));
  list.setBorder(null);
  list.setCellRenderer(comboBox.getRenderer());
  list.setFocusable(false);
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  setListSelection(comboBox.getSelectedIndex());
  installListListeners();
}

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

public void focusGained(FocusEvent e) {
  if (comboBox != null) {
    orgBorder = comboBox.getBorder();
    orgBackgroundColor = comboBox.getBackground();
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof AbstractLookAndFeel) {
      if (orgBorder instanceof UIResource) {
        Border focusBorder = ((AbstractLookAndFeel)laf).getBorderFactory().getFocusFrameBorder();
        comboBox.setBorder(focusBorder);
      }
      Color backgroundColor = AbstractLookAndFeel.getTheme().getFocusBackgroundColor();
      comboBox.setBackground(backgroundColor);
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

c.setBackground(comboBox.getBackground());

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) {
  ListCellRenderer renderer = comboBox.getRenderer();
  //Fix for an obscure condition when renderer may be null -
  //can't figure how this can happen unless the combo box is
  //painted before installUI() has completed (which is called
  //by the superclass constructor calling updateUI().  Only
  //happens when opening an individual Properties window.  Maybe
  //the window is constructed off the AWT thread?
  if ((listBox == null) || (renderer == null)) {
    return;
  }
  Component c;
  c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
  c.setFont(comboBox.getFont());
  c.setForeground(comboBox.isEnabled() ? comboBox.getForeground() : PropUtils.getDisabledForeground());
  c.setBackground(comboBox.getBackground());
  boolean shouldValidate = false;
  if (c instanceof JPanel) {
    shouldValidate = true;
  }
  currentValuePane.paintComponent(
    g, c, comboBox, bounds.x, bounds.y, bounds.width, bounds.height, shouldValidate
  );
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public void paintCurrentValue(Graphics g, Rectangle bounds,boolean hasFocus) {
  ListCellRenderer renderer = comboBox.getRenderer();
  //Fix for an obscure condition when renderer may be null -
  //can't figure how this can happen unless the combo box is
  //painted before installUI() has completed (which is called
  //by the superclass constructor calling updateUI().  Only
  //happens when opening an individual Properties window.  Maybe
  //the window is constructed off the AWT thread?
  if ((listBox == null) || (renderer == null)) {
    return;
  }
  Component c;
  c = renderer.getListCellRendererComponent( listBox,
                          comboBox.getSelectedItem(),
                          -1,
                          false,
                          false );
  c.setFont(comboBox.getFont());
  c.setForeground(comboBox.isEnabled() ? comboBox.getForeground() : 
    PropUtils.getDisabledForeground());
    
  c.setBackground(comboBox.getBackground());
  boolean shouldValidate = false;
  if (c instanceof JPanel)  {
    shouldValidate = true;
  }
  currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
                  bounds.width,bounds.height, shouldValidate);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void paintCurrentValue(Graphics g, Rectangle bounds,boolean hasFocus) {
  ListCellRenderer renderer = comboBox.getRenderer();
  //Fix for an obscure condition when renderer may be null -
  //can't figure how this can happen unless the combo box is
  //painted before installUI() has completed (which is called
  //by the superclass constructor calling updateUI().  Only
  //happens when opening an individual Properties window.  Maybe
  //the window is constructed off the AWT thread?
  if ((listBox == null) || (renderer == null)) {
    return;
  }
  Component c;
  c = renderer.getListCellRendererComponent( listBox,
                          comboBox.getSelectedItem(),
                          -1,
                          false,
                          false );
  c.setFont(comboBox.getFont());
  c.setForeground(comboBox.isEnabled() ? comboBox.getForeground() : 
    PropUtils.getDisabledForeground());
    
  c.setBackground(comboBox.getBackground());
  boolean shouldValidate = false;
  if (c instanceof JPanel)  {
    shouldValidate = true;
  }
  currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
                  bounds.width,bounds.height, shouldValidate);
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

c.setBackground( comboBox.getBackground());

相关文章

JComboBox类方法