Source Code Cross Referenced for SampleInternalFrame.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:        /*
002:         * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of Substance Kirill Grouchnikov nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:        package test.check;
031:
032:        import java.awt.*;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:        import java.util.LinkedList;
036:        import java.util.Map;
037:
038:        import javax.swing.*;
039:        import javax.swing.border.EmptyBorder;
040:
041:        import org.jvnet.lafwidget.LafWidget;
042:        import org.jvnet.substance.SubstanceImageCreator;
043:        import org.jvnet.substance.SubstanceLookAndFeel;
044:        import org.jvnet.substance.theme.*;
045:        import org.jvnet.substance.theme.SubstanceTheme.ThemeKind;
046:        import org.jvnet.substance.watermark.WatermarkChangeListener;
047:        import org.jvnet.substance.watermark.WatermarkInfo;
048:
049:        import com.jgoodies.forms.builder.DefaultFormBuilder;
050:        import com.jgoodies.forms.layout.FormLayout;
051:        import com.jgoodies.forms.layout.Sizes;
052:
053:        /**
054:         * Internal frame for the test application.
055:         * 
056:         * @author Kirill Grouchnikov
057:         */
058:        public class SampleInternalFrame extends JInternalFrame {
059:            /**
060:             * Creates the test internal frame.
061:             */
062:            public SampleInternalFrame() {
063:                this .setLayout(new BorderLayout());
064:                JTabbedPane tabbed = new JTabbedPane();
065:                this .add(tabbed, BorderLayout.CENTER);
066:
067:                tabbed.addTab("Regular", new JPanel());
068:
069:                JPanel samplePanel = new JPanel(new BorderLayout());
070:                FormLayout lm = new FormLayout("fill:default:grow(1), 4dlu,"
071:                        + "fill:default:grow(1)", "");
072:                DefaultFormBuilder builder = new DefaultFormBuilder(lm,
073:                        new ScrollablePanel());
074:                builder.setLineGapSize(Sizes.pixel(1));
075:                builder.setBorder(new EmptyBorder(2, 2, 2, 2));
076:                // lm.setColumnGroups(new int[][] { { 3, 5, 7 } });
077:
078:                // TwoColumnPanel stuff = new TwoColumnPanel();
079:                // stuff.setVerticalSpacing(4);
080:                // stuff.setHorizontalSpacing(0);
081:
082:                JCheckBox cb1 = new JCheckBox("Enabled selected");
083:                cb1.setSelected(true);
084:                JCheckBox cb2 = new JCheckBox("Disabled selected");
085:                cb2.setSelected(true);
086:                cb2.setEnabled(false);
087:                JCheckBox cb3 = new JCheckBox("Enabled unselected");
088:                // cb3.setEnabled(false);
089:                JRadioButton rb1 = new JRadioButton("Enabled selected");
090:                rb1.setSelected(true);
091:                JRadioButton rb2 = new JRadioButton("Disabled selected");
092:                rb2.setSelected(true);
093:                rb2.setEnabled(false);
094:                JRadioButton rb3 = new JRadioButton("Enabled unselected");
095:                // rb3.setEnabled(false);
096:
097:                builder.append(cb1, rb1);
098:                builder.append(cb2, rb2);
099:                builder.append(cb3, rb3);
100:                JComboBox combo = new JComboBox(new Object[] { "item1" });
101:                combo.setSelectedIndex(0);
102:                combo.setEditable(true);
103:                combo.putClientProperty(LafWidget.COMBO_BOX_USE_MODEL_ONLY,
104:                        Boolean.TRUE);
105:                JTextField text = new JTextField("Text field");
106:                text.setEditable(false);
107:                builder.append(combo, text);
108:                JPanel contentPanel = builder.getPanel();
109:                contentPanel.setPreferredSize(new Dimension(contentPanel
110:                        .getPreferredSize().width, contentPanel
111:                        .getPreferredSize().height + 100));
112:                // contentPanel.setOpaque(false);
113:                contentPanel.setBorder(null);
114:                // stuff.setBorder(null);
115:
116:                JScrollPane scroll = new JScrollPane(contentPanel,
117:                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
118:                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
119:
120:                scroll.setBorder(new EmptyBorder(0, 0, 0, 0));
121:                samplePanel.add(scroll, BorderLayout.CENTER);
122:
123:                JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
124:                JButton prev = new JButton("prev");
125:                JButton cancel = new JButton("cancel");
126:                cancel.setEnabled(false);
127:                JButton ok = new JButton("OK");
128:                ok.putClientProperty(
129:                        SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY,
130:                        Boolean.TRUE);
131:                buttons.add(prev);
132:                buttons.add(cancel);
133:                buttons.add(ok);
134:
135:                samplePanel.add(buttons, BorderLayout.SOUTH);
136:
137:                tabbed.addTab("Sample", samplePanel);
138:                tabbed.setSelectedComponent(samplePanel);
139:                tabbed.setOpaque(false);
140:                JMenuBar jmb = new JMenuBar();
141:
142:                if (UIManager.getLookAndFeel() instanceof  SubstanceLookAndFeel) {
143:                    Map<String, ThemeInfo> allThemes = SubstanceLookAndFeel
144:                            .getAllThemes();
145:
146:                    JMenu jmTheme = new JMenu("Theme");
147:                    JMenu jmInvertedTheme = SubstanceLookAndFeel
148:                            .toEnableInvertedThemes() ? new JMenu(
149:                            "Inverted theme") : null;
150:
151:                    ButtonGroup bgTheme = new ButtonGroup();
152:                    for (Map.Entry<String, ThemeInfo> themeEntry : allThemes
153:                            .entrySet()) {
154:                        String themeName = themeEntry.getKey();
155:                        final ThemeInfo themeInfo = themeEntry.getValue();
156:                        final String themeClassName = themeInfo.getClassName();
157:
158:                        JRadioButtonMenuItem jmiTheme = new JRadioButtonMenuItem(
159:                                themeName);
160:                        try {
161:                            Class<?> themeClass = Class.forName(themeClassName);
162:                            SubstanceTheme theme = (SubstanceTheme) themeClass
163:                                    .newInstance();
164:                            if (themeInfo.getThemeKind() == ThemeKind.INVERTED)
165:                                theme = new SubstanceInvertedTheme(theme);
166:                            jmiTheme.setIcon(SubstanceImageCreator
167:                                    .getThemeIcon(theme));
168:                        } catch (Exception exc) {
169:                            continue;
170:                        }
171:
172:                        jmiTheme.addActionListener(new ActionListener() {
173:                            public void actionPerformed(ActionEvent e) {
174:                                try {
175:                                    if ((themeInfo.getThemeKind() == ThemeKind.INVERTED)
176:                                            || (themeInfo.getThemeKind() == ThemeKind.NEGATED)) {
177:                                        SubstanceLookAndFeel
178:                                                .setCurrentTheme(themeInfo);
179:                                    } else {
180:                                        SubstanceLookAndFeel
181:                                                .setCurrentTheme(themeClassName);
182:                                    }
183:                                    // UIManager
184:                                    // .setLookAndFeel(new SubstanceLookAndFeel());
185:                                } catch (Exception exc) {
186:                                    exc.printStackTrace();
187:                                }
188:                                for (Frame frame : Frame.getFrames())
189:                                    SwingUtilities.updateComponentTreeUI(frame);
190:                            }
191:                        });
192:                        if (themeName.equals(SubstanceLookAndFeel
193:                                .getCurrentThemeName())) {
194:                            jmiTheme.setSelected(true);
195:                        }
196:                        bgTheme.add(jmiTheme);
197:
198:                        if (themeEntry.getValue().getThemeKind() == ThemeKind.INVERTED)
199:                            jmInvertedTheme.add(jmiTheme);
200:                        else
201:                            jmTheme.add(jmiTheme);
202:                    }
203:
204:                    jmb.add(jmTheme);
205:                    if (jmInvertedTheme != null)
206:                        jmb.add(jmInvertedTheme);
207:
208:                    JMenu jmWatermark = new JMenu("Watermark");
209:
210:                    ButtonGroup bgWatermark = new ButtonGroup();
211:                    Map<String, WatermarkInfo> allWatermarks = SubstanceLookAndFeel
212:                            .getAllWatermarks();
213:                    for (Map.Entry<String, WatermarkInfo> watermarkEntry : allWatermarks
214:                            .entrySet()) {
215:                        String watermarkName = watermarkEntry.getKey();
216:                        final String watermarkClassName = watermarkEntry
217:                                .getValue().getClassName();
218:
219:                        JRadioButtonMenuItem jmiWatermark = new JRadioButtonMenuItem(
220:                                watermarkName);
221:                        jmiWatermark.addActionListener(new ActionListener() {
222:                            public void actionPerformed(ActionEvent e) {
223:                                SubstanceLookAndFeel
224:                                        .setCurrentWatermark(watermarkClassName);
225:                                for (Frame frame : Frame.getFrames())
226:                                    SwingUtilities.updateComponentTreeUI(frame);
227:                            }
228:                        });
229:                        if (watermarkName.equals(SubstanceLookAndFeel
230:                                .getCurrentWatermarkName())) {
231:                            jmiWatermark.setSelected(true);
232:                        }
233:                        bgWatermark.add(jmiWatermark);
234:                        jmWatermark.add(jmiWatermark);
235:                    }
236:
237:                    jmWatermark.addSeparator();
238:                }
239:
240:                JMenu jm1 = new JMenu("Menu1");
241:                jm1.setMnemonic('1');
242:                int mcount = 0;
243:                for (LinkedList<JMenuItem> miList : SampleMenuFactory
244:                        .getTestMenuItems()) {
245:                    if (mcount > 0) {
246:                        if (mcount % 2 == 0)
247:                            jm1.addSeparator();
248:                        else
249:                            jm1.add(new JSeparator());
250:                    }
251:                    for (JMenuItem menuItem : miList) {
252:                        jm1.add(menuItem);
253:                    }
254:                    mcount++;
255:                }
256:                jmb.add(jm1);
257:                this .setJMenuBar(jmb);
258:
259:                this .setClosable(true);
260:                this .setMaximizable(true);
261:                this .setIconifiable(true);
262:                this .setResizable(true);
263:
264:                synchronize();
265:                SubstanceLookAndFeel
266:                        .registerThemeChangeListener(new ThemeChangeListener() {
267:                            public void themeChanged() {
268:                                synchronize();
269:                            }
270:                        });
271:                SubstanceLookAndFeel
272:                        .registerWatermarkChangeListener(new WatermarkChangeListener() {
273:                            public void watermarkChanged() {
274:                                synchronize();
275:                            }
276:                        });
277:                ok.requestFocusInWindow();
278:            }
279:
280:            /**
281:             * Synchronizes the frame icon with the current theme.
282:             */
283:            protected void synchronize() {
284:                SwingUtilities.invokeLater(new Runnable() {
285:                    public void run() {
286:                        setFrameIcon(new ImageIcon(SubstanceImageCreator
287:                                .getBigHexaMarker(6, SubstanceLookAndFeel
288:                                        .getTheme())));
289:                        setTitle(SubstanceLookAndFeel.getCurrentThemeName()
290:                                + " / "
291:                                + SubstanceLookAndFeel
292:                                        .getCurrentWatermarkName());
293:                    }
294:                });
295:            }
296:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.