52 |
import javax.swing.JOptionPane; |
import javax.swing.JOptionPane; |
53 |
import javax.swing.JTextField; |
import javax.swing.JTextField; |
54 |
import javax.swing.JToggleButton; |
import javax.swing.JToggleButton; |
55 |
|
import javax.swing.JToolBar; |
56 |
import javax.swing.UIDefaults; |
import javax.swing.UIDefaults; |
57 |
import javax.swing.UIManager; |
import javax.swing.UIManager; |
58 |
import javax.swing.border.AbstractBorder; |
import javax.swing.border.AbstractBorder; |
1146 |
} |
} |
1147 |
|
|
1148 |
/** |
/** |
1149 |
|
* A border used when painting {@link JToolBar} instances. |
1150 |
|
*/ |
1151 |
|
public static class ToolBarBorder extends AbstractBorder |
1152 |
|
implements UIResource |
1153 |
|
{ |
1154 |
|
/** |
1155 |
|
* Creates a new border instance. |
1156 |
|
*/ |
1157 |
|
public ToolBarBorder() |
1158 |
|
{ |
1159 |
|
} |
1160 |
|
|
1161 |
|
/** |
1162 |
|
* Returns the border insets. |
1163 |
|
* |
1164 |
|
* @param c the component (ignored). |
1165 |
|
* |
1166 |
|
* @return The border insets. |
1167 |
|
*/ |
1168 |
|
public Insets getBorderInsets(Component c) |
1169 |
|
{ |
1170 |
|
return getBorderInsets(c, null); |
1171 |
|
} |
1172 |
|
|
1173 |
|
/** |
1174 |
|
* Returns the border insets. |
1175 |
|
* |
1176 |
|
* @param c the component (ignored). |
1177 |
|
* @return The border insets. |
1178 |
|
*/ |
1179 |
|
public Insets getBorderInsets(Component c, Insets newInsets) |
1180 |
|
{ |
1181 |
|
JToolBar tb = (JToolBar) c; |
1182 |
|
if (tb.getOrientation() == JToolBar.HORIZONTAL) |
1183 |
|
{ |
1184 |
|
if (newInsets == null) |
1185 |
|
newInsets = new Insets(2, 16, 2, 2); |
1186 |
|
else |
1187 |
|
{ |
1188 |
|
newInsets.top = 2; |
1189 |
|
newInsets.left = 16; |
1190 |
|
newInsets.bottom = 2; |
1191 |
|
newInsets.right = 2; |
1192 |
|
} |
1193 |
|
return newInsets; |
1194 |
|
} |
1195 |
|
else // assume JToolBar.VERTICAL |
1196 |
|
{ |
1197 |
|
if (newInsets == null) |
1198 |
|
newInsets = new Insets(16, 2, 2, 2); |
1199 |
|
else |
1200 |
|
{ |
1201 |
|
newInsets.top = 16; |
1202 |
|
newInsets.left = 2; |
1203 |
|
newInsets.bottom = 2; |
1204 |
|
newInsets.right = 2; |
1205 |
|
} |
1206 |
|
return newInsets; |
1207 |
|
} |
1208 |
|
|
1209 |
|
} |
1210 |
|
|
1211 |
|
/** |
1212 |
|
* Paints the border for the specified component. |
1213 |
|
* |
1214 |
|
* @param c the component. |
1215 |
|
* @param g the graphics device. |
1216 |
|
* @param x the x-coordinate. |
1217 |
|
* @param y the y-coordinate. |
1218 |
|
* @param w the width. |
1219 |
|
* @param h the height. |
1220 |
|
*/ |
1221 |
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, |
1222 |
|
int h) |
1223 |
|
{ |
1224 |
|
|
1225 |
|
JToolBar tb = (JToolBar) c; |
1226 |
|
if (tb.getOrientation() == JToolBar.HORIZONTAL) |
1227 |
|
{ |
1228 |
|
MetalUtils.fillMetalPattern(g, x + 2, y + 2, x + 11, y + h - 5, |
1229 |
|
MetalLookAndFeel.getControlHighlight(), |
1230 |
|
MetalLookAndFeel.getControlDarkShadow()); |
1231 |
|
} |
1232 |
|
else |
1233 |
|
{ |
1234 |
|
MetalUtils.fillMetalPattern(g, x + 2, y + 2, x + w - 5, y + 11, |
1235 |
|
MetalLookAndFeel.getControlHighlight(), |
1236 |
|
MetalLookAndFeel.getControlDarkShadow()); |
1237 |
|
} |
1238 |
|
} |
1239 |
|
|
1240 |
|
} |
1241 |
|
|
1242 |
|
/** |
1243 |
* A border for table header cells. |
* A border for table header cells. |
1244 |
* |
* |
1245 |
* @since 1.3 |
* @since 1.3 |