本文整理匯總了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));
}