source: trunk/src/org/expeditee/gui/Popup.java@ 129

Last change on this file since 129 was 129, checked in by bjn8, 16 years ago

removed uneeded item

File size: 1.5 KB
Line 
1package org.expeditee.gui;
2
3import java.awt.BasicStroke;
4import java.awt.Component;
5import java.awt.Container;
6import java.awt.Graphics;
7import java.awt.Graphics2D;
8import java.awt.Stroke;
9
10import javax.swing.JComponent;
11import javax.swing.JPanel;
12
13import org.expeditee.items.WidgetCorner;
14
15/**
16 *
17 * A Custom swing popup in Expeditee.
18 *
19 * @author Brook Novak
20 *
21 */
22public abstract class Popup extends JPanel {
23
24 public static final float BORDER_THICKNESS = WidgetCorner.BORDER_THICKNESS;
25 private static final Stroke _lineStroke = new BasicStroke(BORDER_THICKNESS);
26
27 private boolean _isReadyToPaint = false;
28
29 @Override
30 public void paint(Graphics g) {
31 super.paint(g);
32 // Draw iwidget-like border for consistancy
33 ((Graphics2D)g).setStroke(_lineStroke);
34 g.drawRect(0, 0, getWidth(), getHeight());
35 }
36
37 private void ignoreAWTPainting(Component c) {
38
39 if (c instanceof JComponent) {
40 ((JComponent)c).setDoubleBuffered(false);
41 }
42
43 c.setIgnoreRepaint(true);
44
45 if (c instanceof Container) {
46 for (Component child : ((Container) c).getComponents()) {
47
48 if (child instanceof Container) {
49 ignoreAWTPainting(child);
50 } else {
51 if (child instanceof JComponent) {
52 ((JComponent)child).setDoubleBuffered(false);
53 }
54
55 child.setIgnoreRepaint(true);
56 }
57 }
58 }
59
60 }
61
62 /**
63 * Ensures that AWT painting turned off
64 */
65 void prepareToPaint() {
66 if (!_isReadyToPaint) {
67 _isReadyToPaint = true;
68 ignoreAWTPainting(this);
69 }
70 }
71
72}
Note: See TracBrowser for help on using the repository browser.