FormLayout lmButtons = new FormLayout(
"right:pref, 10dlu, left:pref:grow(1), 4dlu,"
+ "left:pref:grow(1), 4dlu, left:pref:grow(1), "
+ "4dlu, left:pref:grow(1)", "");
lmButtons.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
DefaultFormBuilder builderButtons = new DefaultFormBuilder(lmButtons,
new ScrollablePanel());
builderButtons.setDefaultDialogBorder();
builderButtons.append("");
JLabel bLabel = new JLabel("Buttons");
bLabel.setIcon(Check.getIcon("JButtonColor16"));
JLabel tbLabel = new JLabel("Toggle buttons");
tbLabel.setIcon(Check.getIcon("JToggleButtonColor16"));
JLabel cbLabel = new JLabel("Check boxes");
cbLabel.setIcon(Check.getIcon("JCheckBoxColor16"));
JLabel rbLabel = new JLabel("Radio buttons");
rbLabel.setIcon(Check.getIcon("JRadioButtonColor16"));
builderButtons.append(bLabel, tbLabel);
builderButtons.append(cbLabel, rbLabel);
builderButtons.appendSeparator("Regular settings");
this.addButtonRow(builderButtons, "Enabled", null, null);
this.addButtonRow(builderButtons, "Flat", null,
new ClientPropertyCommand(SubstanceLookAndFeel.FLAT_PROPERTY,
Boolean.TRUE));
this.addButtonRow(builderButtons, "Disabled", null,
new DisableCommand());
this
.addButtonRow(builderButtons, "Selected", null,
new SelectCommand());
this.addButtonRow(builderButtons, "Disabled selected", null,
new ChainCommand<Component>(new DisableCommand(),
new SelectCommand()));
builderButtons.appendSeparator("Background settings");
this.addButtonRow(builderButtons, "Yellow", null,
new BackgroundColorCommand(Color.yellow));
this.addButtonRow(builderButtons, "Yellow flat", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.yellow), new ClientPropertyCommand(
SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE)));
this.addButtonRow(builderButtons, "Yellow disabled", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.yellow), new DisableCommand()));
this.addButtonRow(builderButtons, "Yellow selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.yellow), new SelectCommand()));
this.addButtonRow(builderButtons, "Yellow disabled selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.yellow), new SelectCommand(),
new DisableCommand()));
this.addButtonRow(builderButtons, "Red", null,
new BackgroundColorCommand(Color.red));
this.addButtonRow(builderButtons, "Red disabled", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.red), new DisableCommand()));
this.addButtonRow(builderButtons, "Red selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.red), new SelectCommand()));
this.addButtonRow(builderButtons, "Red disabled selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.red), new SelectCommand(), new DisableCommand()));
this.addButtonRow(builderButtons, "Green", null,
new BackgroundColorCommand(Color.green));
this.addButtonRow(builderButtons, "Green disabled", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.green), new DisableCommand()));
this.addButtonRow(builderButtons, "Green selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.green), new SelectCommand()));
this
.addButtonRow(builderButtons, "Green disabled selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.green), new SelectCommand(),
new DisableCommand()));
this.addButtonRow(builderButtons, "Dark Green", null,
new BackgroundColorCommand(Color.green.darker()));
this.addButtonRow(builderButtons, "Dark Green disabled", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.green.darker()), new DisableCommand()));
this.addButtonRow(builderButtons, "Dark Green selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.green.darker()), new SelectCommand()));
this.addButtonRow(builderButtons, "Dark Green disabled selected", null,
new ChainCommand<Component>(new BackgroundColorCommand(
Color.green.darker()), new SelectCommand(),
new DisableCommand()));
builderButtons.appendSeparator("Foreground settings");
this.addButtonRow(builderButtons, "Yellow", null,
new ForegroundColorCommand(Color.yellow));
this.addButtonRow(builderButtons, "Yellow disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.yellow), new DisableCommand()));
this.addButtonRow(builderButtons, "Yellow selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.yellow), new SelectCommand()));
this.addButtonRow(builderButtons, "Yellow disabled selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.yellow), new SelectCommand(),
new DisableCommand()));
this.addButtonRow(builderButtons, "Red", null,
new ForegroundColorCommand(Color.red));
this.addButtonRow(builderButtons, "Red disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.red), new DisableCommand()));
this.addButtonRow(builderButtons, "Red selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.red), new SelectCommand()));
this.addButtonRow(builderButtons, "Red disabled selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.red), new SelectCommand(), new DisableCommand()));
this.addButtonRow(builderButtons, "Green", null,
new ForegroundColorCommand(Color.green));
this.addButtonRow(builderButtons, "Green disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green), new DisableCommand()));
this.addButtonRow(builderButtons, "Green selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green), new SelectCommand()));
this
.addButtonRow(builderButtons, "Green disabled selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green), new SelectCommand(),
new DisableCommand()));
this.addButtonRow(builderButtons, "Dark Green", null,
new ForegroundColorCommand(Color.green.darker()));
this.addButtonRow(builderButtons, "Dark Green disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green.darker()), new DisableCommand()));
this.addButtonRow(builderButtons, "Dark Green selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green.darker()), new SelectCommand()));
this.addButtonRow(builderButtons, "Dark Green disabled selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green.darker()), new SelectCommand(),
new DisableCommand()));
builderButtons.appendSeparator("Combined settings");
this.addButtonRow(builderButtons, "Blue/yellow", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.blue), new BackgroundColorCommand(Color.yellow)));
this.addButtonRow(builderButtons, "Blue/yellow disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.blue), new BackgroundColorCommand(Color.yellow),
new DisableCommand()));
this.addButtonRow(builderButtons, "Blue/yellow selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.blue), new BackgroundColorCommand(Color.yellow),
new SelectCommand()));
this.addButtonRow(builderButtons, "Blue/yellow disabled selected",
null, new ChainCommand<Component>(new ForegroundColorCommand(
Color.blue), new BackgroundColorCommand(Color.yellow),
new SelectCommand(), new DisableCommand()));
this.addButtonRow(builderButtons, "Red/light green", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.red), new BackgroundColorCommand(Color.green
.brighter())));
this.addButtonRow(builderButtons, "Red/light green disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.red), new BackgroundColorCommand(Color.green
.brighter()), new DisableCommand()));
this.addButtonRow(builderButtons, "Red/light green selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.red), new BackgroundColorCommand(Color.green
.brighter()), new SelectCommand()));
this
.addButtonRow(builderButtons,
"Red/light green disabled selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.red), new BackgroundColorCommand(
Color.green.brighter()), new SelectCommand(),
new DisableCommand()));
this.addButtonRow(builderButtons, "Dark yellow/blue", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.yellow.darker()), new BackgroundColorCommand(
Color.blue)));
this.addButtonRow(builderButtons, "Dark yellow/blue disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.yellow.darker()), new BackgroundColorCommand(
Color.blue), new DisableCommand()));
this.addButtonRow(builderButtons, "Dark yellow/blue selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.yellow.darker()), new BackgroundColorCommand(
Color.blue), new SelectCommand()));
this
.addButtonRow(builderButtons,
"Dark yellow/blue disabled selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.yellow.darker()),
new BackgroundColorCommand(Color.blue),
new SelectCommand(), new DisableCommand()));
this.addButtonRow(builderButtons, "Dark green/magenta", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green.darker()), new BackgroundColorCommand(
Color.magenta)));
this.addButtonRow(builderButtons, "Dark green/magenta disabled", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green.darker()), new BackgroundColorCommand(
Color.magenta), new DisableCommand()));
this.addButtonRow(builderButtons, "Dark green/magenta selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green.darker()), new BackgroundColorCommand(
Color.magenta), new SelectCommand()));
this.addButtonRow(builderButtons,
"Dark green/magenta disabled selected", null,
new ChainCommand<Component>(new ForegroundColorCommand(
Color.green.darker()), new BackgroundColorCommand(
Color.magenta), new SelectCommand(),
new DisableCommand()));
JPanel panelButtons = builderButtons.getPanel();
JScrollPane jspButtons = new JScrollPane(panelButtons);
panelButtons.setOpaque(false);
jspButtons.setOpaque(false);
jspButtons.getViewport().setOpaque(false);
FormLayout lmOther = new FormLayout(
"right:pref, 10dlu, left:pref:grow(1), 4dlu,"
+ "left:pref:grow(1), 4dlu, left:pref:grow(1), "
+ "4dlu, left:pref:grow(1)", "");
lmOther.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
DefaultFormBuilder builderOther = new DefaultFormBuilder(lmOther,
new ScrollablePanel());
builderOther.setDefaultDialogBorder();
builderOther.append("");
builderOther.append(new JLabel("Yellow"), new JLabel(
"Blue + red foreground"));
builderOther.append(new JLabel("Green"), new JLabel("Dark green"));
builderOther.appendSeparator("Labels");
addControlRow(builderOther, "Regular",
new CreationCommand<Component>() {
public Component create() {
return new JLabel("label");
}
}, null);
addControlRow(builderOther, "Disabled",
new CreationCommand<Component>() {
public Component create() {
return new JLabel("label");
}
}, new DisableCommand());
addControlRow(builderOther, "HTML", new CreationCommand<Component>() {
public Component create() {
return new JLabel(
"<html>text <b>text</b> <font color='red'>text</font>");
}
}, null);
builderOther.appendSeparator("Sliders");
addControlRow(builderOther, "Regular",
new CreationCommand<Component>() {
public Component create() {
return new JSlider(0, 100, 50);
}
}, null);
addControlRow(builderOther, "Disabled",
new CreationCommand<Component>() {
public Component create() {
return new JSlider(0, 100, 50);
}
}, new DisableCommand());
builderOther.appendSeparator("Progress bars");
addControlRow(builderOther, "Regular",
new CreationCommand<Component>() {
public Component create() {
JProgressBar jpb = new JProgressBar(0, 100);
jpb.setIndeterminate(false);
jpb.setValue(50);
jpb.setStringPainted(true);
return jpb;
}
}, null);
addControlRow(builderOther, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JProgressBar jpb = new JProgressBar(0, 100);
jpb.setIndeterminate(false);
jpb.setValue(50);
jpb.setStringPainted(true);
return jpb;
}
}, new DisableCommand());
addControlRow(builderOther, "Custom foreground",
new CreationCommand<Component>() {
public Component create() {
JProgressBar jpb = new JProgressBar(0, 100);
jpb.setIndeterminate(false);
jpb.setValue(50);
jpb.setStringPainted(true);
return jpb;
}
}, new ForegroundColorCommand(Color.red));
addControlRow(builderOther, "Disabled with foreground",
new CreationCommand<Component>() {
public Component create() {
JProgressBar jpb = new JProgressBar(0, 100);
jpb.setIndeterminate(false);
jpb.setValue(50);
jpb.setStringPainted(true);
return jpb;
}
}, new ChainCommand<Component>(new DisableCommand(),
new ForegroundColorCommand(Color.red)));
addControlRow(builderOther, "Indeterminate",
new CreationCommand<Component>() {
public Component create() {
JProgressBar jpb = new JProgressBar(0, 100);
jpb.setIndeterminate(true);
return jpb;
}
}, null);
addControlRow(builderOther, "Indeterminate disabled",
new CreationCommand<Component>() {
public Component create() {
JProgressBar jpb = new JProgressBar(0, 100);
jpb.setIndeterminate(true);
return jpb;
}
}, new DisableCommand());
builderOther.appendSeparator("Combo boxes");
addControlRow(builderOther, "Regular",
new CreationCommand<Component>() {
public Component create() {
JComboBox jcb = new JComboBox(new Object[] { "Ester",
"Jordi", "Jordina", "Jorge", "Sergi" });
return jcb;
}
}, null);
addControlRow(builderOther, "Flat", new CreationCommand<Component>() {
public Component create() {
JComboBox jcb = new JComboBox(new Object[] { "Ester", "Jordi",
"Jordina", "Jorge", "Sergi" });
return jcb;
}
}, new ClientPropertyCommand(SubstanceLookAndFeel.FLAT_PROPERTY,
Boolean.TRUE));
addControlRow(builderOther, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JComboBox jcb = new JComboBox(new Object[] { "Ester",
"Jordi", "Jordina", "Jorge", "Sergi" });
return jcb;
}
}, new DisableCommand());
addControlRow(builderOther, "Editable",
new CreationCommand<Component>() {
public Component create() {
JComboBox jcb = new JComboBox(new Object[] { "Ester",
"Jordi", "Jordina", "Jorge", "Sergi" });
jcb.setEditable(true);
return jcb;
}
}, null);
addControlRow(builderOther, "Disabled editable",
new CreationCommand<Component>() {
public Component create() {
JComboBox jcb = new JComboBox(new Object[] { "Ester",
"Jordi", "Jordina", "Jorge", "Sergi" });
jcb.setEditable(true);
return jcb;
}
}, new DisableCommand());
CreationCommand<Component> spinnerCreationCmd = new CreationCommand<Component>() {
public Component create() {
JSpinner s = new JSpinner(new SpinnerListModel(new Object[] {
"sample0", "sample", "sample2" }));
s.getModel().setValue("sample");
return s;
}
};
builderOther.appendSeparator("Spinners");
addControlRow(builderOther, "Regular", spinnerCreationCmd, null);
addControlRow(builderOther, "Flat", spinnerCreationCmd,
new ClientPropertyCommand(SubstanceLookAndFeel.FLAT_PROPERTY,
Boolean.TRUE));
addControlRow(builderOther, "Disabled", spinnerCreationCmd,
new DisableCommand());
JPanel panelOther = builderOther.getPanel();
JScrollPane jspOther = new JScrollPane(panelOther);
panelOther.setOpaque(false);
jspOther.setOpaque(false);
jspOther.getViewport().setOpaque(false);
FormLayout lmText = new FormLayout(
"right:pref, 10dlu, left:pref:grow(1), 4dlu,"
+ "left:pref:grow(1), 4dlu, left:pref:grow(1), "
+ "4dlu, left:pref:grow(1)", "");
lmText.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
DefaultFormBuilder builderText = new DefaultFormBuilder(lmText,
new ScrollablePanel());
builderText.setDefaultDialogBorder();
builderText.append("");
builderText.append(new JLabel("Yellow"), new JLabel(
"Blue + red foreground"));
builderText.append(new JLabel("Green"), new JLabel("Dark green"));
builderText.appendSeparator("Text fields");
addControlRow(builderText, "Regular", new CreationCommand<Component>() {
public Component create() {
JTextField field = new JTextField("test", 15);
return field;
}
}, null);
addControlRow(builderText, "Watermark",
new CreationCommand<Component>() {
public Component create() {
JTextField field = new JTextField("test", 15);
return field;
}
}, new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderText, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JTextField field = new JTextField("test", 15);
return field;
}
}, new DisableCommand());
addControlRow(builderText, "Not editable",
new CreationCommand<Component>() {
public Component create() {
JTextField field = new JTextField("test", 15);
field.setEditable(false);
return field;
}
}, null);
builderText.appendSeparator("Formatted text fields");
addControlRow(builderText, "Regular", new CreationCommand<Component>() {
public Component create() {
JFormattedTextField field = new JFormattedTextField(
new DecimalFormat("#,##0.0000"));
field.setText("2,430.0000");
return field;
}
}, null);
addControlRow(builderText, "Watermark",
new CreationCommand<Component>() {
public Component create() {
JFormattedTextField field = new JFormattedTextField(
new DecimalFormat("#,##0.0000"));
field.setText("2,430.0000");
return field;
}
}, new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderText, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JFormattedTextField field = new JFormattedTextField(
new DecimalFormat("#,##0.0000"));
field.setText("2,430.0000");
return field;
}
}, new DisableCommand());
addControlRow(builderText, "Not editable",
new CreationCommand<Component>() {
public Component create() {
JFormattedTextField field = new JFormattedTextField(
new DecimalFormat("#,##0.0000"));
field.setText("2,430.0000");
field.setEditable(false);
return field;
}
}, null);
builderText.appendSeparator("Password fields");
addControlRow(builderText, "Regular", new CreationCommand<Component>() {
public Component create() {
JPasswordField field = new JPasswordField("password", 15);
return field;
}
}, null);
addControlRow(builderText, "Watermark",
new CreationCommand<Component>() {
public Component create() {
JPasswordField field = new JPasswordField("password",
15);
return field;
}
}, new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderText, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JPasswordField field = new JPasswordField("password",
15);
return field;
}
}, new DisableCommand());
addControlRow(builderText, "Not editable",
new CreationCommand<Component>() {
public Component create() {
JPasswordField field = new JPasswordField("password",
15);
field.setEditable(false);
return field;
}
}, null);
builderText.appendSeparator("Editor panes");
addControlRow(builderText, "Regular", new CreationCommand<Component>() {
public Component create() {
JEditorPane pane = new JEditorPane("text/html;",
"Sample <b>content</b><br> <u>text</u>");
return pane;
}
}, null);
addControlRow(builderText, "Watermark",
new CreationCommand<Component>() {
public Component create() {
JEditorPane pane = new JEditorPane("text/html;",
"Sample <b>content</b><br> <u>text</u>");
return pane;
}
}, new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderText, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JEditorPane pane = new JEditorPane("text/html;",
"Sample <b>content</b><br> <u>text</u>");
return pane;
}
}, new DisableCommand());
addControlRow(builderText, "Not editable",
new CreationCommand<Component>() {
public Component create() {
JEditorPane pane = new JEditorPane("text/html;",
"Sample <b>content</b><br> <u>text</u>");
pane.setEditable(false);
return pane;
}
}, null);
builderText.appendSeparator("Text areas");
addControlRow(builderText, "Regular", new CreationCommand<Component>() {
public Component create() {
JTextArea area = new JTextArea("Sample content text", 3, 15);
return area;
}
}, null);
addControlRow(builderText, "Watermark",
new CreationCommand<Component>() {
public Component create() {
JTextArea area = new JTextArea("Sample content text",
3, 15);
return area;
}
}, new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderText, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JTextArea area = new JTextArea("Sample content text",
3, 15);
return area;
}
}, new DisableCommand());
addControlRow(builderText, "Not editable",
new CreationCommand<Component>() {
public Component create() {
JTextArea area = new JTextArea("Sample content text",
3, 15);
area.setEditable(false);
return area;
}
}, null);
builderText.appendSeparator("Text panes");
addControlRow(builderText, "Regular", new CreationCommand<Component>() {
public Component create() {
JTextPane pane = new JTextPane();
pane.replaceSelection("Sample content text");
pane.setPreferredSize(new Dimension(120, 40));
return pane;
}
}, null);
addControlRow(builderText, "Watermark",
new CreationCommand<Component>() {
public Component create() {
JTextPane pane = new JTextPane();
pane.replaceSelection("Sample content text");
pane.setPreferredSize(new Dimension(120, 40));
return pane;
}
}, new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderText, "Disabled",
new CreationCommand<Component>() {
public Component create() {
JTextPane pane = new JTextPane();
pane.replaceSelection("Sample content text");
pane.setPreferredSize(new Dimension(120, 40));
return pane;
}
}, new DisableCommand());
addControlRow(builderText, "Not editable",
new CreationCommand<Component>() {
public Component create() {
JTextPane pane = new JTextPane();
pane.replaceSelection("Sample content text");
pane.setPreferredSize(new Dimension(120, 40));
pane.setEditable(false);
return pane;
}
}, null);
JPanel panelText = builderText.getPanel();
JScrollPane jspText = new JScrollPane(panelText);
panelText.setOpaque(false);
jspText.setOpaque(false);
jspText.getViewport().setOpaque(false);
JScrollPane coloredScrollPane = new JScrollPane(new CheckeredPanel());
coloredScrollPane.setBackground(Color.yellow);
coloredScrollPane.getVerticalScrollBar().setBackground(Color.green);
FormLayout lmCells = new FormLayout(
"right:pref, 10dlu, fill:pref:grow(1), 4dlu,"
+ "fill:pref:grow(1), 4dlu, fill:pref:grow(1), "
+ "4dlu, fill:pref:grow(1)", "");
lmCells.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
DefaultFormBuilder builderCells = new DefaultFormBuilder(lmCells,
new ScrollablePanel());
builderCells.setDefaultDialogBorder();
builderCells.append("");
builderCells.append(new JLabel("Yellow"), new JLabel(
"Blue + red foreground"));
builderCells.append(new JLabel("Green"), new JLabel("Dark green"));
builderCells.appendSeparator("Lists");
addControlRow(builderCells, "List", new CreationCommand<Component>() {
public Component create() {
JList list = new JList(new Object[] { "entry1", "entry2",
"entry3" });
return list;
}
}, null);
addControlRow(builderCells, "List watermark",
new CreationCommand<Component>() {
public Component create() {
JList list = new JList(new Object[] { "entry1",
"entry2", "entry3" });
return list;
}
}, new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderCells, "List disabled",
new CreationCommand<Component>() {
public Component create() {
JList list = new JList(new Object[] { "entry1",
"entry2", "entry3" });
return list;
}
}, new DisableCommand());
CreationCommand<Component> tableCreationCmd = new CreationCommand<Component>() {
public Component create() {
final JTable table = new JTable(new Object[][] {
{ "entry11", "entry12", "entry13" },
{ "entry21", "entry22", "entry23" },
{ "entry31", "entry32", "entry33" } }, new Object[] {
"Column1", "Column2", "Column3" });
table.setName("Table ");
JScrollPane tableScroll = new JScrollPane(table) {
@Override
public void setBackground(Color bg) {
super.setBackground(bg);
table.setBackground(bg);
table.getTableHeader().setBackground(bg);
}
@Override
public void setForeground(Color fg) {
super.setForeground(fg);
table.setForeground(fg);
table.getTableHeader().setForeground(fg);
}
};
Dimension prefTable = table.getPreferredSize();
tableScroll.setPreferredSize(new Dimension(prefTable.width,
prefTable.height + 25));
return tableScroll;
}
};
builderCells.appendSeparator("Tables");
addControlRow(builderCells, "Table", tableCreationCmd, null);
addControlRow(builderCells, "Table watermark", tableCreationCmd,
new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderCells, "Table disabled", tableCreationCmd,
new DisableViewportCommand());
CreationCommand<Component> treeCreationCmd = new CreationCommand<Component>() {
public void expandAll(JTree tree, boolean expand) {
TreeNode root = (TreeNode) tree.getModel().getRoot();
// Traverse tree from root
expandAll(tree, new TreePath(root), expand);
}
private void expandAll(JTree tree, TreePath parent, boolean expand) {
// Traverse children
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() >= 0) {
for (Enumeration e = node.children(); e.hasMoreElements();) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
expandAll(tree, path, expand);
}
}
// Expansion or collapse must be done bottom-up
if (expand) {
tree.expandPath(parent);
} else {
tree.collapsePath(parent);
}
}
public Component create() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1");
DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2");
DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3");
DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode(
"gson11");
DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode(
"gson12");
DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode(
"gson21");
DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode(
"gson22");
DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode(
"gson31");
DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode(
"gson32");
DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode(
"ggson111");
DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode(
"ggson112");
DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode(
"ggson113");
gson11.add(ggson111);
gson11.add(ggson112);
gson11.add(ggson113);
son1.add(gson11);
son1.add(gson12);
son2.add(gson21);
son2.add(gson22);
son3.add(gson31);
son3.add(gson32);
root.add(son1);
root.add(son2);
root.add(son3);
JTree tree = new JTree(root);
expandAll(tree, true);
return tree;
}
};
builderCells.appendSeparator("Trees");
addControlRow(builderCells, "Tree", treeCreationCmd, null);
addControlRow(builderCells, "Tree watermark", treeCreationCmd,
new ClientPropertyCommand(
SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE));
addControlRow(builderCells, "Tree disabled", treeCreationCmd,
new DisableCommand());
JPanel panelCells = builderCells.getPanel();
JScrollPane jspCells = new JScrollPane(panelCells);
panelCells.setOpaque(false);
jspCells.setOpaque(false);
jspCells.getViewport().setOpaque(false);