Source Code Cross Referenced for StartupDialog.java in  » Report » datavision-1.1.0 » jimm » datavision » gui » 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 » Report » datavision 1.1.0 » jimm.datavision.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.gui;
002:
003:        import jimm.util.I18N;
004:        import java.awt.*;
005:        import java.awt.event.*;
006:        import javax.swing.*;
007:        import java.io.File;
008:        import java.net.*;
009:        import java.util.prefs.Preferences;
010:
011:        /**
012:         * This class is called from the DataVision class when the designer is
013:         * started with no command line.  It is a startup dialog with the
014:         * DataVision splash screen and two buttons, one to create a new
015:         * report and one to open an existing report.
016:         *
017:         * @author Frank W. Zammetti, <a href="mailto:fzammetti@omnytex.com">fzammetti@omnytex.com</a>
018:         */
019:        public class StartupDialog extends JDialog implements  ActionListener {
020:
021:            /** This string is what is returned when we're creating a new report */
022:            public static final String NEW_REPORT_STRING = "*StartANewReport*";
023:
024:            /** The all-seeing eye. */
025:            protected static final String TITLE_IMAGE = "images/DVTitle.png";
026:
027:            // The two buttons
028:            private JButton newReport = new JButton(I18N
029:                    .get("StartupDialog.new"));
030:            private JButton existingReport = new JButton(I18N
031:                    .get("StartupDialog.open"));
032:            private JButton quit = new JButton(I18N.get("StartupDialog.quit"));
033:
034:            // The button for the title.  Am I just missing something or is there really
035:            // no Image widget, or something along those lines, for displaying an image
036:            // in Swing?  Do you really have to make it a button?!?
037:            private JButton titleImage = null;
038:
039:            // The result of this dialog.  Will either be null, meaning the dialog
040:            // was dismissed with the close button, the value of NEW_REPORT_STRING
041:            // if creating a new report, or the path to the selected file
042:            // (only one is selectable!)
043:            private String selectedFile = null;
044:
045:            /** Constructor for our class.  The dialog is built here. */
046:            public StartupDialog() {
047:                super ((Frame) null, I18N.get("StartupDialog.title"), true);
048:
049:                // Set it's size and resizability
050:                setResizable(false);
051:                setSize(580, 420);
052:
053:                // What to do when the close button is pressed (default didn't
054:                // work, I don't know why, so this had to be done explicitly)
055:                setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
056:                addWindowListener(new WindowAdapter() {
057:                    public void windowClosing(WindowEvent we) {
058:                        dispose();
059:                    }
060:                });
061:
062:                // Center it on the screen
063:                Toolkit kit = this .getToolkit();
064:                Dimension screenSize = kit.getScreenSize();
065:                int screenWidth = screenSize.width;
066:                int screenHeight = screenSize.height;
067:                Dimension windowSize = getSize();
068:                int windowWidth = windowSize.width;
069:                int windowHeight = windowSize.height;
070:                int upperLeftX = (screenWidth - windowWidth) / 2;
071:                int upperLeftY = (screenHeight - windowHeight) / 2;
072:                setLocation(upperLeftX, upperLeftY);
073:
074:                // Add it's content... first, the image
075:                URL url = getClass().getClassLoader().getResource(TITLE_IMAGE);
076:                Image img = Toolkit.getDefaultToolkit().getImage(url);
077:                JPanel p1 = new JPanel();
078:                titleImage = new JButton(new ImageIcon(img));
079:                titleImage.setBorderPainted(false);
080:                titleImage.setContentAreaFilled(false);
081:                titleImage.setFocusPainted(false);
082:                p1.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
083:                p1.add(titleImage);
084:                getContentPane().add("Center", p1);
085:
086:                // Now the two buttons, along with their event handlers...
087:                JPanel p2 = new JPanel();
088:                p2.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 10));
089:                newReport.addActionListener(this );
090:                p2.add(newReport);
091:                existingReport.addActionListener(this );
092:                p2.add(existingReport);
093:                quit.addActionListener(this );
094:                p2.add(quit);
095:                getContentPane().add("South", p2);
096:
097:                // Show it
098:                show();
099:
100:            } // End StartupDialog()
101:
102:            /** Callback to handle all user interactions */
103:            public void actionPerformed(ActionEvent ae) {
104:
105:                String ac = ae.getActionCommand();
106:
107:                // Set the starting report directory (null is default home directory)
108:                // Store the report directory in the preferences for this package
109:                Preferences prefs = Preferences.userRoot().node(
110:                        "/jimm/datavision");
111:                String reportDir = prefs.get("reportDir", null);
112:                System.out.println("reportDir(1) = " + reportDir);
113:
114:                // Open an existing report
115:                if (ac.equalsIgnoreCase(I18N.get("StartupDialog.open"))) {
116:                    JFileChooser jfc = new JFileChooser();
117:                    if (reportDir != null) {
118:                        jfc.setCurrentDirectory(new File(reportDir));
119:                    }
120:                    jfc.setMultiSelectionEnabled(false);
121:                    int rv = jfc.showOpenDialog(this );
122:                    if (rv == JFileChooser.APPROVE_OPTION) {
123:                        selectedFile = jfc.getSelectedFile().getPath();
124:                        // If the file path has changed then store it in the preferences
125:                        String jfcap = jfc.getSelectedFile().getAbsolutePath();
126:                        if (jfcap != null) {
127:                            File f = new File(jfcap);
128:                            String newReportDir = f.getParent();
129:                            if (newReportDir == null) {
130:                                newReportDir = reportDir;
131:                            }
132:                            if (newReportDir != null) {
133:                                boolean changed = true;
134:                                if (reportDir != null
135:                                        && newReportDir.compareTo(reportDir) == 0) {
136:                                    changed = false;
137:                                }
138:                                if (changed) {
139:                                    prefs.put("reportDir", newReportDir);
140:                                }
141:                            }
142:                        }
143:                        dispose();
144:                    }
145:
146:                    // Start a new report
147:                } else if (ac.equalsIgnoreCase(I18N.get("StartupDialog.new"))) {
148:                    selectedFile = NEW_REPORT_STRING;
149:                    dispose();
150:
151:                    // Quit
152:                } else if (ac.equalsIgnoreCase(I18N.get("StartupDialog.quit"))) {
153:                    dispose();
154:                    System.exit(0);
155:                }
156:
157:            } // End actionPerformed()
158:
159:            /** Method to return the selected File object. */
160:            public String getSelectedFile() {
161:                return selectedFile;
162:            } // End getSelectedFile()
163:
164:        } // End Class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.