private void initComboBox(JComboBox combo) { if (combo.getUI() instanceof WindowsComboBoxUI) { combo.setUI(new RightPopupWindowsComboBoxUI()); } else { combo.setUI(new RightPopupBasicComboBoxUI()); } combo.addPopupMenuListener(new RightPopupMenuListener()); }
public void refreshSupplier(boolean remove) { if (remove) panel.remove(supplierCombo); try { model = new DefaultComboBoxModel( Manager.getInstance().getSupplierManager().getSuppliers().toArray()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } supplierCombo = new JComboBox(model); supplierCombo.setUI(ColorArrowUI.createUI(this)); supplierCombo.setEditable(true); supplierComboField = (JTextField) supplierCombo.getEditor().getEditorComponent(); supplierComboField.setText(""); supplierComboField.setOpaque(false); supplierComboField.setBorder(BorderFactory.createEmptyBorder()); supplierComboField.addKeyListener(new ComboKeyHandler(supplierCombo)); supplierCombo.setFont(new Font("Arial Narrow", Font.PLAIN, 14)); supplierCombo.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK)); supplierCombo.setOpaque(false); supplierCombo.setSelectedIndex(-1); supplierCombo.setVisible(supplierLabel.isVisible()); supplierCombo.setBounds(85, 56, 220, 20); panel.add(supplierCombo); }
private static void createAndShowGUI() { // the combo box (add/modify items if you like to) JComboBox<String> comboBox = new JComboBox<String>(new String[] {"Ester", "Jordi", "Jordina", "Jorge", "Sergi"}); comboBox.setUI( new BasicComboBoxUI() { protected JButton createArrowButton() { return new JButton() { private static final long serialVersionUID = 1L; public int getWidth() { return 0; } }; } }); // has to be editable comboBox.setEditable(true); // change the editor's document new AutoComboBox(comboBox); // create and show a window containing the combo box JFrame frame = new JFrame(); frame.setDefaultCloseOperation(3); frame.getContentPane().add(comboBox); frame.pack(); frame.setVisible(true); frame.setLocationRelativeTo(null); }
private void initJComboBox(JComboBox jcb) { jcb.setSize(120, 20); jcb.setOpaque(false); jcb.setFocusable(false); jcb.setRenderer(new StarComboBoxRender()); jcb.setUI((ComboBoxUI) StarComboBoxUI.createUI(jcb)); jcb.setBorder(new RoundBorder(Color.red)); add(jcb); }
/** Creates new form gui */ public gui() { super(new BorderLayout()); initComponents(); // Load user list and images images = new ImageIcon[userStrings.length]; Integer[] intArray = new Integer[userStrings.length]; for (int i = 0; i < userStrings.length; i++) { intArray[i] = new Integer(i); images[i] = createImageIcon("images/" + userStrings[i] + ".png"); if (images[i] != null) { images[i].setDescription(userStrings[i]); } } users = new JComboBox(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); users.setUI(new MetalComboBoxUI()); // ComboBoxRenderer renderer = new ComboBoxRenderer(); ComboBoxRenderer renderer = new ComboBoxRenderer(userStrings, images); renderer.setPreferredSize(new Dimension(650, 150)); users.setRenderer(renderer); users.setSize(renderer.getPreferredSize()); users.setMaximumRowCount(4); users.setBounds(150, 250, 650, 200); add(users); // setBorder(BorderFactory.createEmptyBorder(20,20,20,20)); // Set the user satisfaction labels jSlider1.setPaintTicks(true); Hashtable labelTable = new Hashtable(); for (int i = 0; i < labels.length; i++) { labelTable.put(new Integer(i), new JLabel(labels[i])); } jSlider1.setLabelTable(labelTable); jSlider1.setPaintLabels(true); socket = new generalSocket(machine, 1099); statusThread thread = new statusThread(socket, jLabel4); Thread theThread = new Thread(thread); theThread.start(); }
public DGSelectRenderer() { list = new JComboBox<DGSelect>(DGSelect.values()); IntelComboBoxUI ui = new IntelComboBoxUI() { /* * (non-Javadoc) * * @see * com.intel.stl.ui.common.view.IntelComboBoxUI#getValueString(java * .lang.Object) */ @Override protected String getValueString(Object value) { DGSelect sel = (DGSelect) value; return sel.getName(); } }; list.setUI(ui); }
public JPanel Panel() throws IOException { new ImageGet(); Image bgp = ImageGet.getImageByState("adduser"); background = new ImageIcon(bgp); p1.setBounds(0, 0, 988, 756); final MTextfield t1 = new MTextfield(); final MTextfield t2 = new MTextfield(); final MTextfield t3 = new MTextfield(); Color text = new Color(0, 0, 0); final String[] jobs = {"营业厅业务员", "快递员", "中转中心业务员", "中转中心库存管理人员", "总经理", "财务人员", "管理员"}; final JComboBox job = new JComboBox(jobs); job.setOpaque(false); job.setUI( new BasicComboBoxUI() { public void installUI(JComponent job) { super.installUI(job); // listBox.setBackground(); listBox.setSelectionForeground(Color.BLACK); } protected JButton createArrowButton() { return super.createArrowButton(); } }); t1.setOpaque(false); t2.setOpaque(false); t3.setOpaque(false); t1.setBorder(BorderFactory.createEmptyBorder()); t2.setBorder(BorderFactory.createEmptyBorder()); t3.setBorder(BorderFactory.createEmptyBorder()); JButton b5 = new JButton(); b5.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { boolean idisempty = t1.getText().equals(""); boolean nameisempty = t2.getText().equals(""); boolean passwordisempty = t3.getText().equals(""); boolean isempty = idisempty || nameisempty || passwordisempty; if (!isempty) { UserInfoPO user = new UserInfoPO( t1.getText(), t3.getText(), t2.getText(), job.getSelectedItem().toString()); // System.out.println(t1.getText()); // System.out.println(t3.getText()); // System.out.println(t2.getText()); // System.out.println(job.getSelectedItem().toString()); UserBl userbl = new UserBl(oos, ois); if (userbl.AddUser(user)) Mdialog.showMessageDialog("新建成功!"); else Mdialog.showMessageDialog("抱歉,新建失败!"); } else Mdialog.showMessageDialog("新建失败,请确认信息填写完整!"); } }); p1.setOpaque(false); p1.setLayout(null); p1.add(t1); p1.add(t2); p1.add(t3); p1.add(job); p1.add(b5); int length = 174, width = 43; t1.setBounds(194, 319, length, width); t1.settextFont(); t2.setBounds(194, 409, length, width); t2.settextFont(); t3.setBounds(600, 319, length, width); t3.settextFont(); job.setBounds(600, 409, length, width); b5.setContentAreaFilled(false); b5.setBorder(BorderFactory.createEmptyBorder()); b5.setBounds(582, 606, 200, 54); return p1; }