1 19 20 package org.netbeans.modules.xml.wsdl.ui.view.grapheditor.widget; 21 22 import java.awt.Color ; 23 import java.awt.Font ; 24 import java.awt.Image ; 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 36 public class ImageLabelWidget extends Widget { 37 38 public ImageLabelWidget(Scene scene, Image image, String text) { 39 this(scene, image, text, null, DEFAULT_GAP); 40 } 41 42 43 public ImageLabelWidget(Scene scene, Image image, String text, 44 int hgap) 45 { 46 this(scene, image, text, null, hgap); 47 } 48 49 50 public ImageLabelWidget(Scene scene, Image image, 51 String text, String comment) 52 { 53 this(scene, image, text, comment, DEFAULT_GAP); 54 } 55 56 57 public ImageLabelWidget(Scene scene, Image image, 58 String text, 59 String comment, int hgap) 60 { 61 super(scene); 62 63 setLayout(LayoutFactory.createHorizontalLayout( 64 SerialAlignment.CENTER, hgap)); 65 66 Font 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 COMMENT_COLOR = new Color (0x666666); 85 public static final int DEFAULT_GAP = 4; 86 } 87 | Popular Tags |