Source Code Cross Referenced for SplitTab.java in  » Swing-Library » jgoodies-looks » com » jgoodies » looks » demo » 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 » jgoodies looks » com.jgoodies.looks.demo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001-2007 JGoodies Karsten Lentzsch. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:
031:        package com.jgoodies.looks.demo;
032:
033:        import java.awt.BorderLayout;
034:        import java.awt.Dimension;
035:
036:        import javax.swing.*;
037:        import javax.swing.table.AbstractTableModel;
038:        import javax.swing.table.TableModel;
039:        import javax.swing.tree.DefaultMutableTreeNode;
040:        import javax.swing.tree.DefaultTreeModel;
041:        import javax.swing.tree.TreeModel;
042:
043:        import com.jgoodies.forms.factories.Borders;
044:        import com.jgoodies.looks.LookUtils;
045:        import com.jgoodies.uif_lite.component.UIFSplitPane;
046:
047:        /** 
048:         * Contains nested split panels and demonstrates how ClearLook
049:         * removes obsolete decorations.
050:         * 
051:         * @author Karsten Lentzsch
052:         * @version $Revision: 1.5 $
053:         * 
054:         * @see UIFSplitPane
055:         */
056:        final class SplitTab {
057:
058:            /**
059:             * Builds and returns the panel.
060:             */
061:            JComponent build() {
062:                JPanel panel = new JPanel(new BorderLayout());
063:                panel.setOpaque(false);
064:                panel.setBorder(Borders.DIALOG_BORDER);
065:                panel.add(buildHorizontalSplit());
066:                return panel;
067:            }
068:
069:            /**
070:             * Builds and returns the horizontal split using stripped split panes.<p>
071:             * 
072:             * Nesting split panes often leads to duplicate borders. 
073:             * However, a look&feel should not remove borders completely
074:             * - unless he has good knowledge about the context: the surrounding 
075:             * components in the component tree and the border states.
076:             */
077:            private JComponent buildHorizontalSplit() {
078:                JComponent left = new JScrollPane(buildTree());
079:                left.setPreferredSize(new Dimension(200, 100));
080:
081:                JComponent upperRight = new JScrollPane(buildTextArea());
082:                upperRight.setPreferredSize(new Dimension(100, 100));
083:
084:                JComponent lowerRight = new JScrollPane(buildTable());
085:                lowerRight.setPreferredSize(new Dimension(100, 100));
086:
087:                JSplitPane verticalSplit = UIFSplitPane
088:                        .createStrippedSplitPane(JSplitPane.VERTICAL_SPLIT,
089:                                upperRight, lowerRight);
090:                verticalSplit.setOpaque(false);
091:                JSplitPane horizontalSplit = UIFSplitPane
092:                        .createStrippedSplitPane(JSplitPane.HORIZONTAL_SPLIT,
093:                                left, verticalSplit);
094:                horizontalSplit.setOpaque(false);
095:                return horizontalSplit;
096:            }
097:
098:            /**
099:             * Builds and returns a sample tree.
100:             */
101:            private JTree buildTree() {
102:                JTree tree = new JTree(createSampleTreeModel());
103:                tree.expandRow(3);
104:                tree.expandRow(2);
105:                tree.expandRow(1);
106:                return tree;
107:            }
108:
109:            /**
110:             * Builds and returns a sample text area.
111:             */
112:            private JTextArea buildTextArea() {
113:                JTextArea area = new JTextArea();
114:                area
115:                        .setText("May\nI\nKindly\nRemind you that a\nMargin\nImproves a text's readability.");
116:                return area;
117:            }
118:
119:            /**
120:             * Builds and returns a sample table.
121:             */
122:            private JTable buildTable() {
123:                TableModel model = new SampleTableModel(
124:                        createSampleTableData(), new String[] { "Artist",
125:                                "Title      ", "Free" });
126:                JTable table = new JTable(model);
127:
128:                table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
129:                table.getColumnModel().getColumn(0).setPreferredWidth(100);
130:                table.getColumnModel().getColumn(1).setPreferredWidth(250);
131:                table.getColumnModel().getColumn(2).setPreferredWidth(50);
132:                table.setRowSelectionInterval(2, 2);
133:                int tableFontSize = table.getFont().getSize();
134:                int minimumRowHeight = tableFontSize + 6;
135:                int defaultRowHeight = LookUtils.IS_LOW_RESOLUTION ? 17 : 18;
136:                table
137:                        .setRowHeight(Math.max(minimumRowHeight,
138:                                defaultRowHeight));
139:                return table;
140:            }
141:
142:            /**
143:             * Creates and returns a sample tree model.
144:             */
145:            private TreeModel createSampleTreeModel() {
146:                DefaultMutableTreeNode root = new DefaultMutableTreeNode(
147:                        "Musicians");
148:                DefaultMutableTreeNode parent;
149:
150:                //
151:                parent = new DefaultMutableTreeNode("Drums");
152:                root.add(parent);
153:                parent.add(new DefaultMutableTreeNode("Elvin Jones"));
154:                parent.add(new DefaultMutableTreeNode("Jack DeJohnette"));
155:                parent.add(new DefaultMutableTreeNode("Rashied Ali"));
156:
157:                //
158:                parent = new DefaultMutableTreeNode("Piano");
159:                root.add(parent);
160:                parent.add(new DefaultMutableTreeNode(
161:                        "Alexander von Schlippenbach"));
162:                parent.add(new DefaultMutableTreeNode("McCoy Tyner"));
163:                parent.add(new DefaultMutableTreeNode("Sun Ra"));
164:
165:                parent = new DefaultMutableTreeNode("Saxophon");
166:                root.add(parent);
167:                parent.add(new DefaultMutableTreeNode("Albert Ayler"));
168:                parent.add(new DefaultMutableTreeNode("Archie Shepp"));
169:                parent.add(new DefaultMutableTreeNode("Charlie Parker"));
170:                parent.add(new DefaultMutableTreeNode("John Coltrane"));
171:                parent.add(new DefaultMutableTreeNode("Ornette Coleman"));
172:                parent.add(new DefaultMutableTreeNode("Pharoa Sanders"));
173:                parent.add(new DefaultMutableTreeNode("Sonny Rollins"));
174:
175:                return new DefaultTreeModel(root);
176:            }
177:
178:            /**
179:             * Creates and returns sample table data.
180:             */
181:            private Object[][] createSampleTableData() {
182:                return new Object[][] {
183:                        { "Albert Ayler", "Greenwich Village", Boolean.TRUE },
184:                        { "Carla Bley", "Escalator Over the Hill", Boolean.TRUE },
185:                        { "Frank Zappa", "Yo' Mama", Boolean.TRUE },
186:                        { "John Coltrane", "Ascension", Boolean.TRUE },
187:                        { "Miles Davis", "In a Silent Way", Boolean.TRUE },
188:                        { "Pharoa Sanders", "Karma", Boolean.TRUE },
189:                        { "Wayne Shorter", "Juju", Boolean.TRUE },
190:                        { "", "", Boolean.FALSE }, { "", "", Boolean.FALSE },
191:                        { "", "", Boolean.FALSE }, { "", "", Boolean.FALSE },
192:                        { "", "", Boolean.FALSE }, { "", "", Boolean.FALSE },
193:                        { "", "", Boolean.FALSE }, { "", "", Boolean.FALSE },
194:                        { "", "", Boolean.FALSE }, };
195:            }
196:
197:            private static final class SampleTableModel extends
198:                    AbstractTableModel {
199:
200:                private final String[] columnNames;
201:                private final Object[][] rowData;
202:
203:                SampleTableModel(Object[][] rowData, String[] columnNames) {
204:                    this .columnNames = columnNames;
205:                    this .rowData = rowData;
206:                }
207:
208:                public String getColumnName(int column) {
209:                    return columnNames[column].toString();
210:                }
211:
212:                public int getRowCount() {
213:                    return rowData.length;
214:                }
215:
216:                public int getColumnCount() {
217:                    return columnNames.length;
218:                }
219:
220:                public Class getColumnClass(int column) {
221:                    return column == 2 ? Boolean.class : super 
222:                            .getColumnClass(column);
223:                }
224:
225:                public Object getValueAt(int row, int col) {
226:                    return rowData[row][col];
227:                }
228:
229:                public boolean isCellEditable(int row, int column) {
230:                    return true;
231:                }
232:
233:                public void setValueAt(Object value, int row, int col) {
234:                    rowData[row][col] = value;
235:                    fireTableCellUpdated(row, col);
236:                }
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.