1 package rero.gui.input; 2 3 import javax.swing.*; 4 import javax.swing.border.*; 5 import javax.swing.event.*; 6 7 import java.awt.*; 8 import java.awt.event.*; 9 10 import java.util.*; 11 12 import text.*; 13 14 public class InputBorder implements Border 15 { 16 protected AttributedString indent; 17 protected String original; 18 19 public InputBorder(String text) 20 { 21 indent = AttributedString.CreateAttributedString(text); 22 indent.assignWidths(); 23 24 original = text; 25 } 26 27 public String getText() 28 { 29 return original; 30 } 31 32 public AttributedText getAttributes() 33 { 34 return indent.getAttributedText(); 35 } 36 37 public boolean isBorderOpaque() 38 { 39 return true; 40 } 41 42 public Insets getBorderInsets(Component c) 43 { 44 return new Insets(0, indent.getAttributedText().getWidth(), 0, 0); 45 } 46 47 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) 48 { 49 TextSource.initGraphics(g); 50 TextSource.drawText(g, indent.getAttributedText(), x, height + y - 4); } 52 } 53 | Popular Tags |