本文整理汇总了Java中javax.swing.plaf.metal.MetalComboBoxUI类的典型用法代码示例。如果您正苦于以下问题:Java MetalComboBoxUI类的具体用法?Java MetalComboBoxUI怎么用?Java MetalComboBoxUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetalComboBoxUI类属于javax.swing.plaf.metal包,在下文中一共展示了MetalComboBoxUI类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.swing.plaf.metal.MetalComboBoxUI; //导入依赖的package包/类
public static void main(String... args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
for (UIManager.LookAndFeelInfo lafInfo
: UIManager.getInstalledLookAndFeels()) {
try {
UIManager.setLookAndFeel(lafInfo.getClassName());
} catch (Exception e) {
throw new RuntimeException(e);
}
MetalComboBoxUI ui = new MetalComboBoxUI();
ui.installUI(new JComboBox());
ui.getBaseline(new JComboBox(), 0, 0);
ui.getBaseline(new JComboBox(), 1, 1);
ui.getBaseline(new JComboBox(), 2, 2);
ui.getBaseline(new JComboBox(), 3, 3);
ui.getBaseline(new JComboBox(), 4, 4);
}
}
});
}
示例2: main
import javax.swing.plaf.metal.MetalComboBoxUI; //导入依赖的package包/类
public static void main(String... args) throws Exception {
MetalComboBoxUI ui = new MetalComboBoxUI();
ui.installUI(new JComboBox());
ui.getBaseline(new JComboBox(), 0, 0);
ui.getBaseline(new JComboBox(), 1, 1);
ui.getBaseline(new JComboBox(), 2, 2);
ui.getBaseline(new JComboBox(), 3, 3);
ui.getBaseline(new JComboBox(), 4, 4);
}
示例3: updateUI
import javax.swing.plaf.metal.MetalComboBoxUI; //导入依赖的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);
}
示例4: ImageComboBox
import javax.swing.plaf.metal.MetalComboBoxUI; //导入依赖的package包/类
/**
* Create new image combo box
*
* @param parent
* newmodelwindow pare t
* @param imagesName
* names of the imates
* @param imagesText
* texts of the imates
*/
public ImageComboBox(NewModelWindow parent, String[] imagesName, String[] imagesText) {
super(new BorderLayout());
this.parent = parent;
// Load images
images = new ImageIcon[imagesName.length];
Integer[] intArray = new Integer[imagesName.length];
for (int i = 0; i < imagesName.length; i++) {
intArray[i] = new Integer(i);
images[i] = UIUtil.loadResourceIcon(imagesName[i]);
if (images[i] != null) {
images[i].setDescription(imagesText[i]);
}
}
// create JComboBox
list = new JComboBox<Integer>(intArray);
Color bg = (Color) UIManager.get("ComboBox.background");
Color fg = (Color) UIManager.get("ComboBox.foreground");
UIManager.put("ComboBox.selectionBackground", bg);
UIManager.put("ComboBox.selectionForeground", fg);
list.setUI(new MetalComboBoxUI());
list.setBackground(Color.WHITE);
ComboBoxRenderer renderer = new ComboBoxRenderer(images, imagesText);
renderer.setPreferredSize(new Dimension(200, 150));
list.setRenderer(renderer);
list.setMaximumRowCount(3);
list.addActionListener(this);
// Lay out the demo.
add(list, BorderLayout.PAGE_START);
setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}
示例5: setComboBoxProperties
import javax.swing.plaf.metal.MetalComboBoxUI; //导入依赖的package包/类
private static<T> void setComboBoxProperties(JComboBox<T> comboBox, ImageInfoReader imageInfoReader) {
comboBox.setOpaque(false);
comboBox.setBackground(ColorPalette.FOREGROUND_COLOR);
comboBox.setForeground(ColorPalette.FOREGROUND_COLOR);
comboBox.setFont(Fonts.FONT);
comboBox.setUI(new MetalComboBoxUI() {
@Override
protected ComboPopup createPopup() {
return new TiledImageComboPopup( comboBox, imageInfoReader );
}
});
}