Source Code Cross Referenced for OptionDialog.java in  » XML-UI » xui32 » com » xoetrope » editor » netbeans » actions » 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 » XML UI » xui32 » com.xoetrope.editor.netbeans.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.editor.netbeans.actions;
002:
003:        import java.util.ArrayList;
004:
005:        import java.awt.BorderLayout;
006:        import java.awt.Container;
007:        import java.awt.Dimension;
008:        import java.awt.GridLayout;
009:        import java.awt.HeadlessException;
010:        import java.awt.event.ActionEvent;
011:        import java.awt.event.ActionListener;
012:        import javax.swing.BorderFactory;
013:        import javax.swing.Box;
014:        import javax.swing.BoxLayout;
015:        import javax.swing.JButton;
016:        import javax.swing.JComboBox;
017:        import javax.swing.JDialog;
018:        import javax.swing.JFrame;
019:        import javax.swing.JLabel;
020:        import javax.swing.JPanel;
021:        import javax.swing.JTextField;
022:
023:        /**
024:         * A dialog for presentation of options. Ok and Cancel buttons are automatically
025:         * added.
026:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
027:         * the GNU Public License (GPL), please see license.txt for more details. If
028:         * you make commercial use of this software you must purchase a commercial
029:         * license from Xoetrope.</p>
030:         * <p> $Revision: 1.3 $</p>
031:         */
032:        public class OptionDialog extends JDialog implements  ActionListener {
033:            public static final int TEXT_INPUT = 0;
034:            public static final int NUMBER_INPUT = 1;
035:            public static final int LIST_INPUT = 2;
036:
037:            public static final int ID_OK = 0;
038:            public static final int ID_CANCEL = 1;
039:
040:            private JPanel contentPanel;
041:            private JButton cancelBtn, okBtn;
042:            private ArrayList options;
043:            private int status = ID_CANCEL;
044:
045:            /**
046:             * Create a new option dialog
047:             * @param frame the parent frame
048:             * @param title the dialog title
049:             * @throws HeadlessException
050:             */
051:            public OptionDialog(JFrame frame, String title)
052:                    throws HeadlessException {
053:                super (frame, title, true);
054:
055:                options = new ArrayList();
056:                Container contentPane = getContentPane();
057:                contentPane.setLayout(new BorderLayout());
058:
059:                contentPanel = new JPanel();
060:                contentPanel.setLayout(new GridLayout(0, 2, 2, 2));
061:                contentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10,
062:                        10, 10));
063:                contentPanel.setMinimumSize(new Dimension(210, 40));
064:                contentPane.add(contentPanel, BorderLayout.CENTER);
065:
066:                JPanel buttonPanel = new JPanel();
067:                buttonPanel.setLayout(new BoxLayout(buttonPanel,
068:                        BoxLayout.LINE_AXIS));
069:                buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10,
070:                        10, 10));
071:                buttonPanel.add(Box.createHorizontalGlue());
072:                buttonPanel.add(cancelBtn = new JButton("Cancel"));
073:                buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
074:                buttonPanel.add(okBtn = new JButton("OK"));
075:
076:                cancelBtn.addActionListener(this );
077:                okBtn.addActionListener(this );
078:
079:                contentPane.add(buttonPanel, BorderLayout.PAGE_END);
080:            }
081:
082:            /**
083:             * Respond to the button clicks and dismiss
084:             * the dialog once the state has been set
085:             * @param e
086:             */
087:            public void actionPerformed(ActionEvent e) {
088:                if (e.getSource() == okBtn)
089:                    status = ID_OK;
090:                else
091:                    status = ID_CANCEL;
092:
093:                setVisible(false);
094:            }
095:
096:            /**
097:             * Get the state following dismissal of the dialog
098:             * @return
099:             */
100:            public int getStatus() {
101:                return status;
102:            }
103:
104:            /**
105:             * Add an option
106:             * @param optionType the type of the option, controls the input control type
107:             * @param caption the caption for this option
108:             * @param initialValue the initial value if any
109:             */
110:            public void addOption(int optionType, String caption,
111:                    String initialValue) {
112:                addOption(optionType, caption, initialValue, null);
113:            }
114:
115:            /**
116:             * Add an option
117:             * @param optionType the type of the option, controls the input control type
118:             * @param caption the caption for this option
119:             * @param initialValue the initial value if any
120:             * @param choices he list options
121:             */
122:            public void addOption(int optionType, String caption,
123:                    String initialValue, String[] choices) {
124:                if ((optionType == TEXT_INPUT) || (optionType == NUMBER_INPUT)) {
125:                    JTextField option = new JTextField(initialValue);
126:                    contentPanel.add(new JLabel(caption));
127:                    contentPanel.add(option);
128:                    options.add(option);
129:                } else if (optionType == LIST_INPUT) {
130:                    JComboBox option = new JComboBox(choices);
131:                    contentPanel.add(new JLabel(caption));
132:                    contentPanel.add(option);
133:                    option.setSelectedItem(initialValue);
134:                    options.add(option);
135:                }
136:            }
137:
138:            /**
139:             * Get the input or selected value for the object
140:             * @param idx the index of the object
141:             * @return the value as a string
142:             */
143:            public String getOption(int idx) {
144:                return ((JTextField) options.get(idx)).getText();
145:            }
146:
147:            /**
148:             * Display the dialog
149:             */
150:            public void setVisible(boolean state) {
151:                if (state) {
152:                    contentPanel.doLayout();
153:                    pack();
154:                }
155:                super.setVisible(state);
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.