Source Code Cross Referenced for ScrollableDialog.java in  » IDE » DrJava » edu » rice » cs » util » swing » 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 » DrJava » edu.rice.cs.util.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*BEGIN_COPYRIGHT_BLOCK
002:         *
003:         * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
004:         * All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are met:
008:         *    * Redistributions of source code must retain the above copyright
009:         *      notice, this list of conditions and the following disclaimer.
010:         *    * Redistributions in binary form must reproduce the above copyright
011:         *      notice, this list of conditions and the following disclaimer in the
012:         *      documentation and/or other materials provided with the distribution.
013:         *    * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
014:         *      names of its contributors may be used to endorse or promote products
015:         *      derived from this software without specific prior written permission.
016:         * 
017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
021:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
022:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
023:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028:         *
029:         * This software is Open Source Initiative approved Open Source Software.
030:         * Open Source Initative Approved is a trademark of the Open Source Initiative.
031:         * 
032:         * This file is part of DrJava.  Download the current version of this project
033:         * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
034:         * 
035:         * END_COPYRIGHT_BLOCK*/
036:
037:        package edu.rice.cs.util.swing;
038:
039:        import edu.rice.cs.drjava.ui.MainFrame;
040:        import java.awt.*;
041:        import java.awt.event.*;
042:        import javax.swing.*;
043:        import javax.swing.border.*;
044:        import java.io.Serializable;
045:
046:        /**
047:         * Manages a JDialog with a scrollable text area and a button panel.
048:         * @version $Id: ScrollableDialog.java 4255 2007-08-28 19:17:37Z mgricken $
049:         */
050:        public class ScrollableDialog implements  Serializable {
051:            /** Default width for all ScrollableDialogs. */
052:            public static final int DEFAULT_WIDTH = 500;
053:            /** Default height for all ScrollableDialogs. */
054:            public static final int DEFAULT_HEIGHT = 400;
055:            /** JDialog managed by this component. */
056:            protected JDialog _dialog;
057:            /** JTextArea contained in a scroll pane in this dialog. */
058:            protected JTextArea _textArea;
059:            /** Panel of buttons at the bottom of this dialog. */
060:            protected JPanel _buttonPanel;
061:
062:            /**
063:             * Creates a new ScrollableDialog with the default width and height.
064:             * @param parent Parent frame for this dialog
065:             * @param title Title for this dialog
066:             * @param header Message to display at the top of this dialog
067:             * @param text Text to insert into the scrollable JTextArea
068:             */
069:            public ScrollableDialog(JFrame parent, String title, String header,
070:                    String text) {
071:                this (parent, title, header, text, DEFAULT_WIDTH, DEFAULT_HEIGHT);
072:            }
073:
074:            /**
075:             * Creates a new ScrollableDialog.
076:             * @param parent Parent frame for this dialog
077:             * @param title Title for this dialog
078:             * @param header Message to display at the top of this dialog
079:             * @param text Text to insert into the scrollable JTextArea
080:             * @param width Width for this dialog
081:             * @param height Height for this dialog
082:             */
083:            public ScrollableDialog(JFrame parent, String title, String header,
084:                    String text, int width, int height) {
085:                _dialog = new JDialog(parent, title, true);
086:                Container content = _dialog.getContentPane();
087:
088:                content.setLayout(new BorderLayout());
089:
090:                // Create the text area
091:                _textArea = new JTextArea();
092:                _textArea.setEditable(false);
093:                _textArea.setText(text);
094:
095:                // Arrange the dialog
096:                _dialog.setSize(width, height);
097:
098:                // Add components
099:                JScrollPane textScroll = new BorderlessScrollPane(_textArea,
100:                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
101:                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
102:                JPanel scrollWrapper = new JPanel(new BorderLayout(0, 5));
103:                scrollWrapper.setBorder(new EmptyBorder(5, 5, 0, 5));
104:                scrollWrapper.add(new JLabel(header), BorderLayout.NORTH);
105:                scrollWrapper.add(textScroll, BorderLayout.CENTER);
106:                JPanel bottomPanel = new JPanel(new BorderLayout());
107:                _buttonPanel = new JPanel(new GridLayout(1, 0, 5, 5));
108:                bottomPanel.add(_buttonPanel, BorderLayout.EAST);
109:                bottomPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
110:                _addButtons();
111:
112:                content.add(scrollWrapper, BorderLayout.CENTER);
113:                content.add(bottomPanel, BorderLayout.SOUTH);
114:
115:                // This method is deprecated.  There are alternatives, but it is
116:                // probably best to let defer to the standard focus-management
117:                // policy rather than trying to customize it.
118:                //_textArea.requestDefaultFocus();
119:            }
120:
121:            /**
122:             * Adds buttons to this dialog's button panel.
123:             * Subclasses can override this to add different buttons.
124:             */
125:            protected void _addButtons() {
126:                _buttonPanel.add(new JButton(_okAction));
127:            }
128:
129:            /** A default "OK" action which disposes this dialog when invoked.
130:             */
131:            private Action _okAction = new AbstractAction("OK") {
132:                public void actionPerformed(ActionEvent e) {
133:                    _dialog.dispose();
134:                }
135:            };
136:
137:            /**
138:             * Sets the font for the text area in this dialog.
139:             * @param f New font for the text
140:             */
141:            public void setTextFont(Font f) {
142:                _textArea.setFont(f);
143:            }
144:
145:            /** Shows this dialog. */
146:            public void show() {
147:                MainFrame.setPopupLoc(_dialog, _dialog.getOwner());
148:                _dialog.setVisible(true);
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.