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


001:        /*
002:         * @(#)ClickThroughLabel.java 2/28/2006
003:         *
004:         * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
005:         */
006:
007:        package com.jidesoft.swing;
008:
009:        import javax.swing.*;
010:        import javax.swing.event.MouseInputListener;
011:        import java.awt.*;
012:        import java.awt.event.MouseEvent;
013:
014:        /**
015:         * <tt>ClickThroughLabel</tt> is a special JLabel that will retarget all mouse events to specified target component.
016:         * <p/>
017:         * For example, you need to paint some text on a JComponent. Usually you can call Java2D paint text method and paint
018:         * the text. However the other way to do it is to add JLabel to JComponent and JLabel will not only paint
019:         * the text but also an optional icon which is better. However if you had mouse listener added to JComponent, the mouse
020:         * listener will not receive any mouse events when mouse clicks on the JLabel. By using this <tt>ClickThroughLabel</tt>,
021:         * mouse event will be passed to underlying JComponent.
022:         * <p/>
023:         * Please note, we didn't pass all mouse events. In most cases, MOUSE_EXITED and MOUSE_ENTERED doesn't make sense to pass through.
024:         * However there are cases, for example when the JLabel is at the border of JComponent, you may expect MOUSE_ENTERED event
025:         * on JComponent but it will not happen. So please be aware of those cases so that you don't depend on it for important
026:         * decision in your code.
027:         */
028:        public class ClickThroughLabel extends JLabel implements 
029:                MouseInputListener {
030:
031:            private Component _target;
032:
033:            public ClickThroughLabel() {
034:                installListeners();
035:            }
036:
037:            public ClickThroughLabel(Icon image) {
038:                super (image);
039:                installListeners();
040:            }
041:
042:            public ClickThroughLabel(Icon image, int horizontalAlignment) {
043:                super (image, horizontalAlignment);
044:                installListeners();
045:            }
046:
047:            public ClickThroughLabel(String text) {
048:                super (text);
049:                installListeners();
050:            }
051:
052:            public ClickThroughLabel(String text, int horizontalAlignment) {
053:                super (text, horizontalAlignment);
054:                installListeners();
055:            }
056:
057:            public ClickThroughLabel(String text, Icon icon,
058:                    int horizontalAlignment) {
059:                super (text, icon, horizontalAlignment);
060:                installListeners();
061:            }
062:
063:            public Component getTarget() {
064:                return _target;
065:            }
066:
067:            public void setTarget(Component target) {
068:                _target = target;
069:            }
070:
071:            protected void installListeners() {
072:                addMouseListener(this );
073:                addMouseMotionListener(this );
074:            }
075:
076:            protected void uninstallListeners() {
077:                removeMouseListener(this );
078:                removeMouseMotionListener(this );
079:            }
080:
081:            public void mouseClicked(MouseEvent e) {
082:                JideSwingUtilities
083:                        .retargetMouseEvent(e.getID(), e, getTarget());
084:            }
085:
086:            public void mousePressed(MouseEvent e) {
087:                JideSwingUtilities
088:                        .retargetMouseEvent(e.getID(), e, getTarget());
089:            }
090:
091:            public void mouseReleased(MouseEvent e) {
092:                JideSwingUtilities
093:                        .retargetMouseEvent(e.getID(), e, getTarget());
094:            }
095:
096:            public void mouseEntered(MouseEvent e) {
097:                JideSwingUtilities
098:                        .retargetMouseEvent(e.getID(), e, getTarget());
099:            }
100:
101:            public void mouseExited(MouseEvent e) {
102:                JideSwingUtilities
103:                        .retargetMouseEvent(e.getID(), e, getTarget());
104:            }
105:
106:            public void mouseDragged(MouseEvent e) {
107:                JideSwingUtilities
108:                        .retargetMouseEvent(e.getID(), e, getTarget());
109:            }
110:
111:            public void mouseMoved(MouseEvent e) {
112:                JideSwingUtilities
113:                        .retargetMouseEvent(e.getID(), e, getTarget());
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.