Source Code Cross Referenced for ScrollPaneExample.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.*;
016:
017:        import javax.swing.tree.DefaultTreeModel;
018:        import java.awt.event.ActionEvent;
019:        import java.awt.event.ActionListener;
020:
021:        /**
022:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
023:         */
024:        public class ScrollPaneExample extends WingSetPane {
025:            private ScrollPaneControls controls;
026:            private STable table;
027:            private STree tree;
028:            private SList list;
029:            private SScrollPane scrollPane;
030:
031:            protected SComponent createControls() {
032:                controls = new ScrollPaneControls();
033:                return controls;
034:            }
035:
036:            public SComponent createExample() {
037:                table = new STable(new TableExample.ROTableModel(15, 42));
038:                table.setDefaultRenderer(new TableExample.MyCellRenderer());
039:
040:                tree = new STree(new DefaultTreeModel(HugeTreeModel.ROOT_NODE));
041:
042:                list = createTestList(42);
043:
044:                scrollPane = new SScrollPane(table);
045:                scrollPane.setHorizontalExtent(10);
046:                scrollPane.setVerticalExtent(20);
047:                scrollPane.getHorizontalScrollBar().setBlockIncrement(3);
048:                scrollPane.getVerticalScrollBar().setBlockIncrement(3);
049:                scrollPane.setVerticalAlignment(SConstants.TOP_ALIGN);
050:                scrollPane.setPreferredSize(SDimension.FULLAREA);
051:
052:                controls.addControllable(scrollPane);
053:                return scrollPane;
054:            }
055:
056:            protected void showInPane(SComponent comp) {
057:                scrollPane.setViewportView(comp);
058:            }
059:
060:            class ScrollPaneControls extends ComponentControls {
061:                public ScrollPaneControls() {
062:                    String[] scrollables = { "table", "tree", "list" };
063:                    final SComboBox scrollable = new SComboBox(scrollables);
064:                    scrollable.addActionListener(new ActionListener() {
065:                        public void actionPerformed(ActionEvent e) {
066:                            int newScrollable = scrollable.getSelectedIndex();
067:                            switch (newScrollable) {
068:                            case 0:
069:                                showInPane(table);
070:                                break;
071:                            case 1:
072:                                showInPane(tree);
073:                                break;
074:                            case 2:
075:                                showInPane(list);
076:                                break;
077:                            }
078:                        }
079:                    });
080:
081:                    String[] scrollpaneModes = { "scrolling", "complete",
082:                            "paging" };
083:                    final SComboBox mode = new SComboBox(scrollpaneModes);
084:                    mode.addActionListener(new ActionListener() {
085:                        public void actionPerformed(ActionEvent e) {
086:                            scrollPane.setMode(mode.getSelectedIndex());
087:                            scrollPane.setPreferredSize(SDimension.FULLAREA);
088:                            widthTextField.setText("100%");
089:                            heightTextField.setText("100%");
090:                        }
091:                    });
092:
093:                    Integer[] horizontalExtents = { new Integer(5),
094:                            new Integer(10), new Integer(15) };
095:                    final SComboBox hScrollpaneExtent = new SComboBox(
096:                            horizontalExtents);
097:                    hScrollpaneExtent.setSelectedIndex(1);
098:                    hScrollpaneExtent.addActionListener(new ActionListener() {
099:                        public void actionPerformed(ActionEvent e) {
100:                            int extent = ((Integer) hScrollpaneExtent
101:                                    .getSelectedItem()).intValue();
102:                            scrollPane.setHorizontalExtent(extent);
103:                        }
104:                    });
105:
106:                    Integer[] verticalExtents = { new Integer(10),
107:                            new Integer(15), new Integer(20) };
108:                    final SComboBox vScrollpaneExtent = new SComboBox(
109:                            verticalExtents);
110:                    vScrollpaneExtent.setSelectedIndex(2);
111:                    vScrollpaneExtent.addActionListener(new ActionListener() {
112:                        public void actionPerformed(ActionEvent e) {
113:                            int extent = ((Integer) vScrollpaneExtent
114:                                    .getSelectedItem()).intValue();
115:                            scrollPane.setVerticalExtent(extent);
116:                        }
117:                    });
118:
119:                    final SPageScroller horizontalPageScrollerH = new SPageScroller(
120:                            SPageScroller.HORIZONTAL);
121:                    horizontalPageScrollerH
122:                            .setLayoutMode(SPageScroller.HORIZONTAL);
123:                    final SPageScroller horizontalPageScrollerV = new SPageScroller(
124:                            SPageScroller.VERTICAL);
125:                    horizontalPageScrollerV
126:                            .setLayoutMode(SPageScroller.HORIZONTAL);
127:                    String[] horizontalScrollBars = { "normal", "page (H)",
128:                            "page (V)", "null" };
129:                    final SComboBox hScrollBar = new SComboBox(
130:                            horizontalScrollBars);
131:                    hScrollBar.addActionListener(new ActionListener() {
132:                        public void actionPerformed(ActionEvent e) {
133:                            int newScrollbar = hScrollBar.getSelectedIndex();
134:                            switch (newScrollbar) {
135:                            case 0:
136:                                scrollPane
137:                                        .setHorizontalScrollBar(new SScrollBar(
138:                                                SScrollBar.HORIZONTAL));
139:                                break;
140:                            case 1:
141:                                scrollPane
142:                                        .setHorizontalScrollBar(horizontalPageScrollerH);
143:                                break;
144:                            case 2:
145:                                scrollPane
146:                                        .setHorizontalScrollBar(horizontalPageScrollerV);
147:                                break;
148:                            case 3:
149:                                scrollPane.setHorizontalScrollBar(null);
150:                                break;
151:                            }
152:                        }
153:                    });
154:
155:                    final SPageScroller verticalPageScrollerH = new SPageScroller(
156:                            SPageScroller.HORIZONTAL);
157:                    verticalPageScrollerH.setLayoutMode(SPageScroller.VERTICAL);
158:                    final SPageScroller verticalPageScrollerV = new SPageScroller(
159:                            SPageScroller.VERTICAL);
160:                    verticalPageScrollerV.setLayoutMode(SPageScroller.VERTICAL);
161:                    String[] verticalScrollBars = { "normal", "page (H)",
162:                            "page (V)", "null" };
163:                    final SComboBox vScrollBar = new SComboBox(
164:                            verticalScrollBars);
165:                    vScrollBar.addActionListener(new ActionListener() {
166:                        public void actionPerformed(ActionEvent e) {
167:                            int newScrollbar = vScrollBar.getSelectedIndex();
168:                            switch (newScrollbar) {
169:                            case 0:
170:                                scrollPane.setVerticalScrollBar(new SScrollBar(
171:                                        SScrollBar.VERTICAL));
172:                                break;
173:                            case 1:
174:                                scrollPane
175:                                        .setVerticalScrollBar(verticalPageScrollerH);
176:                                break;
177:                            case 2:
178:                                scrollPane
179:                                        .setVerticalScrollBar(verticalPageScrollerV);
180:                                break;
181:                            case 3:
182:                                scrollPane.setVerticalScrollBar(null);
183:                                break;
184:                            }
185:                        }
186:                    });
187:
188:                    String[] horizontalPolicies = { "as needed", "always",
189:                            "never" };
190:                    final SComboBox hScrollBarPolicy = new SComboBox(
191:                            horizontalPolicies);
192:                    hScrollBarPolicy.addActionListener(new ActionListener() {
193:                        public void actionPerformed(ActionEvent e) {
194:                            int newPolicy = hScrollBarPolicy.getSelectedIndex();
195:                            switch (newPolicy) {
196:                            case 0:
197:                                scrollPane
198:                                        .setHorizontalScrollBarPolicy(SScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
199:                                break;
200:                            case 1:
201:                                scrollPane
202:                                        .setHorizontalScrollBarPolicy(SScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
203:                                break;
204:                            case 2:
205:                                scrollPane
206:                                        .setHorizontalScrollBarPolicy(SScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
207:                                break;
208:                            }
209:                        }
210:                    });
211:
212:                    String[] verticalPolicies = { "as needed", "always",
213:                            "never" };
214:                    final SComboBox vScrollBarPolicy = new SComboBox(
215:                            verticalPolicies);
216:                    vScrollBarPolicy.addActionListener(new ActionListener() {
217:                        public void actionPerformed(ActionEvent e) {
218:                            int newPolicy = vScrollBarPolicy.getSelectedIndex();
219:                            switch (newPolicy) {
220:                            case 0:
221:                                scrollPane
222:                                        .setVerticalScrollBarPolicy(SScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
223:                                break;
224:                            case 1:
225:                                scrollPane
226:                                        .setVerticalScrollBarPolicy(SScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
227:                                break;
228:                            case 2:
229:                                scrollPane
230:                                        .setVerticalScrollBarPolicy(SScrollPane.VERTICAL_SCROLLBAR_NEVER);
231:                                break;
232:                            }
233:                        }
234:                    });
235:
236:                    addControl(new SLabel("scrollable"));
237:                    addControl(scrollable);
238:                    addControl(new SLabel(" mode"));
239:                    addControl(mode);
240:                    addControl(new SLabel(" extent (H/V)"));
241:                    addControl(hScrollpaneExtent);
242:                    addControl(vScrollpaneExtent);
243:                    addControl(new SLabel(" scrollbar (H/V)"));
244:                    addControl(hScrollBar);
245:                    addControl(vScrollBar);
246:                    addControl(new SLabel(" policy (H/V)"));
247:                    addControl(hScrollBarPolicy);
248:                    addControl(vScrollBarPolicy);
249:                }
250:            }
251:
252:            private SList createTestList(int rows) {
253:                String[] modelData = new String[rows];
254:                for (int i = 0; i < rows; ++i) {
255:                    modelData[i] = "This is list item number " + (i + 1);
256:                }
257:
258:                SList testList = new SList(new SDefaultListModel(modelData));
259:                testList.setShowAsFormComponent(false);
260:
261:                return testList;
262:            }
263:
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.