Source Code Cross Referenced for TabbedPaneExample.java in  » Swing-Library » wings3 » wingset » 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 » wings3 » wingset 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package wingset;
014:
015:        import org.wings.SBorderLayout;
016:        import org.wings.SButton;
017:        import org.wings.SComboBox;
018:        import org.wings.SComponent;
019:        import org.wings.SConstants;
020:        import org.wings.SDimension;
021:        import org.wings.SLabel;
022:        import org.wings.SPanel;
023:        import org.wings.STabbedPane;
024:        import org.wings.STextArea;
025:        import org.wings.style.CSSProperty;
026:        import org.wings.style.CSSStyleSheet;
027:        import org.wings.text.DefaultDocument;
028:        import org.wings.text.SDocument;
029:
030:        import javax.swing.event.ChangeEvent;
031:        import javax.swing.event.ChangeListener;
032:        import java.awt.*;
033:        import java.awt.event.ActionEvent;
034:
035:        /**
036:         * Example for STabbedPane.
037:         *
038:         * @author <a href="mailto:andre@lison.de">Andre Lison</a>
039:         * @author <a href="mailto:B.Schmid@eXXcellent.de">Benjamin Schmid</a>
040:         */
041:        public class TabbedPaneExample extends WingSetPane {
042:            private final static int INITIAL_TAB_COUNT = 10;
043:            private final static Object[] TAB_PLACEMENTS = new Object[] {
044:                    new Object[] { "Top", new Integer(SConstants.TOP) },
045:                    new Object[] { "Left", new Integer(SConstants.LEFT) },
046:                    new Object[] { "Right", new Integer(SConstants.RIGHT) },
047:                    new Object[] { "Bottom", new Integer(SConstants.BOTTOM) } };
048:            private TabbedPaneControls controls;
049:            private STabbedPane tabbedPane;
050:            private SDocument logText = new DefaultDocument();
051:
052:            protected SComponent createControls() {
053:                controls = new TabbedPaneControls();
054:                return controls;
055:            }
056:
057:            protected SComponent createExample() {
058:
059:                // Create tabbed pane and tabulators
060:                tabbedPane = new STabbedPane();
061:                tabbedPane.setPreferredSize(new SDimension("700px", null));
062:                for (int i = 0; i < INITIAL_TAB_COUNT; ++i) {
063:                    addTab();
064:                }
065:                tabbedPane.setShowAsFormComponent(false);
066:                tabbedPane.setEnabledAt(1, false); // disable a tab
067:                tabbedPane.addChangeListener(new ChangeListener() {
068:                    public void stateChanged(ChangeEvent ce) {
069:                        logText.setText(logText.getText() + "Changed to tab: "
070:                                + tabbedPane.getSelectedIndex() + "\n");
071:                    }
072:                });
073:                controls.addControllable(tabbedPane);
074:
075:                SPanel panel = new SPanel(new SBorderLayout(10, 10));
076:                panel.add(tabbedPane);
077:                return panel;
078:            }
079:
080:            protected void addTab() {
081:                int i = tabbedPane.getTabCount();
082:                SPanel panel = new SPanel(new SBorderLayout(10, 10));
083:                STextArea textArea = new STextArea(logText, null, 6, 60);
084:                textArea.setPreferredSize(SDimension.FULLWIDTH);
085:                panel.add(new SLabel("Tab # " + i), SBorderLayout.NORTH);
086:                panel.add(textArea, SBorderLayout.CENTER);
087:                tabbedPane.add("Tab " + i, panel);
088:            }
089:
090:            /**
091:             * Extended component control for this wingset demo.
092:             */
093:            private class TabbedPaneControls extends ComponentControls {
094:                private int tabCount = INITIAL_TAB_COUNT;
095:
096:                public TabbedPaneControls() {
097:                    widthTextField.setText("700px");
098:                    final SComboBox placement = new SComboBox(TAB_PLACEMENTS);
099:                    placement
100:                            .addActionListener(new java.awt.event.ActionListener() {
101:                                public void actionPerformed(ActionEvent e) {
102:                                    Object[] objects = (Object[]) placement
103:                                            .getSelectedItem();
104:                                    Integer integer = (Integer) objects[1];
105:                                    tabbedPane.setTabPlacement(integer
106:                                            .intValue());
107:                                }
108:                            });
109:                    placement.setRenderer(new ObjectPairCellRenderer());
110:                    addControl(new SLabel(" tab placement"));
111:                    addControl(placement);
112:
113:                    final SComboBox unselectedTabColor = new SComboBox(COLORS);
114:                    unselectedTabColor
115:                            .addActionListener(new java.awt.event.ActionListener() {
116:                                public void actionPerformed(ActionEvent e) {
117:                                    Color color = (Color) ((Object[]) unselectedTabColor
118:                                            .getSelectedItem())[1];
119:                                    tabbedPane
120:                                            .setAttribute(
121:                                                    STabbedPane.SELECTOR_UNSELECTED_TAB,
122:                                                    CSSProperty.BACKGROUND_COLOR,
123:                                                    CSSStyleSheet
124:                                                            .getAttribute(color));
125:                                }
126:                            });
127:                    unselectedTabColor
128:                            .setRenderer(new ObjectPairCellRenderer());
129:                    addControl(new SLabel(" unselected tab"));
130:                    addControl(unselectedTabColor);
131:
132:                    final SComboBox selectedTabColor = new SComboBox(COLORS);
133:                    selectedTabColor
134:                            .addActionListener(new java.awt.event.ActionListener() {
135:                                public void actionPerformed(ActionEvent e) {
136:                                    Color color = (Color) ((Object[]) selectedTabColor
137:                                            .getSelectedItem())[1];
138:                                    tabbedPane.setAttribute(
139:                                            STabbedPane.SELECTOR_SELECTED_TAB,
140:                                            CSSProperty.BACKGROUND_COLOR,
141:                                            CSSStyleSheet.getAttribute(color));
142:                                }
143:                            });
144:                    selectedTabColor.setRenderer(new ObjectPairCellRenderer());
145:                    addControl(new SLabel(" selected tab"));
146:                    addControl(selectedTabColor);
147:
148:                    final SComboBox disabledTabColor = new SComboBox(COLORS);
149:                    disabledTabColor
150:                            .addActionListener(new java.awt.event.ActionListener() {
151:                                public void actionPerformed(ActionEvent e) {
152:                                    Color color = (Color) ((Object[]) disabledTabColor
153:                                            .getSelectedItem())[1];
154:                                    tabbedPane.setAttribute(
155:                                            STabbedPane.SELECTOR_DISABLED_TAB,
156:                                            CSSProperty.BACKGROUND_COLOR,
157:                                            CSSStyleSheet.getAttribute(color));
158:                                }
159:                            });
160:                    disabledTabColor.setRenderer(new ObjectPairCellRenderer());
161:                    addControl(new SLabel(" disabled tab"));
162:                    addControl(disabledTabColor);
163:
164:                    final SComboBox contentColor = new SComboBox(COLORS);
165:                    contentColor
166:                            .addActionListener(new java.awt.event.ActionListener() {
167:                                public void actionPerformed(ActionEvent e) {
168:                                    Color color = (Color) ((Object[]) contentColor
169:                                            .getSelectedItem())[1];
170:                                    tabbedPane.setAttribute(
171:                                            STabbedPane.SELECTOR_CONTENT,
172:                                            CSSProperty.BACKGROUND_COLOR,
173:                                            CSSStyleSheet.getAttribute(color));
174:                                }
175:                            });
176:                    contentColor.setRenderer(new ObjectPairCellRenderer());
177:                    addControl(new SLabel(" content"));
178:                    addControl(contentColor);
179:
180:                    final SButton addTab = new SButton("add new tab");
181:                    addTab
182:                            .addActionListener(new java.awt.event.ActionListener() {
183:                                public void actionPerformed(ActionEvent e) {
184:                                    addTab();
185:                                }
186:                            });
187:                    addControl(addTab);
188:
189:                    final SButton removeTab = new SButton("remove selected tab");
190:                    removeTab
191:                            .addActionListener(new java.awt.event.ActionListener() {
192:                                public void actionPerformed(ActionEvent e) {
193:                                    removeTab();
194:                                }
195:                            });
196:                    addControl(removeTab);
197:                }
198:
199:                protected void removeTab() {
200:                    int index = tabbedPane.getSelectedIndex();
201:                    if (index != -1) {
202:                        tabCount--;
203:                        tabbedPane.removeTabAt(index);
204:                    }
205:                }
206:
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.