Source Code Cross Referenced for SizesPanel.java in  » Swing-Library » substance-look-feel » test » check » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » substance look feel » test.check 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package test.check;
002:
003:        import java.awt.*;
004:        import java.util.LinkedList;
005:        import java.util.List;
006:
007:        import javax.swing.*;
008:        import javax.swing.event.ListSelectionEvent;
009:        import javax.swing.event.ListSelectionListener;
010:        import javax.swing.table.DefaultTableModel;
011:        import javax.swing.tree.DefaultMutableTreeNode;
012:
013:        import org.jvnet.substance.SubstanceDefaultListCellRenderer;
014:
015:        import com.jgoodies.forms.builder.DefaultFormBuilder;
016:        import com.jgoodies.forms.layout.FormLayout;
017:
018:        public class SizesPanel extends JPanel {
019:            private static interface Creator {
020:                public JComponent create(int fontSize);
021:            }
022:
023:            private static class Mapping {
024:                public String caption;
025:
026:                public Creator creator;
027:
028:                public Mapping(String caption, Creator creator) {
029:                    super ();
030:                    this .caption = caption;
031:                    this .creator = creator;
032:                }
033:            }
034:
035:            private List<Mapping> model;
036:
037:            private JScrollPane central;
038:
039:            public SizesPanel() {
040:                this .model = new LinkedList<Mapping>();
041:                this .model.add(new Mapping("buttons", new Creator() {
042:                    public JComponent create(int fontSize) {
043:                        JButton result = new JButton("size " + fontSize);
044:                        result
045:                                .setFont(new Font("Tahoma", Font.PLAIN,
046:                                        fontSize));
047:                        return result;
048:                    }
049:                }));
050:                this .model.add(new Mapping("toggle buttons", new Creator() {
051:                    public JComponent create(int fontSize) {
052:                        JToggleButton result = new JToggleButton("size "
053:                                + fontSize);
054:                        result
055:                                .setFont(new Font("Tahoma", Font.PLAIN,
056:                                        fontSize));
057:                        return result;
058:                    }
059:                }));
060:                this .model.add(new Mapping("check boxes", new Creator() {
061:                    public JComponent create(int fontSize) {
062:                        JCheckBox result = new JCheckBox("size " + fontSize);
063:                        result
064:                                .setFont(new Font("Tahoma", Font.PLAIN,
065:                                        fontSize));
066:                        return result;
067:                    }
068:                }));
069:                this .model.add(new Mapping("radio buttons", new Creator() {
070:                    public JComponent create(int fontSize) {
071:                        JRadioButton result = new JRadioButton("size "
072:                                + fontSize);
073:                        result
074:                                .setFont(new Font("Tahoma", Font.PLAIN,
075:                                        fontSize));
076:                        return result;
077:                    }
078:                }));
079:                this .model.add(new Mapping("combo boxes", new Creator() {
080:                    public JComponent create(int fontSize) {
081:                        JComboBox result = new JComboBox(new Object[] { "size "
082:                                + fontSize });
083:                        result
084:                                .setFont(new Font("Tahoma", Font.PLAIN,
085:                                        fontSize));
086:                        return result;
087:                    }
088:                }));
089:                this .model.add(new Mapping("spinners", new Creator() {
090:                    public JComponent create(int fontSize) {
091:                        JSpinner result = new JSpinner(new SpinnerNumberModel(
092:                                fontSize, fontSize, fontSize, 1));
093:                        result
094:                                .setFont(new Font("Tahoma", Font.PLAIN,
095:                                        fontSize));
096:                        return result;
097:                    }
098:                }));
099:                this .model.add(new Mapping("text fields", new Creator() {
100:                    public JComponent create(int fontSize) {
101:                        JTextField result = new JTextField("size " + fontSize);
102:                        result
103:                                .setFont(new Font("Tahoma", Font.PLAIN,
104:                                        fontSize));
105:                        return result;
106:                    }
107:                }));
108:                this .model.add(new Mapping("password fields", new Creator() {
109:                    public JComponent create(int fontSize) {
110:                        JPasswordField result = new JPasswordField("size "
111:                                + fontSize);
112:                        result
113:                                .setFont(new Font("Tahoma", Font.PLAIN,
114:                                        fontSize));
115:                        return result;
116:                    }
117:                }));
118:                this .model.add(new Mapping("scroll bars", new Creator() {
119:                    public JComponent create(int fontSize) {
120:                        JScrollBar result = new JScrollBar(
121:                                JScrollBar.HORIZONTAL);
122:                        result
123:                                .setFont(new Font("Tahoma", Font.PLAIN,
124:                                        fontSize));
125:                        return result;
126:                    }
127:                }));
128:                this .model.add(new Mapping("progress bars", new Creator() {
129:                    public JComponent create(int fontSize) {
130:                        JProgressBar result = new JProgressBar(
131:                                JProgressBar.HORIZONTAL);
132:                        result.setMinimum(0);
133:                        result.setMaximum(100);
134:                        result.setValue(60);
135:                        result
136:                                .setFont(new Font("Tahoma", Font.PLAIN,
137:                                        fontSize));
138:                        return result;
139:                    }
140:                }));
141:                this .model.add(new Mapping("progress bars 2", new Creator() {
142:                    public JComponent create(int fontSize) {
143:                        JProgressBar result = new JProgressBar(
144:                                JProgressBar.HORIZONTAL);
145:                        result.setMinimum(0);
146:                        result.setMaximum(100);
147:                        result.setValue(60);
148:                        result.setStringPainted(true);
149:                        result
150:                                .setFont(new Font("Tahoma", Font.PLAIN,
151:                                        fontSize));
152:                        return result;
153:                    }
154:                }));
155:                this .model.add(new Mapping("sliders", new Creator() {
156:                    public JComponent create(int fontSize) {
157:                        JSlider result = new JSlider(JSlider.HORIZONTAL, 0,
158:                                100, 50);
159:                        result
160:                                .setFont(new Font("Tahoma", Font.PLAIN,
161:                                        fontSize));
162:                        return result;
163:                    }
164:                }));
165:                this .model.add(new Mapping("sliders 2", new Creator() {
166:                    public JComponent create(int fontSize) {
167:                        JSlider result = new JSlider(JSlider.HORIZONTAL, 0,
168:                                100, 50);
169:                        result.setMajorTickSpacing(20);
170:                        result.setMinorTickSpacing(5);
171:                        result.setPaintLabels(true);
172:                        result
173:                                .setFont(new Font("Tahoma", Font.PLAIN,
174:                                        fontSize));
175:                        return result;
176:                    }
177:                }));
178:                this .model.add(new Mapping("sliders 3", new Creator() {
179:                    public JComponent create(int fontSize) {
180:                        JSlider result = new JSlider(JSlider.HORIZONTAL, 0,
181:                                100, 50);
182:                        result.setMajorTickSpacing(20);
183:                        result.setMinorTickSpacing(5);
184:                        result.setPaintTicks(true);
185:                        result
186:                                .setFont(new Font("Tahoma", Font.PLAIN,
187:                                        fontSize));
188:                        return result;
189:                    }
190:                }));
191:                this .model.add(new Mapping("sliders 4", new Creator() {
192:                    public JComponent create(int fontSize) {
193:                        JSlider result = new JSlider(JSlider.HORIZONTAL, 0,
194:                                100, 50);
195:                        result.setMajorTickSpacing(20);
196:                        result.setMinorTickSpacing(5);
197:                        result.setPaintTicks(true);
198:                        result.setPaintLabels(true);
199:                        result
200:                                .setFont(new Font("Tahoma", Font.PLAIN,
201:                                        fontSize));
202:                        return result;
203:                    }
204:                }));
205:                this .model.add(new Mapping("trees", new Creator() {
206:                    public JComponent create(int fontSize) {
207:                        DefaultMutableTreeNode root = new DefaultMutableTreeNode(
208:                                "size " + fontSize);
209:                        DefaultMutableTreeNode son1 = new DefaultMutableTreeNode(
210:                                "son1");
211:                        DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode(
212:                                "gson11");
213:                        son1.add(gson11);
214:                        root.add(son1);
215:                        JTree result = new JTree(root);
216:                        // result.setRootVisible(false);
217:                        // result.setShowsRootHandles(true);
218:                        result
219:                                .setFont(new Font("Tahoma", Font.PLAIN,
220:                                        fontSize));
221:                        return result;
222:                    }
223:                }));
224:                this .model.add(new Mapping("lists", new Creator() {
225:                    public JComponent create(int fontSize) {
226:                        JList result = new JList(new Object[] { "item1",
227:                                "item2" });
228:                        result
229:                                .setFont(new Font("Tahoma", Font.PLAIN,
230:                                        fontSize));
231:                        return result;
232:                    }
233:                }));
234:                this .model.add(new Mapping("tables", new Creator() {
235:                    public JComponent create(int fontSize) {
236:                        DefaultTableModel model = new DefaultTableModel() {
237:                            @Override
238:                            public int getRowCount() {
239:                                return 2;
240:                            }
241:
242:                            @Override
243:                            public int getColumnCount() {
244:                                return 3;
245:                            }
246:
247:                            @Override
248:                            public Object getValueAt(int row, int column) {
249:                                return row + ":" + column;
250:                            }
251:
252:                            @Override
253:                            public boolean isCellEditable(int row, int column) {
254:                                return false;
255:                            }
256:
257:                            @Override
258:                            public String getColumnName(int column) {
259:                                return "Column " + column;
260:                            }
261:                        };
262:                        JTable table = new JTable(model);
263:                        table.setFont(new Font("Tahoma", Font.PLAIN, fontSize));
264:                        return table;
265:                    }
266:                }));
267:
268:                final JList list = new JList(new AbstractListModel() {
269:                    public Object getElementAt(int index) {
270:                        return model.get(index);
271:                    }
272:
273:                    public int getSize() {
274:                        return model.size();
275:                    }
276:                });
277:                list.setCellRenderer(new SubstanceDefaultListCellRenderer() {
278:                    @Override
279:                    public Component getListCellRendererComponent(JList list,
280:                            Object value, int index, boolean isSelected,
281:                            boolean cellHasFocus) {
282:                        return super .getListCellRendererComponent(list,
283:                                ((Mapping) value).caption, index, isSelected,
284:                                cellHasFocus);
285:                    }
286:                });
287:                this .setLayout(new BorderLayout());
288:                this .add(new JScrollPane(list), BorderLayout.WEST);
289:
290:                list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
291:
292:                list.getSelectionModel().addListSelectionListener(
293:                        new ListSelectionListener() {
294:                            public void valueChanged(ListSelectionEvent e) {
295:                                SwingUtilities.invokeLater(new Runnable() {
296:                                    public void run() {
297:                                        if (central != null)
298:                                            remove(central);
299:                                        central = null;
300:
301:                                        int selIndex = list.getSelectedIndex();
302:                                        if (selIndex >= 0) {
303:                                            Mapping sel = (Mapping) list
304:                                                    .getSelectedValue();
305:                                            FormLayout lm = new FormLayout(
306:                                                    "right:pref, 4dlu, left:pref:grow",
307:                                                    "");
308:                                            DefaultFormBuilder builder = new DefaultFormBuilder(
309:                                                    lm, new ScrollablePanel());
310:                                            builder.setDefaultDialogBorder();
311:                                            for (int fontSize = 11; fontSize < 25; fontSize++) {
312:                                                builder
313:                                                        .append(
314:                                                                fontSize
315:                                                                        + " pixels",
316:                                                                sel.creator
317:                                                                        .create(fontSize));
318:                                            }
319:                                            central = new JScrollPane(
320:                                                    builder.getPanel(),
321:                                                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
322:                                                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
323:                                            add(central, BorderLayout.CENTER);
324:                                            doLayout();
325:                                            revalidate();
326:                                        }
327:                                    }
328:                                });
329:                            }
330:                        });
331:            }
332:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.