List of utility methods to do JComboBox
String | getEOL(JComboBox eolCombo) get EOL switch (eolCombo.getSelectedIndex()) { case 0: return "\n"; case 1: return "\r"; case 2: return "\r\n"; return "\n"; |
String | getJComboBoxString(JComboBox comboBox) get J Combo Box String String result = ""; Object obj = comboBox.getSelectedItem(); if (obj != null) { result = obj.toString(); } else { JTextField jtf = getJComboBoxJTextField(comboBox); if (jtf != null) { result = jtf.getText(); ... |
int | getMaxWidth(final JComboBox get Max Width int maxLen = 0; for (int i = 0; i < combo.getItemCount(); i++) { String str = combo.getItemAt(i); int wi = fm.stringWidth(str); if (wi > maxLen) { maxLen = wi; return maxLen + 20; |
JComboBox> | getOnlyComboBox(Container owner) get Only Combo Box return getOnlyComboBox(owner, false);
|
JComboBox | getPrinterJComboBox() get Printer J Combo Box JComboBox<String> box = new JComboBox<>(); PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); for (PrintService printService : services) { box.addItem(printService.getName()); box.setSelectedItem(getDefaultPrinterName()); return box; |
int | getScrollBarWidth(JComboBox comboBox, JScrollPane scrollPane) get Scroll Bar Width int scrollBarWidth = 0; if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) { JScrollBar vertical = scrollPane.getVerticalScrollBar(); scrollBarWidth = vertical.getPreferredSize().width; return scrollBarWidth; |
void | initCombo(JComboBox combo) Fail safe combo init combo.setSelectedIndex((combo.getItemCount() == 0) ? -1 : 0);
return;
|
void | inputComboBox(JComboBox input Combo Box for (int i = 0; i < str.length; i++) { cbx.addItem(str[i]); |
boolean | isCbEquals(JComboBox cb, String str) is Cb Equals if (cb.getSelectedIndex() == -1) { if (str.equals("")) { return (true); } else { if (str.equals("")) { return (false); if (cb.getSelectedItem().equals(str)) { return (true); return (false); |
boolean | isComboBoxButton(AbstractButton button) Checks and answers if the specified button is in a combo box. Container parent = button.getParent(); return (parent != null) && ((parent instanceof JComboBox) || (parent.getParent() instanceof JComboBox)); |