Source Code Cross Referenced for InternalFrameDemo.java in  » Swing-Library » substance-look-feel » test » contrib » 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.contrib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package test.contrib;
002:
003:        import java.awt.*;
004:        import java.awt.event.*;
005:        import java.net.URL;
006:
007:        import javax.swing.*;
008:
009:        import org.jdesktop.swingx.JXPanel;
010:
011:        /*
012:         * InternalFrameDemo.java requires:
013:         *   MyInternalFrame.java
014:         */
015:        public class InternalFrameDemo extends JFrame implements  ActionListener {
016:            JDesktopPane desktop;
017:            static int openFrameCount = 0;
018:            static final int xOffset = 30, yOffset = 30;
019:
020:            public InternalFrameDemo() {
021:                super ("InternalFrameDemo");
022:
023:                // Make the big window be indented 50 pixels from each edge
024:                // of the screen.
025:                int inset = 50;
026:                Dimension screenSize = Toolkit.getDefaultToolkit()
027:                        .getScreenSize();
028:                setBounds(inset, inset, screenSize.width - inset * 2,
029:                        screenSize.height - inset * 2);
030:
031:                // Set up the GUI.
032:                desktop = new JDesktopPane(); // a specialized layered pane
033:                createFrame(); // create first "window"
034:                createFrame(); // create second "window"
035:                createImageFrame();
036:                this .add(desktop);
037:                setJMenuBar(createMenuBar());
038:            }
039:
040:            protected void createImageFrame() {
041:                JInternalFrame ix = new JInternalFrame("ImageDocument", true, // resizable
042:                        true, // closable
043:                        true, // maximizable
044:                        true);// iconifiable
045:                ix.setSize(500, 500);
046:                URL iUrl = InternalFrameDemo.class.getClassLoader()
047:                        .getResource("test/contrib/image.jpg");
048:                ImageIcon icon = new ImageIcon(iUrl);
049:                ix.setLayout(new BorderLayout());
050:                ix.add(new JLabel(icon));
051:                ix.setVisible(true);
052:                desktop.add(ix);
053:            }
054:
055:            protected JMenuBar createMenuBar() {
056:                JMenuBar menuBar = new JMenuBar();
057:
058:                // Set up the lone menu.
059:                JMenu menu = new JMenu("Document");
060:                menu.setMnemonic(KeyEvent.VK_D);
061:                menuBar.add(menu);
062:
063:                // Set up the first menu item.
064:                JMenuItem menuItem = new JMenuItem("New");
065:                menuItem.setMnemonic(KeyEvent.VK_N);
066:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
067:                        ActionEvent.ALT_MASK));
068:                menuItem.setActionCommand("new");
069:                menuItem.addActionListener(this );
070:                menu.add(menuItem);
071:
072:                // Set up the second menu item.
073:                menuItem = new JMenuItem("Quit");
074:                menuItem.setMnemonic(KeyEvent.VK_Q);
075:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
076:                        ActionEvent.ALT_MASK));
077:                menuItem.setActionCommand("quit");
078:                menuItem.addActionListener(this );
079:                menu.add(menuItem);
080:
081:                return menuBar;
082:            }
083:
084:            // React to menu selections.
085:            public void actionPerformed(ActionEvent e) {
086:                if ("new".equals(e.getActionCommand())) { // new
087:                    createFrame();
088:                } else { // quit
089:                    quit();
090:                }
091:            }
092:
093:            // Create a new internal frame.
094:            protected void createFrame() {
095:                MyInternalFrame frame = new MyInternalFrame();
096:                frame.setVisible(true); // necessary as of 1.3
097:                desktop.add(frame);
098:                try {
099:                    frame.setSelected(true);
100:                } catch (java.beans.PropertyVetoException e) {
101:                }
102:            }
103:
104:            // Quit the application.
105:            protected void quit() {
106:                System.exit(0);
107:            }
108:
109:            /**
110:             * Create the GUI and show it. For thread safety, this method should be
111:             * invoked from the event-dispatching thread.
112:             */
113:            private static void createAndShowGUI() {
114:                // Make sure we have nice window decorations.
115:                // JFrame.setDefaultLookAndFeelDecorated(true);
116:                try {
117:                    UIManager
118:                            .setLookAndFeel("org.jvnet.substance.SubstanceLookAndFeel");
119:                    // Create and set up the window.
120:                    InternalFrameDemo frame = new InternalFrameDemo();
121:                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
122:
123:                    // Display the window.
124:                    frame.setVisible(true);
125:                } catch (Exception e) {
126:                    e.printStackTrace();
127:                }
128:            }
129:
130:            public static void main(String[] args) {
131:                // Schedule a job for the event-dispatching thread:
132:                // creating and showing this application's GUI.
133:                javax.swing.SwingUtilities.invokeLater(new Runnable() {
134:                    public void run() {
135:                        createAndShowGUI();
136:                    }
137:                });
138:            }
139:
140:            public class MyInternalFrame extends JInternalFrame {
141:
142:                public MyInternalFrame() {
143:                    super ("Document #" + (++openFrameCount), true, // resizable
144:                            true, // closable
145:                            true, // maximizable
146:                            true);// iconifiable
147:
148:                    // ...Create the GUI and put it in the window...
149:
150:                    // ...Then set the window size or call pack...
151:                    setSize(500, 500);
152:
153:                    // Set the window's location.
154:                    setLocation(xOffset * openFrameCount, yOffset
155:                            * openFrameCount);
156:
157:                    // Add a panel
158:                    JXPanel panel = new JXPanel();
159:                    //panel.setOpaque(false);
160:                    panel.setAlpha(0.5f);
161:                    this .add(panel);
162:                    String[] columnNames = { "First Name", "Last Name",
163:                            "Sport", "# of Years", "Vegetarian" };
164:
165:                    Object[][] data = {
166:                            { "Mary", "Campione", "Snowboarding",
167:                                    new Integer(5), new Boolean(false) },
168:                            { "Alison", "Huml", "Rowing", new Integer(3),
169:                                    new Boolean(true) },
170:                            { "Kathy", "Walrath", "Knitting", new Integer(2),
171:                                    new Boolean(false) },
172:                            { "Sharon", "Zakhour", "Speed reading",
173:                                    new Integer(20), new Boolean(true) },
174:                            { "Philip", "Milne", "Pool", new Integer(10),
175:                                    new Boolean(false) } };
176:
177:                    panel.add(new JTable(data, columnNames));
178:                    // A simple tree
179:                    panel.add(new JTree());
180:
181:                    //			// A simple tree non opaque
182:                    //			JTree tree = new JTree();
183:                    //			tree.setOpaque(false);
184:                    //			panel.add(tree);
185:                    //
186:                    //			// A table in a pane opaque
187:                    //			JPanel panel3 = new JPanel();
188:                    //			panel3.add(new JTable(data, columnNames));
189:                    //			panel3.setPreferredSize(new Dimension(150, 150));
190:                    //			panel.add(panel3);
191:                    //
192:                    //			// A table in a scroll pane non opaque
193:                    //			JScrollPane treeScroll = new JScrollPane(new JTable(data,
194:                    //					columnNames));
195:                    //			treeScroll.setPreferredSize(new Dimension(150, 150));
196:                    //			treeScroll.setOpaque(false);
197:                    //			treeScroll.setAutoscrolls(true);
198:                    //			panel.add(treeScroll);
199:                    //
200:                    //			// A table in a scroll pane opaque
201:                    //			JScrollPane treeScroll5 = new JScrollPane(new JTable(data,
202:                    //					columnNames));
203:                    //			treeScroll5.setPreferredSize(new Dimension(150, 150));
204:                    //			treeScroll5.setAutoscrolls(true);
205:                    //			panel.add(treeScroll5);
206:                    //
207:                    //			// A tree in a scrollpane non opaque
208:                    //			JScrollPane treeScroll2 = new JScrollPane(new JTree());
209:                    //			treeScroll2.setPreferredSize(new Dimension(150, 150));
210:                    //			treeScroll2.setOpaque(false);
211:                    //			treeScroll2.setAutoscrolls(true);
212:                    //			panel.add(treeScroll2);
213:                    //
214:                    //			// A tree in a scrollpane opaque
215:                    //			JScrollPane treeScroll4 = new JScrollPane(new JTree());
216:                    //			treeScroll4.setPreferredSize(new Dimension(150, 150));
217:                    //			treeScroll4.setAutoscrolls(true);
218:                    //			panel.add(treeScroll4);
219:                    //
220:                    //			// A icon in a scroll pane
221:                    //			JPanel panel2 = new JPanel();
222:                    //			panel2.setOpaque(false);
223:                    //			URL iUrl = InternalFrameDemo.class.getClassLoader().getResource(
224:                    //					"test/contrib/image2.jpg");
225:                    //			JLabel label = new JLabel(new ImageIcon(iUrl));
226:                    //			label.setOpaque(false);
227:                    //			panel2.add(label);
228:                    //			JScrollPane treeScroll3 = new JScrollPane(panel2);
229:                    //			treeScroll3.setOpaque(false);
230:                    //			treeScroll3.setPreferredSize(new Dimension(150, 150));
231:                    //			treeScroll3.setAutoscrolls(true);
232:                    //			panel.add(treeScroll3);
233:
234:                }
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.