use of javax.swing.plaf.basic.BasicComboBoxUI in project android by JetBrains.
the class GradleEditorComboBoxEditor method getComboboxPopup.
@Nullable
private static ComboPopup getComboboxPopup(final JComboBox comboBox) {
final ComboBoxUI ui = comboBox.getUI();
ComboPopup popup = null;
if (ui instanceof BasicComboBoxUI) {
try {
final Field popupField = BasicComboBoxUI.class.getDeclaredField("popup");
popupField.setAccessible(true);
popup = (ComboPopup) popupField.get(ui);
} catch (NoSuchFieldException e1) {
popup = null;
} catch (IllegalAccessException e1) {
popup = null;
}
}
return popup;
}
use of javax.swing.plaf.basic.BasicComboBoxUI in project java-swing-tips by aterai.
the class ComboCellRenderer method makeComboBox.
private static JComboBox<String> makeComboBox() {
JComboBox<String> combo = new JComboBox<String>(new String[] { "Name 0", "Name 1", "Name 2" }) {
@Override
public void updateUI() {
super.updateUI();
setBorder(BorderFactory.createEmptyBorder());
setUI(new BasicComboBoxUI() {
@Override
protected JButton createArrowButton() {
JButton button = super.createArrowButton();
button.setContentAreaFilled(false);
button.setBorder(BorderFactory.createEmptyBorder());
return button;
}
});
// JTextField editor = (JTextField) getEditor().getEditorComponent();
// editor.setBorder(BorderFactory.createEmptyBorder());
// editor.setOpaque(true);
// editor.setEditable(false);
}
};
//combo.setEditable(true);
return combo;
}
use of javax.swing.plaf.basic.BasicComboBoxUI in project java-swing-tips by aterai.
the class ComboCellRenderer method updateUI.
@Override
public void updateUI() {
super.updateUI();
setBorder(BorderFactory.createEmptyBorder());
setUI(new BasicComboBoxUI() {
@Override
protected JButton createArrowButton() {
button = super.createArrowButton();
button.setContentAreaFilled(false);
//button.setBackground(ComboCellRenderer.this.getBackground());
button.setBorder(BorderFactory.createEmptyBorder());
return button;
}
});
}
use of javax.swing.plaf.basic.BasicComboBoxUI in project intellij-community by JetBrains.
the class FixedComboBoxEditor method getComboboxPopup.
@Nullable
private static ComboPopup getComboboxPopup(final JComboBox comboBox) {
final ComboBoxUI ui = comboBox.getUI();
ComboPopup popup = null;
if (ui instanceof BasicComboBoxUI) {
popup = ReflectionUtil.getField(BasicComboBoxUI.class, ui, ComboPopup.class, "popup");
}
return popup;
}
use of javax.swing.plaf.basic.BasicComboBoxUI in project java-swing-tips by aterai.
the class MainPanel method makePanel.
private static JPanel makePanel() {
final JPanel p = new JPanel(new BorderLayout(5, 5));
p.add(new JComboBox<>(new String[] { "aaaa", "bbbbbbbbbb", "ccccc" }));
String[] items = { "JComboBox 11111:", "JComboBox 222:", "JComboBox 33:" };
JComboBox<String> comboBox = new JComboBox<String>(items) {
@Override
public void updateUI() {
super.updateUI();
UIManager.put("ComboBox.squareButton", Boolean.FALSE);
UIManager.put("ComboBox.background", p.getBackground());
setUI(new BasicComboBoxUI() {
@Override
protected JButton createArrowButton() {
//.createArrowButton();
JButton button = new JButton();
button.setBorder(BorderFactory.createEmptyBorder());
button.setVisible(false);
return button;
}
});
final ListCellRenderer<? super String> r = getRenderer();
setRenderer(new ListCellRenderer<String>() {
private final Color bgc = UIManager.getColor("ComboBox.background");
@Override
public Component getListCellRendererComponent(JList<? extends String> list, String value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel c = (JLabel) r.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
c.setHorizontalAlignment(SwingConstants.RIGHT);
if (isSelected) {
c.setForeground(list.getSelectionForeground());
c.setBackground(list.getSelectionBackground());
} else {
c.setForeground(list.getForeground());
c.setBackground(bgc);
}
return c;
}
});
setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
//setBackground(p.getBackground());
setOpaque(false);
setFocusable(false);
}
};
p.add(comboBox, BorderLayout.WEST);
p.setBorder(BorderFactory.createTitledBorder("JComboBox+JComboBox"));
return p;
}
Aggregations