Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Disappearing Shadow on JFrame



Hello

I am hoping someone on the list can help me out. The following code displays a transparent JFrame with a button. Clicking on the button resizes the window. There are two problems I see when it displays and have not been able to find a solution:

1. When the JFrame is initially displayed, there is no shadow cast by the button. Changing focus away from the JFrame and back again causes it to appear. Why does it not appear initially? FYI, moving the show() to the AWT thread does not change the behaviour.

2. Repeatedly clicking the button to resize the JFrame will cause the shadow to disappear occasionally. What causes this?

I am using Java build 1.4.2-38 and OS X v10.3.5. Any insights would be most appreciated since these 2 problems are affecting a Swing UI I am currently writing. Thanks for any help/insights. The Java code follows:

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class ShadowTest extends JFrame {

  public ShadowTest() {
    super("ShadowTest");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBackground(new Color(0.0f, 0.0f, 0.0f, 0.0f));
    setResizable(false);
    setSize(200, 100);
    JButton b = new JButton("Click Me");
    b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (getHeight() == 100) {
          setSize(200, 200);
        } else {
          setSize(200, 100);
        }
      }
    });
    getContentPane().add(b);
  }

  public static void main(String[] args) {
    new ShadowTest().show();
  }
}

Regards,
David Flett


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.