001: /*******************************************************************************
002: * Copyright (c) 2007-2008 Kirill Grouchnikov and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *******************************************************************************/package test;
008:
009: import java.awt.*;
010: import java.text.DecimalFormat;
011:
012: import javax.swing.*;
013: import javax.swing.tree.DefaultMutableTreeNode;
014:
015: import org.jvnet.substance.SubstanceLookAndFeel;
016: import org.jvnet.substance.skin.BusinessBlackSteelSkin;
017: import org.jvnet.substance.watermark.SubstanceLatchWatermark;
018:
019: import test.check.SampleMenuFactory;
020:
021: public class SimpleBrambleFrame extends JFrame {
022: public SimpleBrambleFrame() {
023: super ("Sample title");
024:
025: this .setLayout(new BorderLayout());
026:
027: JPanel controlsPanel = new JPanel(new FlowLayout());
028:
029: JPanel vControlsPanel = new JPanel(new FlowLayout());
030:
031: controlsPanel.add(new JLabel("Qwerty"));
032: JButton button = new JButton("Qwerty");
033: button.setMnemonic('w');
034: controlsPanel.add(button);
035:
036: JCheckBox checkBox = new JCheckBox("Qwerty");
037: checkBox.setMnemonic('e');
038: controlsPanel.add(checkBox);
039:
040: JToggleButton toggleButton = new JToggleButton("Qwerty");
041: toggleButton.setMnemonic('r');
042: controlsPanel.add(toggleButton);
043:
044: JRadioButton radioButton = new JRadioButton("Qwerty");
045: radioButton.setMnemonic('y');
046: controlsPanel.add(radioButton);
047:
048: JComboBox combo = new JComboBox(new Object[] { "Qwerty",
049: "uiop[]", "asdfgh", "jkl;'", "zxcvb", "nm,./" });
050: controlsPanel.add(combo);
051:
052: JList list = new JList(new Object[] { "Qwerty", "uiop[]",
053: "asdfgh", "jkl;'", "zxcvb", "nm,./" });
054: controlsPanel.add(list);
055: JList listBleed = new JList(new Object[] { "Qwerty", "uiop[]",
056: "asdfgh", "jkl;'", "zxcvb", "nm,./" });
057: listBleed.putClientProperty(
058: SubstanceLookAndFeel.WATERMARK_TO_BLEED, Boolean.TRUE);
059: controlsPanel.add(listBleed);
060:
061: JTree tree = getTree();
062: controlsPanel.add(tree);
063:
064: JTree treeBleed = getTree();
065: treeBleed.putClientProperty(
066: SubstanceLookAndFeel.WATERMARK_TO_BLEED, Boolean.TRUE);
067: controlsPanel.add(treeBleed);
068:
069: JTable table = new JTable(new Object[][] {
070: { "qwerty11", "qwerty12", "qwerty13" },
071: { "qwerty21", "qwerty22", "qwerty23" },
072: { "qwerty31", "qwerty32", "qwerty33" } }, new Object[] {
073: "Qwerty1", "Qwerty2", "Qwerty3" });
074: JScrollPane tableScroll = new JScrollPane(table);
075: Dimension prefTable = table.getPreferredSize();
076: tableScroll.setPreferredSize(new Dimension(prefTable.width,
077: prefTable.height + 25));
078: controlsPanel.add(tableScroll);
079:
080: JTable tableBleed = new JTable(new Object[][] {
081: { "qwerty11", "qwerty12", "qwerty13" },
082: { "qwerty21", "qwerty22", "qwerty23" },
083: { "qwerty31", "qwerty32", "qwerty33" } }, new Object[] {
084: "Qwerty1", "Qwerty2", "Qwerty3" });
085: JScrollPane tableScrollBleed = new JScrollPane(tableBleed);
086: Dimension prefTableBleed = tableBleed.getPreferredSize();
087: tableScrollBleed.setPreferredSize(new Dimension(
088: prefTableBleed.width, prefTableBleed.height + 25));
089: tableBleed.putClientProperty(
090: SubstanceLookAndFeel.WATERMARK_TO_BLEED, Boolean.TRUE);
091: tableScrollBleed.putClientProperty(
092: SubstanceLookAndFeel.WATERMARK_TO_BLEED, Boolean.TRUE);
093: controlsPanel.add(tableScrollBleed);
094:
095: JTextField textField = new JTextField("Qwerty");
096: controlsPanel.add(textField);
097:
098: JFormattedTextField formattedTextField = new JFormattedTextField(
099: new DecimalFormat("#,##0.0000"));
100: formattedTextField.setText("2,430.0000");
101: controlsPanel.add(formattedTextField);
102:
103: JButton buttonTooltip = new JButton("Tooltip");
104: buttonTooltip.setToolTipText("Qwerty tooltip");
105: controlsPanel.add(buttonTooltip);
106:
107: JSlider hslider = new JSlider(0, 100, 50);
108: hslider.setPaintLabels(true);
109: hslider.setPaintTicks(true);
110: hslider.setMajorTickSpacing(20);
111: hslider.setMinorTickSpacing(5);
112: controlsPanel.add(hslider);
113:
114: JSlider hsliderSimple = new JSlider(0, 100, 50);
115: controlsPanel.add(hsliderSimple);
116:
117: JSlider vslider = new JSlider(JSlider.VERTICAL, 0, 100, 50);
118: vslider.setPaintLabels(true);
119: vslider.setPaintTicks(true);
120: vslider.setMajorTickSpacing(20);
121: vslider.setMinorTickSpacing(5);
122: vControlsPanel.add(vslider);
123:
124: JSlider vsliderSimple = new JSlider(JSlider.VERTICAL, 0, 100,
125: 50);
126: vControlsPanel.add(vsliderSimple);
127:
128: JProgressBar progress = new JProgressBar(0, 100);
129: progress.setValue(50);
130: controlsPanel.add(progress);
131:
132: JProgressBar progressString = new JProgressBar(0, 100);
133: progressString.setValue(50);
134: progressString.setStringPainted(true);
135: controlsPanel.add(progressString);
136:
137: JProgressBar progressDis = new JProgressBar(0, 100);
138: progressDis.setValue(50);
139: progressDis.setStringPainted(true);
140: progressDis.setEnabled(false);
141: controlsPanel.add(progressDis);
142:
143: JProgressBar vProgress = new JProgressBar(0, 100);
144: vProgress.setValue(50);
145: vProgress.setOrientation(JProgressBar.VERTICAL);
146: vControlsPanel.add(vProgress);
147:
148: JProgressBar vProgressString = new JProgressBar(0, 100);
149: vProgressString.setValue(50);
150: vProgressString.setStringPainted(true);
151: vProgressString.setOrientation(JProgressBar.VERTICAL);
152: vControlsPanel.add(vProgressString);
153:
154: JProgressBar vProgressDis = new JProgressBar(0, 100);
155: vProgressDis.setValue(50);
156: vProgressDis.setStringPainted(true);
157: vProgressDis.setEnabled(false);
158: vProgressDis.setOrientation(JProgressBar.VERTICAL);
159: vControlsPanel.add(vProgressDis);
160:
161: JDesktopPane desktopPane = new JDesktopPane();
162: JInternalFrame internalFrame = new JInternalFrame();
163: internalFrame.setLayout(new FlowLayout());
164: internalFrame.add(new JButton("qwerty"));
165: internalFrame.add(new JCheckBox("qwerty"));
166: internalFrame.add(new JRadioButton("qwerty"));
167: internalFrame.add(new JToggleButton("qwerty"));
168: internalFrame.setBounds(10, 10, 200, 200);
169: internalFrame.setMaximizable(true);
170: internalFrame.setIconifiable(true);
171: internalFrame.setResizable(true);
172: internalFrame.setClosable(true);
173: internalFrame.setTitle("Qwerty title");
174: desktopPane.add(internalFrame);
175: internalFrame.setVisible(true);
176:
177: JList bigList = new JList(new DefaultListModel() {
178: @Override
179: public int getSize() {
180: return 300;
181: }
182:
183: @Override
184: public Object getElementAt(int index) {
185: return "Element " + index;
186: }
187: });
188:
189: JTabbedPane jtp = new JTabbedPane();
190: jtp.addTab("Controls", controlsPanel);
191: jtp.addTab("Vertical", vControlsPanel);
192: jtp.addTab("Desktop", desktopPane);
193: jtp.addTab("Big list", new JScrollPane(bigList));
194: jtp.addTab("Qwerty", new JPanel());
195: jtp.setSelectedIndex(0);
196:
197: this .add(jtp, BorderLayout.CENTER);
198:
199: JMenuBar jmb = new JMenuBar();
200: JMenu menu1 = SampleMenuFactory.getTestMenu();
201: JMenu menu2 = new JMenu("Edit");
202: menu2.add(new JMenuItem("Qwerty"));
203: menu2.add(new JCheckBoxMenuItem("Qwerty"));
204: menu2.add(new JRadioButtonMenuItem("Qwerty"));
205: menu2.add(new JMenu("Qwerty"));
206: JMenu menu3 = new JMenu("Source");
207: menu3.add(new JMenuItem("Qwerty"));
208: menu3.add(new JCheckBoxMenuItem("Qwerty"));
209: menu3.add(new JRadioButtonMenuItem("Qwerty"));
210: menu3.add(new JMenu("Qwerty"));
211: jmb.add(menu1);
212: jmb.add(menu2);
213: jmb.add(menu3);
214:
215: this .setJMenuBar(jmb);
216:
217: this .setSize(600, 600);
218: this .setLocationRelativeTo(null);
219: this .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
220: }
221:
222: private JTree getTree() {
223: DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
224: DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1");
225: DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2");
226: DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3");
227: DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode(
228: "gson11");
229: DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode(
230: "gson12");
231: DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode(
232: "gson21");
233: DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode(
234: "gson22");
235: DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode(
236: "gson31");
237: DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode(
238: "gson32");
239: DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode(
240: "ggson111");
241: DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode(
242: "ggson112");
243: DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode(
244: "ggson113");
245:
246: gson11.add(ggson111);
247: gson11.add(ggson112);
248: gson11.add(ggson113);
249: son1.add(gson11);
250: son1.add(gson12);
251: son2.add(gson21);
252: son2.add(gson22);
253: son3.add(gson31);
254: son3.add(gson32);
255: root.add(son1);
256: root.add(son2);
257: root.add(son3);
258:
259: JTree tree = new JTree(root);
260: return tree;
261: }
262:
263: public static class CustomSkin extends BusinessBlackSteelSkin {
264: public CustomSkin() {
265: super ();
266: this .watermark = new SubstanceLatchWatermark();
267: }
268: }
269:
270: public static void main(String[] args) throws Exception {
271: SubstanceLookAndFeel.setSkin(new CustomSkin());
272: JFrame.setDefaultLookAndFeelDecorated(true);
273: SwingUtilities.invokeLater(new Runnable() {
274: public void run() {
275: new SimpleBrambleFrame().setVisible(true);
276: }
277: });
278: }
279: }
|