Source Code Cross Referenced for BasicGripperUI.java in  » Swing-Library » jide-common » com » jidesoft » plaf » basic » 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 » jide common » com.jidesoft.plaf.basic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * @(#)BasicGripperUI.java
003:         *
004:         * Copyright 2002 - 2004 JIDE Software. All rights reserved.
005:         */package com.jidesoft.plaf.basic;
006:
007:        import com.jidesoft.plaf.GripperUI;
008:        import com.jidesoft.plaf.UIDefaultsLookup;
009:        import com.jidesoft.swing.Gripper;
010:        import com.jidesoft.swing.JideSwingUtilities;
011:        import com.jidesoft.utils.SecurityUtils;
012:
013:        import javax.swing.*;
014:        import javax.swing.plaf.ComponentUI;
015:        import java.awt.*;
016:        import java.awt.event.MouseAdapter;
017:        import java.awt.event.MouseEvent;
018:        import java.awt.event.MouseListener;
019:
020:        /**
021:         * A Basic L&F implementation of GripperUI.
022:         */
023:        public class BasicGripperUI extends GripperUI {
024:            private int _size;
025:
026:            protected ThemePainter _painter;
027:
028:            protected Painter _gripperPainter;
029:
030:            public static ComponentUI createUI(JComponent c) {
031:                return new BasicGripperUI();
032:            }
033:
034:            @Override
035:            public void installUI(JComponent c) {
036:                _painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
037:                _gripperPainter = (Painter) UIDefaultsLookup
038:                        .get("Gripper.painter");
039:                installDefaults((Gripper) c);
040:                installListeners((Gripper) c);
041:            }
042:
043:            @Override
044:            public void uninstallUI(JComponent c) {
045:                _painter = null;
046:                _gripperPainter = null;
047:                uninstallDefaults((Gripper) c);
048:                uninstallListeners((Gripper) c);
049:            }
050:
051:            protected void installDefaults(Gripper s) {
052:                _size = UIDefaultsLookup.getInt("Gripper.size");
053:            }
054:
055:            protected void uninstallDefaults(Gripper s) {
056:            }
057:
058:            protected MouseListener createMouseListener() {
059:                return new GripperMouseListener();
060:            }
061:
062:            protected void installListeners(Gripper g) {
063:                MouseListener listener = createMouseListener();
064:                if (listener != null) {
065:                    // put the listener in the gripper's client properties so that
066:                    // we can get at it later
067:                    g.putClientProperty(this , listener);
068:                    g.addMouseListener(listener);
069:                }
070:            }
071:
072:            protected void uninstallListeners(Gripper g) {
073:                MouseListener listener = (MouseListener) g
074:                        .getClientProperty(this );
075:                g.putClientProperty(this , null);
076:                if (listener != null) {
077:                    g.removeMouseListener(listener);
078:                }
079:            }
080:
081:            protected void paintBackground(Graphics g, Gripper b) {
082:                Rectangle rect = new Rectangle(0, 0, b.getWidth(), b
083:                        .getHeight());
084:                if (b.isRollover()) {
085:                    getPainter().paintButtonBackground(b, g, rect, 0,
086:                            ThemePainter.STATE_ROLLOVER);
087:                } else {
088:                    if (b.isOpaque()) {
089:                        getPainter().paintButtonBackground(
090:                                b,
091:                                g,
092:                                rect,
093:                                0,
094:                                b.isSelected() ? ThemePainter.STATE_SELECTED
095:                                        : ThemePainter.STATE_DEFAULT, false);
096:                        if ("true".equals(SecurityUtils.getProperty(
097:                                "shadingtheme", "false"))) {
098:                            JideSwingUtilities.fillGradient(g, rect,
099:                                    SwingConstants.HORIZONTAL);
100:                        }
101:                    }
102:                }
103:            }
104:
105:            @Override
106:            public void paint(Graphics g, JComponent c) {
107:                Gripper gripper = (Gripper) c;
108:                paintBackground(g, gripper);
109:                int state = gripper.isSelected() ? ThemePainter.STATE_SELECTED
110:                        : ThemePainter.STATE_DEFAULT;
111:                if (_gripperPainter == null) {
112:                    getPainter().paintGripper(c, g,
113:                            new Rectangle(0, 0, c.getWidth(), c.getHeight()),
114:                            gripper.getOrientation(), state);
115:                } else {
116:                    _gripperPainter.paint(c, g, new Rectangle(0, 0, c
117:                            .getWidth(), c.getHeight()), gripper
118:                            .getOrientation(), state);
119:                }
120:            }
121:
122:            @Override
123:            public Dimension getPreferredSize(JComponent c) {
124:                return new Dimension(_size, _size);
125:            }
126:
127:            @Override
128:            public Dimension getMinimumSize(JComponent c) {
129:                return getPreferredSize(c);
130:            }
131:
132:            @Override
133:            public Dimension getMaximumSize(JComponent c) {
134:                Gripper gripper = (Gripper) c;
135:                if (gripper.getOrientation() == SwingConstants.HORIZONTAL)
136:                    return new Dimension(_size, c.getParent().getHeight());
137:                else
138:                    return new Dimension(c.getParent().getWidth(), _size);
139:            }
140:
141:            public ThemePainter getPainter() {
142:                return _painter;
143:            }
144:
145:            class GripperMouseListener extends MouseAdapter {
146:                @Override
147:                public void mouseEntered(MouseEvent e) {
148:                    super .mouseEntered(e);
149:                    if (e.getSource() instanceof  Gripper) {
150:                        if (((Gripper) e.getSource()).isRolloverEnabled()) {
151:                            ((Gripper) e.getSource()).setRollover(true);
152:                        }
153:                    }
154:                }
155:
156:                @Override
157:                public void mouseExited(MouseEvent e) {
158:                    super .mouseExited(e);
159:                    if (e.getSource() instanceof  Gripper) {
160:                        if (((Gripper) e.getSource()).isRolloverEnabled()) {
161:                            ((Gripper) e.getSource()).setRollover(false);
162:                        }
163:                    }
164:                }
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.