45 |
|
|
46 |
import javax.swing.AbstractButton; |
import javax.swing.AbstractButton; |
47 |
import javax.swing.ButtonModel; |
import javax.swing.ButtonModel; |
48 |
import javax.swing.JButton; |
import javax.swing.JInternalFrame; |
49 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
50 |
import javax.swing.JMenuBar; |
import javax.swing.JMenuBar; |
51 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
53 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
54 |
import javax.swing.plaf.BorderUIResource; |
import javax.swing.plaf.BorderUIResource; |
55 |
import javax.swing.plaf.UIResource; |
import javax.swing.plaf.UIResource; |
|
import javax.swing.plaf.basic.BasicGraphicsUtils; |
|
56 |
import javax.swing.plaf.basic.BasicBorders; |
import javax.swing.plaf.basic.BasicBorders; |
57 |
|
|
58 |
/** |
/** |
186 |
} |
} |
187 |
|
|
188 |
/** |
/** |
189 |
|
* A border used when painting {@link JInternalFrame} instances. |
190 |
|
*/ |
191 |
|
public static class InternalFrameBorder extends AbstractBorder |
192 |
|
implements UIResource |
193 |
|
{ |
194 |
|
/** |
195 |
|
* Creates a new border instance. |
196 |
|
*/ |
197 |
|
public InternalFrameBorder() |
198 |
|
{ |
199 |
|
} |
200 |
|
|
201 |
|
/** |
202 |
|
* Returns the border insets. |
203 |
|
* |
204 |
|
* @param c the component (ignored). |
205 |
|
* |
206 |
|
* @return The border insets. |
207 |
|
*/ |
208 |
|
public Insets getBorderInsets(Component c) |
209 |
|
{ |
210 |
|
return getBorderInsets(c, null); |
211 |
|
} |
212 |
|
|
213 |
|
/** |
214 |
|
* Returns the border insets. |
215 |
|
* |
216 |
|
* @param c the component (ignored). |
217 |
|
* @return The border insets. |
218 |
|
*/ |
219 |
|
public Insets getBorderInsets(Component c, Insets newInsets) |
220 |
|
{ |
221 |
|
if (newInsets == null) |
222 |
|
newInsets = new Insets(5, 5, 5, 5); |
223 |
|
else |
224 |
|
{ |
225 |
|
newInsets.top = 5; |
226 |
|
newInsets.left = 5; |
227 |
|
newInsets.bottom = 5; |
228 |
|
newInsets.right = 5; |
229 |
|
} |
230 |
|
return newInsets; |
231 |
|
} |
232 |
|
|
233 |
|
/** |
234 |
|
* Paints the border for the specified component. |
235 |
|
* |
236 |
|
* @param c the component. |
237 |
|
* @param g the graphics device. |
238 |
|
* @param x the x-coordinate. |
239 |
|
* @param y the y-coordinate. |
240 |
|
* @param w the width. |
241 |
|
* @param h the height. |
242 |
|
*/ |
243 |
|
public void paintBorder(Component c, Graphics g, int x, int y, int w, |
244 |
|
int h) |
245 |
|
{ |
246 |
|
|
247 |
|
JInternalFrame f = (JInternalFrame) c; |
248 |
|
if (f.isSelected()) |
249 |
|
g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); |
250 |
|
else |
251 |
|
g.setColor(MetalLookAndFeel.getControlDarkShadow()); |
252 |
|
|
253 |
|
// fill the border background |
254 |
|
g.fillRect(x, y, w, 5); |
255 |
|
g.fillRect(x, y, 5, h); |
256 |
|
g.fillRect(x + w - 5, y, 5, h); |
257 |
|
g.fillRect(x, y + h - 5, w, 5); |
258 |
|
|
259 |
|
// draw a dot in each corner |
260 |
|
g.setColor(MetalLookAndFeel.getControl()); |
261 |
|
g.fillRect(x, y, 1, 1); |
262 |
|
g.fillRect(x + w - 1, y, 1, 1); |
263 |
|
g.fillRect(x + w - 1, y + h - 1, 1, 1); |
264 |
|
g.fillRect(x, y + h - 1, 1, 1); |
265 |
|
|
266 |
|
// draw the lines |
267 |
|
g.setColor(MetalLookAndFeel.getBlack()); |
268 |
|
g.drawLine(x + 14, y + 2, x + w - 15, y + 2); |
269 |
|
g.drawLine(x + 14, y + h - 3, x + w - 15, y + h - 3); |
270 |
|
g.drawLine(x + 2, y + 14, x + 2, y + h - 15); |
271 |
|
g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15); |
272 |
|
|
273 |
|
// draw the line highlights |
274 |
|
g.setColor(MetalLookAndFeel.getControl()); |
275 |
|
g.drawLine(x + 15, y + 3, x + w - 14, y + 3); |
276 |
|
g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2); |
277 |
|
g.drawLine(x + 3, y + 15, x + 3, y + h - 14); |
278 |
|
g.drawLine(x + w - 2, y + 15, x + w - 2, y + h - 14); |
279 |
|
} |
280 |
|
|
281 |
|
} |
282 |
|
|
283 |
|
/** |
284 |
* A border used for {@link JMenu} and {@link JMenuItem} components. |
* A border used for {@link JMenu} and {@link JMenuItem} components. |
285 |
*/ |
*/ |
286 |
public static class MenuItemBorder |
public static class MenuItemBorder |