Source Code Cross Referenced for HoSwingButton.java in  » J2EE » WiSerFramework » de » ug2t » channel » ho » client » 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 » J2EE » WiSerFramework » de.ug2t.channel.ho.client.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // @@
002:        // @@
003:        /*
004:         * Wi.Ser Framework
005:         *
006:         * LGPL Version: 1.8.1, 20-September-2007  
007:         * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library located in LGPL.txt in the 
021:         * license directory; if not, write to the 
022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023:         * Boston, MA  02111-1307, USA.
024:         * 
025:         * If this agreement does not cover your requirements, please contact us
026:         * via email to get detailed information about the commercial license 
027:         * or our service offerings!
028:         *
029:         */
030:        // @@
031:        package de.ug2t.channel.ho.client.swing;
032:
033:        import java.awt.*;
034:        import java.awt.event.*;
035:
036:        import javax.swing.*;
037:        import javax.swing.border.*;
038:        import javax.swing.plaf.*;
039:        import javax.swing.plaf.basic.*;
040:
041:        import com.sun.java.swing.plaf.windows.*;
042:
043:        import de.ug2t.kernel.*;
044:        import de.ug2t.unifiedGui.interfaces.*;
045:
046:        public final class HoSwingButton extends HoSwingComponent implements 
047:                IUnButton {
048:            private JButton pem_swingButton = null;
049:            private HoSwingImage pem_icon = null;
050:
051:            private class MyButtonUI extends BasicButtonUI {
052:                protected void installDefaults(AbstractButton b) {
053:                    String pp = getPropertyPrefix();
054:
055:                    defaultTextShiftOffset = UIManager.getInt(pp
056:                            + "textShiftOffset");
057:
058:                    // set the following defaults on the button
059:                    if (b.getMargin() == null
060:                            || (b.getMargin() instanceof  UIResource)) {
061:                        b.setMargin(UIManager.getInsets(pp + "margin"));
062:                    }
063:
064:                    LookAndFeel.installColorsAndFont(b, pp + "background", pp
065:                            + "foreground", pp + "font");
066:                    b.setBorder(new CompoundBorder(
067:                            new BasicBorders.ButtonBorder(HoSwingComponent
068:                                    .pcmf_createColor("#888888"),
069:                                    HoSwingComponent
070:                                            .pcmf_createColor("#444444"),
071:                                    new Color(212, 208, 200), Color.WHITE),
072:                            new BasicBorders.MarginBorder()));
073:                }
074:
075:                protected void paintText(Graphics g, AbstractButton b,
076:                        Rectangle textRect, String text) {
077:                    this .paintText(g, b, textRect, text, getTextShiftOffset());
078:                }
079:
080:                public void drawStringUnderlineCharAt(JComponent c, Graphics g,
081:                        String text, int underlinedIndex, int x, int y) {
082:                    g.drawString(text, x, y);
083:                    if (underlinedIndex >= 0 && underlinedIndex < text.length()) {
084:                        FontMetrics fm = g.getFontMetrics();
085:                        int underlineRectX = x
086:                                + this .stringWidth(c, fm, text.substring(0,
087:                                        underlinedIndex));
088:                        int underlineRectY = y;
089:                        int underlineRectWidth = fm.charWidth(text
090:                                .charAt(underlinedIndex));
091:                        int underlineRectHeight = 1;
092:                        g.fillRect(underlineRectX, underlineRectY + 1,
093:                                underlineRectWidth, underlineRectHeight);
094:                    }
095:                }
096:
097:                public int stringWidth(JComponent c, FontMetrics fm,
098:                        String string) {
099:                    return fm.stringWidth(string);
100:                }
101:
102:                public FontMetrics getFontMetrics(JComponent c, Graphics g) {
103:                    return getFontMetrics(c, g, g.getFont());
104:                }
105:
106:                public FontMetrics getFontMetrics(JComponent c, Graphics g,
107:                        Font font) {
108:                    if (c != null) {
109:                        return c.getFontMetrics(font);
110:                    }
111:                    return Toolkit.getDefaultToolkit().getFontMetrics(font);
112:                }
113:
114:                public void paintText(Graphics g, AbstractButton b,
115:                        Rectangle textRect, String text, int textShiftOffset) {
116:                    ButtonModel model = b.getModel();
117:                    FontMetrics fm = this .getFontMetrics(b, g);
118:
119:                    int mnemIndex = b.getDisplayedMnemonicIndex();
120:                    if (WindowsLookAndFeel.isMnemonicHidden() == true) {
121:                        mnemIndex = -1;
122:                    }
123:                    Color color = b.getForeground();
124:                    if (model.isEnabled()) {
125:                        if (!(b instanceof  JMenuItem && model.isArmed())
126:                                && !(b instanceof  JMenu && (model.isSelected() || model
127:                                        .isRollover()))) {
128:                            g.setColor(b.getForeground());
129:                        }
130:                        this .drawStringUnderlineCharAt(b, g, text, mnemIndex,
131:                                textRect.x + textShiftOffset, textRect.y
132:                                        + fm.getAscent() + textShiftOffset);
133:                    } else {
134:                        color = UIManager.getColor("Button.disabledForeground");
135:                        Color shadow = UIManager
136:                                .getColor("Button.disabledShadow");
137:
138:                        if (shadow == null) {
139:                            shadow = b.getBackground().darker();
140:                        }
141:                        g.setColor(shadow);
142:                        this .drawStringUnderlineCharAt(b, g, text, mnemIndex,
143:                                textRect.x, textRect.y + fm.getAscent());
144:                    }
145:                    if (color == null) {
146:                        color = b.getBackground().brighter();
147:                    }
148:                }
149:
150:                protected void paintFocus(Graphics g, AbstractButton b,
151:                        Rectangle viewRect, Rectangle textRect,
152:                        Rectangle iconRect) {
153:                    int width = b.getWidth();
154:                    int height = b.getHeight();
155:                    g.setColor(Color.BLACK);
156:                    BasicGraphicsUtils.drawDashedRect(g, 3, 3, width - 6,
157:                            height - 6);
158:                }
159:
160:                protected void paintButtonPressed(Graphics g, AbstractButton b) {
161:                    setTextShiftOffset();
162:                }
163:
164:                public Dimension getPreferredSize(JComponent c) {
165:                    Dimension d = super .getPreferredSize(c);
166:
167:                    AbstractButton b = (AbstractButton) c;
168:                    if (d != null && b.isFocusPainted()) {
169:                        if (d.width % 2 == 0) {
170:                            d.width += 1;
171:                        }
172:                        if (d.height % 2 == 0) {
173:                            d.height += 1;
174:                        }
175:                    }
176:                    return d;
177:                }
178:            }
179:
180:            public HoSwingButton(String xValue, IUnApplication xAppl)
181:                    throws Exception {
182:                super (xValue, xAppl);
183:                this .pcmf_setLocalValue(xValue);
184:                this .pcmf_setEventOnChange(true);
185:
186:                pem_swingButton = new JButton(xValue);
187:                super .pdm_realSwingCmp = this .pem_swingButton;
188:                this .pem_swingButton.setMinimumSize(this .pem_swingButton
189:                        .getPreferredSize());
190:                ((HoSwingClient) xAppl).pcmf_addKeyDispatcher(this );
191:
192:                ActionListener l = new ActionListener() {
193:                    public void actionPerformed(ActionEvent ev) {
194:                        try {
195:                            String l_objName = HoSwingButton.this 
196:                                    .pcmf_getObjName();
197:
198:                            // Lokale Listener aufrufen
199:                            HoSwingButton.this .pcmf_setValue(HoSwingButton.this 
200:                                    .pcmf_getValue());
201:                            HoSwingButton.this .pcmf_setRefresh();
202:                            HoSwingButton.this .pcmf_dispatchEvent();
203:
204:                            if (HoSwingButton.this .pem_session
205:                                    .pcmf_isDisabled())
206:                                return;
207:
208:                            // Werte setzen um diese zum Server zu übertragen
209:                            ((HoSwingPage) HoSwingButton.this .pcmf_getAppl()
210:                                    .pcmf_getActive()).pcmf_setSubmitValue(
211:                                    l_objName, HoSwingButton.this 
212:                                            .pcmf_getValue().toString());
213:                            HoSwingButton.this .pcmf_addSyncedWidgets(
214:                                    (HoSwingPage) HoSwingButton.this 
215:                                            .pcmf_getAppl().pcmf_getActive(),
216:                                    HoSwingButton.this );
217:                            if (HoSwingButton.this .pcmf_getUnComponent()
218:                                    .pcmf_isSubmit() == true)
219:                                ((HoSwingPage) HoSwingButton.this 
220:                                        .pcmf_getAppl().pcmf_getActive())
221:                                        .pcmf_submit();
222:                        } catch (Exception e) {
223:                            KeLog.pcmf_logException("ug2t", this , e);
224:                        }
225:                        ;
226:                    };
227:                };
228:                this .pem_swingButton.addActionListener(l);
229:
230:                return;
231:            };
232:
233:            public void pcmf_setValue(Object xValue) {
234:                if (xValue instanceof  HoSwingImage) {
235:                    this .pem_swingButton
236:                            .setIcon(((JLabel) ((HoSwingImage) xValue)
237:                                    .pcmf_getRealSwingObj()).getIcon());
238:                    this .pem_swingButton.setText(null);
239:                } else if (xValue != null)
240:                    this .pem_swingButton.setText(xValue.toString());
241:
242:                super .pcmf_setValue(xValue);
243:            };
244:
245:            public void pcmf_setIcon(IUnImage xIcon) {
246:                pem_icon = (HoSwingImage) xIcon;
247:                this .pem_swingButton.setIcon(((JLabel) pem_icon
248:                        .pcmf_getRealSwingObj()).getIcon());
249:            }
250:
251:            public void pcmf_setBgColor(String xCol) {
252:                if (!(this .pem_swingButton.getUI() instanceof  MyButtonUI))
253:                    this .pem_swingButton.setUI(new MyButtonUI());
254:
255:                super .pcmf_setBgColor(xCol);
256:            }
257:
258:            public void pcmf_setBorder(int xBorder, String xColor, int xWidth) {
259:                if (xWidth == 0 && !this .pdm_colorSet)
260:                    this .pem_swingButton.updateUI();
261:                else
262:                    this .pem_swingButton.setUI(new MyButtonUI());
263:
264:                super .pcmf_setBorder(xBorder, xColor, xWidth);
265:            }
266:
267:            public IUnImage pcmf_getIcon() {
268:                return (pem_icon);
269:            };
270:
271:            public void pcmf_setKeyAccess(int xKey) {
272:                this .pem_swingButton.setMnemonic(Character
273:                        .toString((char) xKey).toUpperCase().charAt(0));
274:            };
275:
276:            public int pcmf_getAccKey() {
277:                return (this .pem_swingButton.getMnemonic());
278:            }
279:
280:            public void pcmf_setReadOnly(boolean xReadOnly) {
281:                this .pem_swingButton.setEnabled(!xReadOnly);
282:            }
283:
284:            public boolean pcmf_isReadOnly() {
285:                return (!this.pem_swingButton.isEnabled());
286:            }
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.