Source Code Cross Referenced for JScrollBar.java in  » Apache-Harmony-Java-SE » javax-package » javax » 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 » Apache Harmony Java SE » javax package » javax.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Sergey Burlak
020:         * @version $Revision$
021:         */package javax.swing;
022:
023:        import java.awt.Adjustable;
024:        import java.awt.Dimension;
025:        import java.awt.event.AdjustmentEvent;
026:        import java.awt.event.AdjustmentListener;
027:
028:        import javax.accessibility.Accessible;
029:        import javax.accessibility.AccessibleContext;
030:        import javax.accessibility.AccessibleRole;
031:        import javax.accessibility.AccessibleState;
032:        import javax.accessibility.AccessibleStateSet;
033:        import javax.accessibility.AccessibleValue;
034:        import javax.swing.event.ChangeEvent;
035:        import javax.swing.event.ChangeListener;
036:        import javax.swing.event.EventListenerList;
037:        import javax.swing.plaf.ScrollBarUI;
038:
039:        import org.apache.harmony.x.swing.internal.nls.Messages;
040:
041:        public class JScrollBar extends JComponent implements  Adjustable,
042:                Accessible {
043:
044:            protected class AccessibleJScrollBar extends
045:                    JComponent.AccessibleJComponent implements  AccessibleValue {
046:                public AccessibleStateSet getAccessibleStateSet() {
047:                    AccessibleStateSet result = new AccessibleStateSet();
048:
049:                    if (isEnabled()) {
050:                        result.add(AccessibleState.ENABLED);
051:                    }
052:                    if (isFocusable()) {
053:                        result.add(AccessibleState.FOCUSABLE);
054:                    }
055:                    if (isVisible()) {
056:                        result.add(AccessibleState.VISIBLE);
057:                    }
058:                    if (isOpaque()) {
059:                        result.add(AccessibleState.OPAQUE);
060:                    }
061:                    if (getOrientation() == HORIZONTAL) {
062:                        result.add(AccessibleState.HORIZONTAL);
063:                    } else {
064:                        result.add(AccessibleState.VERTICAL);
065:                    }
066:
067:                    return result;
068:                }
069:
070:                public AccessibleRole getAccessibleRole() {
071:                    return AccessibleRole.SCROLL_BAR;
072:                }
073:
074:                public AccessibleValue getAccessibleValue() {
075:                    return this ;
076:                }
077:
078:                public Number getCurrentAccessibleValue() {
079:                    return new Integer(getValue());
080:                }
081:
082:                public boolean setCurrentAccessibleValue(final Number n) {
083:                    boolean result;
084:                    try {
085:                        setValue(n.intValue());
086:                        result = true;
087:                    } catch (final Exception e) {
088:                        result = false;
089:                    }
090:                    return result;
091:                }
092:
093:                public Number getMinimumAccessibleValue() {
094:                    return new Integer(getMinimum());
095:                }
096:
097:                public Number getMaximumAccessibleValue() {
098:                    return new Integer(getMaximum() - getVisibleAmount());
099:                }
100:            }
101:
102:            protected BoundedRangeModel model;
103:            protected int blockIncrement = 10;
104:            protected int unitIncrement = 1;
105:            protected int orientation = VERTICAL;
106:            private static final String classUIID = "ScrollBarUI";
107:
108:            private ChangeListener modelChangeHandler;
109:            private static final String BLOCK_INCREMENT = "blockIncrement";
110:            private static final String UNIT_INCREMENT = "unitIncrement";
111:            private static final String ORIENTATION_PROPERTY = "orientation";
112:            private static final String MODEL_PROPERTY = "model";
113:
114:            public JScrollBar() {
115:                this (VERTICAL, 0, 10, 0, 100);
116:            }
117:
118:            public JScrollBar(final int orientation) {
119:                this (orientation, 0, 10, 0, 100);
120:            }
121:
122:            public JScrollBar(final int orientation, final int value,
123:                    final int extent, final int min, final int max) {
124:                model = new DefaultBoundedRangeModel(value, extent, min, max);
125:
126:                if (orientation != HORIZONTAL && orientation != VERTICAL) {
127:                    throw new IllegalArgumentException(Messages
128:                            .getString("swing.28")); //$NON-NLS-1$
129:                }
130:
131:                this .orientation = orientation;
132:                blockIncrement = extent;
133:
134:                modelChangeHandler = new ChangeListener() {
135:                    public void stateChanged(final ChangeEvent e) {
136:                        fireAdjustmentValueChanged(
137:                                AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
138:                                AdjustmentEvent.TRACK, getValue());
139:                    }
140:                };
141:
142:                model.addChangeListener(modelChangeHandler);
143:                listenerList = new EventListenerList();
144:
145:                updateUI();
146:            }
147:
148:            public void setUI(final ScrollBarUI ui) {
149:                super .setUI(ui);
150:            }
151:
152:            public ScrollBarUI getUI() {
153:                return (ScrollBarUI) ui;
154:            }
155:
156:            public void updateUI() {
157:                setUI((ScrollBarUI) UIManager.getUI(this ));
158:            }
159:
160:            public String getUIClassID() {
161:                return classUIID;
162:            }
163:
164:            public int getOrientation() {
165:                return orientation;
166:            }
167:
168:            public void setOrientation(final int orientation) {
169:                if (orientation != VERTICAL && orientation != HORIZONTAL) {
170:                    throw new IllegalArgumentException(Messages
171:                            .getString("swing.28")); //$NON-NLS-1$
172:                }
173:                if (orientation != this .orientation) {
174:                    int oldValue = this .orientation;
175:                    this .orientation = orientation;
176:                    firePropertyChange(ORIENTATION_PROPERTY, oldValue,
177:                            orientation);
178:                }
179:            }
180:
181:            public BoundedRangeModel getModel() {
182:                return model;
183:            }
184:
185:            public void setModel(final BoundedRangeModel model) {
186:                if (model != this .model) {
187:                    BoundedRangeModel oldValue = this .model;
188:                    if (oldValue != null) {
189:                        oldValue.removeChangeListener(modelChangeHandler);
190:                    }
191:
192:                    this .model = model;
193:                    if (model != null) {
194:                        model.addChangeListener(modelChangeHandler);
195:                    }
196:
197:                    firePropertyChange(MODEL_PROPERTY, oldValue, model);
198:                }
199:            }
200:
201:            public int getUnitIncrement(final int direction) {
202:                return unitIncrement;
203:            }
204:
205:            public void setUnitIncrement(final int unitIncrement) {
206:                if (this .unitIncrement != unitIncrement) {
207:                    int oldValue = this .unitIncrement;
208:                    this .unitIncrement = unitIncrement;
209:                    firePropertyChange(UNIT_INCREMENT, oldValue, unitIncrement);
210:                }
211:            }
212:
213:            public int getBlockIncrement(final int direction) {
214:                return blockIncrement;
215:            }
216:
217:            public void setBlockIncrement(final int blockIncrement) {
218:                if (this .blockIncrement != blockIncrement) {
219:                    int oldValue = this .blockIncrement;
220:                    this .blockIncrement = blockIncrement;
221:                    firePropertyChange(BLOCK_INCREMENT, oldValue,
222:                            blockIncrement);
223:                }
224:            }
225:
226:            public int getUnitIncrement() {
227:                return unitIncrement;
228:            }
229:
230:            public int getBlockIncrement() {
231:                return blockIncrement;
232:            }
233:
234:            public int getValue() {
235:                return getModel().getValue();
236:            }
237:
238:            public void setValue(final int value) {
239:                getModel().setValue(value);
240:            }
241:
242:            public int getVisibleAmount() {
243:                return getModel().getExtent();
244:            }
245:
246:            public void setVisibleAmount(final int extent) {
247:                getModel().setExtent(extent);
248:            }
249:
250:            public int getMinimum() {
251:                return getModel().getMinimum();
252:            }
253:
254:            public void setMinimum(final int minimum) {
255:                getModel().setMinimum(minimum);
256:            }
257:
258:            public int getMaximum() {
259:                return getModel().getMaximum();
260:            }
261:
262:            public void setMaximum(final int maximum) {
263:                getModel().setMaximum(maximum);
264:            }
265:
266:            public boolean getValueIsAdjusting() {
267:                return getModel().getValueIsAdjusting();
268:            }
269:
270:            public void setValueIsAdjusting(final boolean b) {
271:                getModel().setValueIsAdjusting(b);
272:            }
273:
274:            public void setValues(final int newValue, final int newExtent,
275:                    final int newMin, final int newMax) {
276:                getModel().setRangeProperties(newValue, newExtent, newMin,
277:                        newMax, getModel().getValueIsAdjusting());
278:            }
279:
280:            public void addAdjustmentListener(final AdjustmentListener l) {
281:                listenerList.add(AdjustmentListener.class, l);
282:            }
283:
284:            public void removeAdjustmentListener(final AdjustmentListener l) {
285:                listenerList.remove(AdjustmentListener.class, l);
286:            }
287:
288:            public AdjustmentListener[] getAdjustmentListeners() {
289:                return (AdjustmentListener[]) listenerList
290:                        .getListeners(AdjustmentListener.class);
291:            }
292:
293:            protected void fireAdjustmentValueChanged(final int id,
294:                    final int type, final int value) {
295:                AdjustmentListener[] listeners = getAdjustmentListeners();
296:                for (int i = 0; i < listeners.length; i++) {
297:                    listeners[i].adjustmentValueChanged(new AdjustmentEvent(
298:                            this , id, type, value));
299:                }
300:            }
301:
302:            public void setEnabled(final boolean b) {
303:                super .setEnabled(b);
304:            }
305:
306:            protected String paramString() {
307:                return super .paramString();
308:            }
309:
310:            public AccessibleContext getAccessibleContext() {
311:                if (accessibleContext == null) {
312:                    accessibleContext = new AccessibleJScrollBar();
313:                }
314:                return accessibleContext;
315:            }
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.