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

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

Fixed popups with widgets. Added custom popup support.

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 private Component _invoker = null;
30
31 @Override
32 public void paint(Graphics g) {
33 super.paint(g);
34 // Draw iwidget-like border for consistancy
35 ((Graphics2D)g).setStroke(_lineStroke);
36 g.drawRect(0, 0, getWidth(), getHeight());
37 }
38
39 private void ignoreAWTPainting(Component c) {
40
41 if (c instanceof JComponent) {
42 ((JComponent)c).setDoubleBuffered(false);
43 }
44
45 c.setIgnoreRepaint(true);
46
47 if (c instanceof Container) {
48 for (Component child : ((Container) c).getComponents()) {
49
50 if (child instanceof Container) {
51 ignoreAWTPainting(child);
52 } else {
53 if (child instanceof JComponent) {
54 ((JComponent)child).setDoubleBuffered(false);
55 }
56
57 child.setIgnoreRepaint(true);
58 }
59 }
60 }
61
62 }
63
64 /**
65 * Ensures that AWT painting turned off
66 */
67 void prepareToPaint() {
68 if (!_isReadyToPaint) {
69 _isReadyToPaint = true;
70 ignoreAWTPainting(this);
71 }
72 }
73
74}
Note: See TracBrowser for help on using the repository browser.