Source Code Cross Referenced for NonSense.java in  » IDE » tIDE » tide » editor » 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 » IDE » tIDE » tide.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package tide.editor;
002:
003:        import snow.utils.gui.GUIUtils;
004:        import javax.swing.event.MenuEvent;
005:        import javax.swing.event.MenuListener;
006:        import java.util.TimerTask;
007:        import java.awt.BorderLayout;
008:        import java.awt.FlowLayout;
009:        import java.awt.event.*;
010:        import java.awt.Insets;
011:        import javax.swing.border.EmptyBorder;
012:        import java.util.GregorianCalendar;
013:        import java.util.Calendar;
014:        import java.util.prefs.Preferences;
015:        import java.util.Random;
016:        import javax.swing.*;
017:
018:        /** Has to be.
019:         */
020:        public final class NonSense {
021:            private NonSense() {
022:            }
023:
024:            public static void create(JMenu menu) {
025:                menu.addSeparator();
026:                JMenu nsmenu = new JMenu("NonSense");
027:                menu.add(nsmenu);
028:
029:                Random r = new Random();
030:
031:                JMenuItem instanceRandomInt = new JMenuItem(
032:                        "Random int for this instance: " + r.nextInt());
033:                nsmenu.add(instanceRandomInt);
034:                JMenuItem instanceRandomBool = new JMenuItem(
035:                        "Random boolean for this instance: " + r.nextBoolean());
036:                nsmenu.add(instanceRandomBool);
037:                nsmenu.addSeparator();
038:
039:                int nin = r.nextInt();
040:                String ni = Preferences.userRoot().get("random_int", null);
041:                if (ni == null) {
042:                    Preferences.userRoot().put("random_int", "" + nin);
043:                } else {
044:                    try {
045:                        nin = Integer.parseInt(ni);
046:                    } catch (NumberFormatException ign) {
047:                    }
048:                }
049:
050:                JMenuItem userAndJVMRandomInt = new JMenuItem(
051:                        "Random int for this JVM and this user: " + nin);
052:                nsmenu.add(userAndJVMRandomInt);
053:
054:                JMenuItem eternalWait = new JMenuItem("Nothing for impatients");
055:                nsmenu.addSeparator();
056:                nsmenu.add(eternalWait);
057:                eternalWait.addActionListener(new ActionListener() {
058:                    public void actionPerformed(ActionEvent ae) {
059:                        pleaseWait();
060:                    }
061:                });
062:
063:                JMenuItem conf1 = new JMenuItem("Please confirm...");
064:                nsmenu.add(conf1);
065:                conf1.addActionListener(new ActionListener() {
066:                    public void actionPerformed(ActionEvent ae) {
067:                        goodChoice();
068:                    }
069:                });
070:                //+stupid questions
071:                //+dummy invasion alerts
072:                //+dummy blue screen.
073:
074:                final JMenu subm = new JMenu("Search an end...");
075:                nsmenu.add(subm);
076:                infiniteSubmenu(subm, 1);
077:
078:                /*
079:                JMenuItem tech = new JMenuItem("What tIDE is ...");
080:                nsmenu.add(tech);
081:                tech.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) {
082:                   GUIUtils.displayInDialog(MainEditorFrame.instance, "What tIDE is",
083:                      GUIUtils.createReadOnlyDescriptionArea("<html><body>"
084:                      +"Whing sang klang mang klue smue"
085:
086:                      ));
087:                } });  */
088:            }
089:
090:            private static void infiniteSubmenu(final JMenu subm,
091:                    final int level) {
092:                /*int n = (int)(Math.random()*10);
093:                for(int i=0*/
094:                subm.addMenuListener(new MenuListener() {
095:                    public void menuCanceled(MenuEvent e) {
096:                    }
097:
098:                    public void menuDeselected(MenuEvent e) {
099:                    }
100:
101:                    public void menuSelected(MenuEvent e) {
102:                        String name = "deeper...";
103:                        JMenu jm = new JMenu(name);
104:                        subm.add(jm);
105:                        infiniteSubmenu(jm, level + 1);
106:
107:                    }
108:                });
109:            }
110:
111:            private static void goodChoice() {
112:                final JDialog d = new JDialog((JFrame) null, "Confirmation",
113:                        true);
114:                JLabel lab = new JLabel("Are you sure ?");
115:                lab.setBorder(new EmptyBorder(5, 5, 5, 5));
116:                d.add(lab, BorderLayout.CENTER);
117:                JPanel fp = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
118:                d.add(fp, BorderLayout.SOUTH);
119:                ActionListener closeAction = new ActionListener() {
120:                    public void actionPerformed(ActionEvent ae) {
121:                        d.setVisible(false);
122:                    }
123:                };
124:                JButton yes1 = new JButton("Yes");
125:                yes1.addActionListener(closeAction);
126:                fp.add(yes1);
127:                JButton yes2 = new JButton("Yes");
128:                yes2.addActionListener(closeAction);
129:                fp.add(yes2);
130:
131:                d.pack();
132:                d.setLocationRelativeTo(null);
133:                d.setVisible(true);
134:
135:            }
136:
137:            private static void pleaseWait() {
138:                final JDialog d = new JDialog((JFrame) null, "Please wait...",
139:                        true);
140:                JLabel lab = new JLabel(
141:                        "Please wait until the sun burns out...");
142:                lab.setBorder(new EmptyBorder(5, 5, 5, 5));
143:                d.add(lab, BorderLayout.NORTH);
144:
145:                JPanel cp = new JPanel(new BorderLayout(5, 5));
146:                d.add(cp, BorderLayout.CENTER);
147:                //      cp.setBorder(new EmptyBorder(5,5,5,5));
148:
149:                final JProgressBar pb = new JProgressBar();
150:                pb.setStringPainted(true);
151:                cp.add(pb, BorderLayout.CENTER);
152:                final java.util.Timer timer = new java.util.Timer();
153:                final Calendar c = GregorianCalendar.getInstance();
154:
155:                timer.scheduleAtFixedRate(new TimerTask() {
156:                    public void run() {
157:                        c.setTimeInMillis(System.currentTimeMillis());
158:
159:                        int ry = 2007 - c.get(Calendar.YEAR) + 999;
160:                        //int rm =   11 - c.get(Calendar.MONTH);
161:                        int rd = 366 - c.get(c.DAY_OF_YEAR);
162:                        int rh = 24 - c.get(Calendar.HOUR_OF_DAY);
163:                        int rm = 60 - c.get(Calendar.MINUTE);
164:                        int rs = 60 - c.get(Calendar.SECOND);
165:                        StringBuilder sb = new StringBuilder(
166:                                "   Remaining: 3'999'999'" + ry + " years, ");
167:                        sb.append("" + rd + " days, " + rh + " hours, ");
168:                        sb.append("" + rm + " minutes, " + rs + " seconds   ");
169:
170:                        pb.setString(sb.toString());
171:                    }
172:                }, 0L, 1000L);
173:
174:                JPanel fp = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
175:                d.add(fp, BorderLayout.SOUTH);
176:                ActionListener closeAction = new ActionListener() {
177:                    public void actionPerformed(ActionEvent ae) {
178:                        d.setVisible(false);
179:                    }
180:                };
181:
182:                JButton yes1 = new JButton("cancel");
183:                yes1.setMargin(new Insets(1, 0, 1, 0));
184:                yes1.addActionListener(closeAction);
185:                fp.add(yes1);
186:                yes1.setFocusPainted(false);
187:
188:                d.pack();
189:                d.setLocationRelativeTo(null);
190:                d.setVisible(true);
191:
192:                timer.cancel();
193:
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.