当前位置: 首页>>代码示例>>Java>>正文


Java BasicComboBoxUI类代码示例

本文整理汇总了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);
}
 
开发者ID:leMaik,项目名称:swing-material,代码行数:27,代码来源:MaterialComboBox.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:PersistenceDelegateTest.java

示例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();
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:22,代码来源:JComboBoxFixture.java

示例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;
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:17,代码来源:PlayTextField.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:FixedComboBoxEditor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:UIUtil.java

示例7: createLayoutManager

import javax.swing.plaf.basic.BasicComboBoxUI; //导入依赖的package包/类
protected LayoutManager createLayoutManager()
{
	return new BasicComboBoxUI.ComboBoxLayoutManager()
	{
		public void layoutContainer(Container parent)
		{
			layout(parent);
		}
	};
}
 
开发者ID:andy-goryachev,项目名称:PasswordSafe,代码行数:11,代码来源:AgComboBoxUI.java

示例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;
    }
 
开发者ID:aterai,项目名称:java-swing-tips,代码行数:28,代码来源:MainPanel.java

示例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;
    }
 
开发者ID:aterai,项目名称:java-swing-tips,代码行数:28,代码来源:MainPanel.java

示例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;
        }
    });
}
 
开发者ID:aterai,项目名称:java-swing-tips,代码行数:14,代码来源:MainPanel.java

示例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;
}
 
开发者ID:JetBrains,项目名称:jediterm,代码行数:10,代码来源:UIUtil.java

示例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));
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:45,代码来源:GdxSetupUI.java

示例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;
}
 
开发者ID:aterai,项目名称:java-swing-tips,代码行数:45,代码来源:MainPanel.java


注:本文中的javax.swing.plaf.basic.BasicComboBoxUI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。