*
* @return The left panel with comboboxes.
*/
private JPanel getLeftComboPanel() {
FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", "");
DefaultFormBuilder builder = new DefaultFormBuilder(lm,
new ScrollablePanel());
builder.setDefaultDialogBorder();
builder.appendSeparator("Simple combos");
JComboBox comboRegular = new JComboBox(new Object[] { "entry1",
"entry2", "entry3", "entry4", "entry5", "entry6" });
comboRegular.setToolTipText("This is my combo 1");
comboRegular.setMaximumRowCount(4);
// class MyLabel extends JLabel {
// public MyLabel(String text) {
// super("text");
// }
//
// @Override
// protected void paintComponent(Graphics g) {
// g.setColor(Color.red);
// g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
// super.paintComponent(g);
// }
// }
builder.append("Regular", comboRegular);
// builder.append(new MyLabel("Regular"), new JButton("sample"));
JComboBox comboDisabled = new JComboBox(new Object[] { "entry1",
"entry2", "entry3" });
comboDisabled.setEnabled(false);
builder.append(new JLabel("Disabled"), comboDisabled);
JComboBox comboColored = new JComboBox(new Object[] { "entry31",
"entry32", "entry33", "entry34", "entry35", "entry36", "aaa",
"abb", "abc" });
comboColored.setName("Colored combo");
comboColored.setBackground(new Color(255, 128, 128));
comboColored.setForeground(new Color(0, 0, 128));
builder.append("Pink background", comboColored);
JComboBox comboEditable = new JComboBox(new Object[] { "Ester",
"Jordi", "Jordina", "Jorge", "Sergi" });
comboEditable.setEditable(true);
builder.append("Editable", comboEditable);
JComboBox comboColors = new FlexiComboBox<Color>(new Color(255, 128,
128), new Color(128, 255, 128), new Color(128, 128, 255),
new Color(255, 255, 128), new Color(255, 128, 255), new Color(
128, 255, 255)) {
@Override
public String getCaption(Color item) {
return item.getRed() + ":" + item.getGreen() + ":"
+ item.getBlue();
}
@Override
public Color getItemColor(Color item) {
return item;
}
};
comboColors.setName("Colors combo");
builder.append("Colors", comboColors);
JComboBox comboFlat = new JComboBox(new Object[] { "entry1", "entry2",
"entry3", "entry4", "entry5", "entry6" });
comboFlat.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY,
Boolean.TRUE);
builder.append("Flat", comboFlat);
JComboBox comboDefaultCoreRenderer = new JComboBox(new Object[] {
"entry1", "entry2", "entry3", "entry4", "entry5", "entry6" });
comboDefaultCoreRenderer.setRenderer(new DefaultListCellRenderer());
builder.append("Default core renderer", comboDefaultCoreRenderer);
builder.appendSeparator("Miscellaneous");
JComboBox colorCombo = new ColorComboBox();
builder.append("Color chooser", colorCombo);
JComboBox comboHebrew = new JComboBox(new Object[] {
"\u05e8\u05d0\u05e9\u05d9 1", "\u05e8\u05d0\u05e9\u05d9 2",
"\u05e8\u05d0\u05e9\u05d9 3", "\u05e8\u05d0\u05e9\u05d9 4",
"\u05e8\u05d0\u05e9\u05d9 5", "\u05e8\u05d0\u05e9\u05d9 6",
"\u05e8\u05d0\u05e9\u05d9 7", "\u05e8\u05d0\u05e9\u05d9 8",
"\u05e8\u05d0\u05e9\u05d9 9" });
comboHebrew.setToolTipText("RTL combo");
comboHebrew.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
comboHebrew.setMaximumRowCount(6);
builder.append("RTL (Hebrew)", comboHebrew);
try {
final Icon israelFlag = new ImageIcon(ImageIO.read(getClass()
.getResource("/test/check/icons/flag_israel.png")));
JComboBox comboHebrewCustomRenderer = new FlexiComboBox<String>(
"\u05e8\u05d0\u05e9\u05d9 1", "\u05e8\u05d0\u05e9\u05d9 2",
"\u05e8\u05d0\u05e9\u05d9 3", "\u05e8\u05d0\u05e9\u05d9 4",
"\u05e8\u05d0\u05e9\u05d9 5", "\u05e8\u05d0\u05e9\u05d9 6",
"\u05e8\u05d0\u05e9\u05d9 7", "\u05e8\u05d0\u05e9\u05d9 8",
"\u05e8\u05d0\u05e9\u05d9 9") {
@Override
public String getCaption(String item) {
return item;
}
@Override
public Icon getItemIcon(String item) {
return israelFlag;
}
};
comboHebrewCustomRenderer.setToolTipText("RTL combo");
comboHebrewCustomRenderer
.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
comboHebrewCustomRenderer.setMaximumRowCount(6);
builder.append("RTL (Hebrew) with icon", comboHebrewCustomRenderer);
} catch (IOException ioe) {
}
JComboBox comboHebrewEditable = new JComboBox(new Object[] {
"\u05e8\u05d0\u05e9\u05d9 1", "\u05e8\u05d0\u05e9\u05d9 2",
"\u05e8\u05d0\u05e9\u05d9 3", "\u05e8\u05d0\u05e9\u05d9 4",
"\u05e8\u05d0\u05e9\u05d9 5", "\u05e8\u05d0\u05e9\u05d9 6",
"\u05e8\u05d0\u05e9\u05d9 7", "\u05e8\u05d0\u05e9\u05d9 8",
"\u05e8\u05d0\u05e9\u05d9 9" });
comboHebrewEditable.setToolTipText("RTL combo");
comboHebrewEditable
.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
comboHebrewEditable.setMaximumRowCount(6);
comboHebrewEditable.setEditable(true);
builder.append("RTL (Hebrew) editable", comboHebrewEditable);
final JComboBox combo151 = new JComboBox();
final ComboBoxTextEditor151 editor = new ComboBoxTextEditor151();
combo151.setEditor(editor);
combo151.addItem(new EditableDocument151());
combo151.addItem("Default");
combo151.addItem("No Sound");
combo151.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
editor.setCaretPosition(0);
if (combo151.getSelectedItem() instanceof String) {
combo151.setEditable(false);
} else {
combo151.setEditable(true);
}
editor.setCaretPosition(0);
}
});
builder.append("Defect 151", combo151);
return builder.getPanel();
}