本文整理汇总了Java中com.sun.java.swing.plaf.windows.WindowsComboBoxUI类的典型用法代码示例。如果您正苦于以下问题:Java WindowsComboBoxUI类的具体用法?Java WindowsComboBoxUI怎么用?Java WindowsComboBoxUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WindowsComboBoxUI类属于com.sun.java.swing.plaf.windows包,在下文中一共展示了WindowsComboBoxUI类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUI
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI; //导入依赖的package包/类
@Override
public void updateUI() {
ComboBoxUI cui = (ComboBoxUI) UIManager.getUI(this);
if (cui instanceof MetalComboBoxUI) {
cui = new MetalTreeComboBoxUI();
} else if (cui instanceof MotifComboBoxUI) {
cui = new MotifTreeComboBoxUI();
} else if (cui instanceof WindowsComboBoxUI) {
cui = new WindowsTreeComboBoxUI();
}
setUI(cui);
}
示例2: initComboBox
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI; //导入依赖的package包/类
private void initComboBox(JComboBox<?> combo) {
if (combo.getUI() instanceof WindowsComboBoxUI) {
combo.setUI(new RightPopupWindowsComboBoxUI());
} else {
combo.setUI(new RightPopupBasicComboBoxUI());
}
combo.addPopupMenuListener(new RightPopupMenuListener());
}
示例3: MainPanel
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI; //导入依赖的package包/类
private MainPanel() {
super(new BorderLayout());
// Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
// @Override public void eventDispatched(AWTEvent event) {
// if (event instanceof MouseWheelEvent) {
// Object source = event.getSource();
// if (source instanceof JScrollPane) {
// System.out.println("JScrollPane");
// return;
// }
// ((MouseWheelEvent) event).consume();
// }
// }
// }, AWTEvent.MOUSE_WHEEL_EVENT_MASK);
JComboBox<String> combo1 = makeComboBox(5);
if (combo1.getUI() instanceof WindowsComboBoxUI) {
combo1.setUI(new WindowsComboBoxUI() {
@Override protected ComboPopup createPopup() {
return new BasicComboPopup2(comboBox);
}
});
} else {
combo1.setUI(new BasicComboBoxUI() {
@Override protected ComboPopup createPopup() {
return new BasicComboPopup2(comboBox);
}
});
}
JComboBox<String> combo2 = makeComboBox(20);
if (combo2.getUI() instanceof WindowsComboBoxUI) {
combo2.setUI(new WindowsComboBoxUI() {
@Override protected ComboPopup createPopup() {
return new BasicComboPopup3(comboBox);
}
});
} else {
combo2.setUI(new BasicComboBoxUI() {
@Override protected ComboPopup createPopup() {
return new BasicComboPopup3(comboBox);
}
});
}
Box box = Box.createVerticalBox();
box.add(makeTitledPanel("default:", makeComboBox(5)));
box.add(Box.createVerticalStrut(5));
box.add(makeTitledPanel("default:", makeComboBox(20)));
box.add(Box.createVerticalStrut(5));
box.add(makeTitledPanel("disable right click in drop-down list:", combo1));
box.add(Box.createVerticalStrut(5));
box.add(makeTitledPanel("disable right click and scroll in drop-down list:", combo2));
box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
add(box, BorderLayout.NORTH);
setPreferredSize(new Dimension(320, 240));
}