本文整理汇总了Java中com.sun.java.swing.plaf.windows.WindowsComboBoxUI.WindowsComboBoxEditor类的典型用法代码示例。如果您正苦于以下问题:Java WindowsComboBoxEditor类的具体用法?Java WindowsComboBoxEditor怎么用?Java WindowsComboBoxEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WindowsComboBoxEditor类属于com.sun.java.swing.plaf.windows.WindowsComboBoxUI包,在下文中一共展示了WindowsComboBoxEditor类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI.WindowsComboBoxEditor; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
UIManager.LookAndFeelInfo[] array = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo info : array) {
UIManager.setLookAndFeel(info.getClassName());
System.err.println("L&F: " + info.getName());
invokeAndWait(new Runnable() {
@Override
public void run() {
combo = new JComboBox<>(ITEMS);
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent event) {
if (ItemEvent.SELECTED == event.getStateChange() && combo.isEditable()) {
ComboBoxEditor editor = combo.getEditor();
Object component = editor.getEditorComponent();
if (component instanceof JTextField) {
JTextField text = (JTextField) component;
boolean selected = null != text.getSelectedText();
StringBuilder sb = new StringBuilder();
sb.append(" - ").append(combo.getSelectedIndex());
sb.append(": ").append(event.getItem());
if (selected) {
sb.append("; selected");
}
System.err.println(sb);
if ((editor instanceof WindowsComboBoxEditor) == (null == text.getSelectedText())) {
throw new Error("unexpected state of text selection");
}
}
}
}
});
JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(combo);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
});
for (int i = 0; i < ITEMS.length; ++i) {
select(i, true);
select(1, false);
}
invokeAndWait(new Runnable() {
@Override
public void run() {
windowForComponent(combo).dispose();
}
});
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:54,代码来源:Test8015300.java
注:本文中的com.sun.java.swing.plaf.windows.WindowsComboBoxUI.WindowsComboBoxEditor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论