1 14 package org.wings.border; 15 16 import org.wings.SFont; 17 import org.wings.style.CSSProperty; 18 import org.wings.style.CSSAttributeSet; 19 import org.wings.style.CSSStyleSheet; 20 21 import java.awt.*; 22 23 26 public class STitledBorder extends SAbstractBorder { 27 private SBorder border; 28 29 private String title; 30 private CSSAttributeSet titleAttributes = new CSSAttributeSet(); 31 32 35 public STitledBorder(SBorder border) { 36 setBorder(border); 37 attributes.put(CSSProperty.PADDING_TOP, "1em"); 38 } 39 40 46 public STitledBorder(SBorder border, String title) { 47 this(border); 48 setTitle(title); 49 } 50 51 55 public STitledBorder(String title) { 56 this(new SEtchedBorder(SEtchedBorder.LOWERED)); 57 border.setThickness(2); 58 setTitle(title); 59 } 60 61 66 public SBorder getBorder() { 67 return border; 68 } 69 70 75 public void setBorder(SBorder border) { 76 this.border = border; 77 attributes = border.getAttributes(); 78 } 79 80 85 public String getTitle() { 86 return title; 87 } 88 89 94 public void setTitle(String title) { 95 this.title = title; 96 } 97 98 public CSSAttributeSet getTitleAttributes() { 99 return titleAttributes; 100 } 101 102 107 public Color getTitleColor() { 108 return CSSStyleSheet.getForeground(titleAttributes); 109 } 110 111 116 public void setTitleColor(Color color) { 117 titleAttributes.put(CSSProperty.COLOR, CSSStyleSheet.getAttribute(color)); 118 } 119 120 123 public void setTitleBackground(Color color) { 124 titleAttributes.put(CSSProperty.BACKGROUND_COLOR, CSSStyleSheet.getAttribute(color)); 125 } 126 127 134 public Color getTitleBackground() { 135 return CSSStyleSheet.getBackground(titleAttributes); 136 } 137 138 143 public SFont getTitleFont() { 144 return CSSStyleSheet.getFont(titleAttributes); 145 } 146 147 152 public void setTitleFont(SFont titleFont) { 153 titleAttributes.putAll(CSSStyleSheet.getAttributes(titleFont)); 154 } 155 } 156 | Popular Tags |