1 19 package org.netbeans.modules.xml.wsdl.ui.view.grapheditor.widget; 20 21 import java.awt.Color ; 22 import java.awt.Dimension ; 23 import java.awt.Graphics2D ; 24 25 import org.netbeans.api.visual.widget.LabelWidget; 26 import org.netbeans.api.visual.widget.Scene; 27 28 public class CenteredLabelWidget extends LabelWidget { 29 30 protected static final int MINIMUM_WIDTH = 200; 31 protected static final int MINIMUM_HEIGHT = 25; 32 private Color mColor; 33 34 public CenteredLabelWidget(Scene scene) { 35 super(scene); 36 init(); 37 } 38 39 public CenteredLabelWidget(Scene scene, String text, Color color) { 40 super(scene, text); 41 mColor = color; 42 init(); 43 } 44 45 void init() { 46 setAlignment(Alignment.CENTER); 47 setVerticalAlignment(VerticalAlignment.CENTER); 48 setMinimumSize(new Dimension (MINIMUM_WIDTH, MINIMUM_HEIGHT)); 49 } 50 51 @Override 52 protected void paintWidget() { 53 if (mColor != null) { 54 Graphics2D gr = getGraphics (); 55 Color c = gr.getColor(); 56 gr.setColor(mColor); 57 gr.fill(getClientArea()); 58 gr.setColor(c); 59 } 60 super.paintWidget(); 61 } 62 63 64 } 65 | Popular Tags |