summaryrefslogtreecommitdiff
path: root/gnu/java
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-11-14 10:15:58 +0000
committerRoman Kennke <roman@kennke.org>2006-11-14 10:15:58 +0000
commitad8b3babf079c9bb378684ad03d779cb93518240 (patch)
tree267220e7d5b471bc640a7d1d1e0a9e377850a26a /gnu/java
parent48f5065f2194798362625ac881d7c393c5ef5214 (diff)
downloadclasspath-ad8b3babf079c9bb378684ad03d779cb93518240.tar.gz
2006-11-14 Roman Kennke <kennke@aicas.com>
* gnu/java/awt/peer/GLightweightPeer.java (handleEvent): Try to do something reasonable and trigger painting for the lightweight component. (getFontMetrics): Fetch and return a font metrics object from the Toolkit.
Diffstat (limited to 'gnu/java')
-rw-r--r--gnu/java/awt/peer/GLightweightPeer.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/gnu/java/awt/peer/GLightweightPeer.java b/gnu/java/awt/peer/GLightweightPeer.java
index 3029502ff..f9a7bac8e 100644
--- a/gnu/java/awt/peer/GLightweightPeer.java
+++ b/gnu/java/awt/peer/GLightweightPeer.java
@@ -163,8 +163,10 @@ public class GLightweightPeer
public FontMetrics getFontMetrics(Font f)
{
- // Nothing to do here for lightweights.
- return null;
+ // We shouldn't end up here, but if we do we can still try do something
+ // reasonable.
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ return tk.getFontMetrics(f);
}
/* Returning null here tells the Component object that called us to
@@ -201,7 +203,31 @@ public class GLightweightPeer
public void handleEvent(AWTEvent e)
{
- // Nothing to do here for lightweights.
+ // This can only happen when an application posts a PaintEvent for
+ // a lightweight component directly. We still support painting for
+ // this case.
+ if (e instanceof PaintEvent)
+ {
+ PaintEvent pe = (PaintEvent) e;
+ Component target = (Component) e.getSource();
+ if (target != null && target.isShowing())
+ {
+ Graphics g = target.getGraphics();
+ if (g != null)
+ {
+ try
+ {
+ Rectangle clip = pe.getUpdateRect();
+ g.setClip(clip);
+ target.paint(g);
+ }
+ finally
+ {
+ g.dispose();
+ }
+ }
+ }
+ }
}
public void hide()