本文整理匯總了Java中javax.swing.plaf.basic.BasicComboBoxUI類的典型用法代碼示例。如果您正苦於以下問題:Java BasicComboBoxUI類的具體用法?Java BasicComboBoxUI怎麽用?Java BasicComboBoxUI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BasicComboBoxUI類屬於javax.swing.plaf.basic包,在下文中一共展示了BasicComboBoxUI類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: MaterialComboBox
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
public MaterialComboBox() {
setModel(new DefaultComboBoxModel<T>());
setRenderer(new FieldRenderer<T>(this));
setUI(new BasicComboBoxUI() {
@Override
protected ComboPopup createPopup() {
BasicComboPopup popup = new Popup(comboBox);
popup.getAccessibleContext().setAccessibleParent(comboBox);
return popup;
}
@Override
protected JButton createArrowButton() {
JButton button = new javax.swing.plaf.basic.BasicArrowButton(
javax.swing.plaf.basic.BasicArrowButton.SOUTH,
MaterialColor.TRANSPARENT,
MaterialColor.TRANSPARENT,
MaterialColor.TRANSPARENT,
MaterialColor.TRANSPARENT);
button.setName("ComboBox.arrowButton");
return button;
}
});
setOpaque(false);
setBackground(MaterialColor.TRANSPARENT);
}
示例2: test_writeObject_javax_swing_DefaultListModel
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
public void test_writeObject_javax_swing_DefaultListModel() {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
byteArrayOutputStream));
DefaultListModel model = new DefaultListModel();
model.add(0, 1);
model.add(1, 2);
ListDataHandler listDataHandler = new BasicComboBoxUI().new ListDataHandler();
model.addListDataListener(listDataHandler);
encoder.writeObject(model);
encoder.close();
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
byteArrayOutputStream.toByteArray()));
XMLDecoder decoder = new XMLDecoder(stream);
DefaultListModel aModel = (DefaultListModel) decoder.readObject();
assertEquals(model.getSize(), aModel.getSize());
}
示例3: readText
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
public static String readText(final JComboBox cb, final int index) {
return new DoSwingR<String>() {
@Override
protected String doRun() {
Object value = cb.getItemAt(index);
try {
BasicComboBoxUI ui = (BasicComboBoxUI) cb.getUI();
Field popupField = ReflectionUtils.getField(ui.getClass(), "popup");
popupField.setAccessible(true);
ComboPopup popup = (ComboPopup) popupField.get(ui);
JList list = popup.getList();
ListCellRenderer renderer = list.getCellRenderer();
Component rendComp = renderer.getListCellRendererComponent(popup.getList(), value, index, false,
false);
return ComponentFixture.Common.readText(rendComp);
} catch (Exception ex) {
}
return value.toString();
}
}.result();
}
示例4: getListBox
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
JList getListBox() {
JList listBox;
try {
Field field = JComponent.class.getDeclaredField("ui");
field.setAccessible(true);
BasicComboBoxUI ui = (BasicComboBoxUI) field.get(comboBox);
field = BasicComboBoxUI.class.getDeclaredField("listBox");
field.setAccessible(true);
listBox = (JList) field.get(ui);
} catch (NoSuchFieldException nsfe) {
throw new RuntimeException(nsfe);
} catch (IllegalAccessException iae) {
throw new RuntimeException(iae);
}
return listBox;
}
示例5: getComboboxPopup
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
@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;
}
示例6: getComboBoxPopup
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
@Nullable
public static ComboPopup getComboBoxPopup(@NotNull JComboBox comboBox) {
final ComboBoxUI ui = comboBox.getUI();
if (ui instanceof BasicComboBoxUI) {
return ReflectionUtil.getField(BasicComboBoxUI.class, ui, ComboPopup.class, "popup");
}
return null;
}
示例7: createLayoutManager
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
protected LayoutManager createLayoutManager()
{
return new BasicComboBoxUI.ComboBoxLayoutManager()
{
public void layoutContainer(Container parent)
{
layout(parent);
}
};
}
示例8: makeComboBox
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
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.setBorder(BorderFactory.createEmptyBorder());
// ((JTextField) combo.getEditor().getEditorComponent()).setBorder(null);
// ((JTextField) combo.getEditor().getEditorComponent()).setMargin(null);
// combo.setBackground(Color.WHITE);
// combo.setOpaque(true);
// combo.setEditable(true);
return combo;
}
示例9: makeComboBox
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
private static <E> JComboBox<E> makeComboBox(ComboBoxModel<E> model) {
JComboBox<E> combo = new JComboBox<E>(model) {
@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.setBorder(BorderFactory.createEmptyBorder());
// ((JTextField) combo.getEditor().getEditorComponent()).setBorder(null);
// ((JTextField) combo.getEditor().getEditorComponent()).setMargin(null);
// combo.setBackground(Color.WHITE);
// combo.setOpaque(true);
// combo.setEditable(true);
return combo;
}
示例10: updateUI
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
@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;
}
});
}
示例11: getComboBoxPopup
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
@Nullable
public static ComboPopup getComboBoxPopup(@NotNull JComboBox comboBox) {
final ComboBoxUI ui = comboBox.getUI();
if (ui instanceof BasicComboBoxUI) {
return ReflectionUtil.getField(BasicComboBoxUI.class, ui, ComboPopup.class, "popup");
}
return null;
}
示例12: uiStyle
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
private void uiStyle() {
nameText.setCaretColor(Color.WHITE);
packageText.setCaretColor(Color.WHITE);
gameClassText.setCaretColor(Color.WHITE);
destinationText.setCaretColor(Color.WHITE);
sdkLocationText.setCaretColor(Color.WHITE);
nameLabel.setForeground(Color.WHITE);
packageLabel.setForeground(Color.WHITE);
gameClassLabel.setForeground(Color.WHITE);
destinationLabel.setForeground(Color.WHITE);
sdkLocationLabel.setForeground(Color.WHITE);
sdkLocationText.setDisabledTextColor(Color.BLACK);
versionLabel.setForeground(new Color(255, 20, 20));
UIManager.put("ComboBox.selectionBackground", new ColorUIResource(new Color(70, 70, 70)));
UIManager.put("ComboBox.selectionForeground", new ColorUIResource(Color.WHITE));
versionButton.updateUI();
versionButton.setForeground(new Color(255, 255, 255));
versionButton.setBackground(new Color(20, 20, 20));
versionButton.setPrototypeDisplayValue("I am a prototype");
versionButton.setUI(new BasicComboBoxUI() {
@Override
protected JButton createArrowButton () {
return new BasicArrowButton(
BasicArrowButton.SOUTH,
new Color(0, 0, 0),
new Color(0, 0, 0),
new Color(100, 100, 100),
new Color(100, 100, 100));
}
});
projectsLabel.setForeground(new Color(200, 20, 20));
extensionsLabel.setForeground(new Color(200, 20, 20));
subProjectsPanel.setOpaque(true);
subProjectsPanel.setBackground(new Color(46, 46, 46));
for (JPanel extensionPanel : extensionsPanels) {
extensionPanel.setOpaque(true);
extensionPanel.setBackground(new Color(46, 46, 46));
}
}
示例13: makePanel
import javax.swing.plaf.basic.BasicComboBoxUI; //導入依賴的package包/類
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() {
JButton button = new JButton(); //.createArrowButton();
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;
}