KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > grapheditor > widget > ImageLabelWidget


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.wsdl.ui.view.grapheditor.widget;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Font JavaDoc;
24 import java.awt.Image JavaDoc;
25 import org.netbeans.api.visual.layout.LayoutFactory;
26 import org.netbeans.api.visual.layout.LayoutFactory.SerialAlignment;
27 import org.netbeans.api.visual.widget.ImageWidget;
28 import org.netbeans.api.visual.widget.LabelWidget;
29 import org.netbeans.api.visual.widget.Scene;
30 import org.netbeans.api.visual.widget.Widget;
31
32 /**
33  *
34  * @author anjeleevich
35  */

36 public class ImageLabelWidget extends Widget {
37
38     public ImageLabelWidget(Scene scene, Image JavaDoc image, String JavaDoc text) {
39         this(scene, image, text, null, DEFAULT_GAP);
40     }
41     
42
43     public ImageLabelWidget(Scene scene, Image JavaDoc image, String JavaDoc text,
44             int hgap)
45     {
46         this(scene, image, text, null, hgap);
47     }
48     
49     
50     public ImageLabelWidget(Scene scene, Image JavaDoc image,
51             String JavaDoc text, String JavaDoc comment)
52     {
53         this(scene, image, text, comment, DEFAULT_GAP);
54     }
55     
56     
57     public ImageLabelWidget(Scene scene, Image JavaDoc image,
58             String JavaDoc text,
59             String JavaDoc comment, int hgap)
60     {
61         super(scene);
62         
63         setLayout(LayoutFactory.createHorizontalLayout(
64                 SerialAlignment.CENTER, hgap));
65         
66         Font JavaDoc font = scene.getDefaultFont();
67         
68         Widget imageWidget = new ImageWidget(scene, image);
69         
70         Widget textWidget = new LabelWidget(scene, text);
71         textWidget.setFont(font);
72         
73         addChild(imageWidget);
74         addChild(textWidget);
75         
76         if (comment != null) {
77             Widget commentWidget = new LabelWidget(scene, comment);
78             commentWidget.setFont(font);
79             commentWidget.setForeground(COMMENT_COLOR);
80             addChild(commentWidget);
81         }
82     }
83     
84     public static final Color JavaDoc COMMENT_COLOR = new Color JavaDoc(0x666666);
85     public static final int DEFAULT_GAP = 4;
86 }
87
Popular Tags