private void initComboBox(JComboBox combo) { if (combo.getUI() instanceof WindowsComboBoxUI) { combo.setUI(new RightPopupWindowsComboBoxUI()); } else { combo.setUI(new RightPopupBasicComboBoxUI()); } combo.addPopupMenuListener(new RightPopupMenuListener()); }
/** 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(); }