Mailing Lists: Apple Mailing Lists

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

Re: Turning off drop shadow on windows



Thanks Craig. It was very kind of you to do all this for me. I have some code at the minute which uses an undecorated but I have noticed that when the window loses focus and then regains it again, the shadow re-appears. I will have a go with this code and see what happens.

Thanks again :-D


On 2 Oct 2004, at 04:35, Craig Mattocks wrote:

If you prefer to go lightweight with Swing and you can live without a title bar, setUndecorated(true) will zap Aqua shadows automagically for you.

<boo-hoo-hoo>
Oh, those software engineers at Apple, they so cruel, they have no heart.
Their Java-Cocoa technology is too addictive, like bad heroin. I cannot
develop on this platform any longer, there's just too much pain... -sniff-
</boo-hoo-hoo>


- Craig

/**
	Transparent Swing window for Mac OS X.
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class TransFrame extends JFrame
{
	/////////////////
	// Constructor //
	/////////////////
	public TransFrame()
	{
		super("Transparent Frame");

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(new Dimension(400,300));

setBackground(new Color(0f, 1f ,0f, 0.0f)); // Transparent
// setBackground(new Color(0f, 1f ,0f, 0.5f)); // Transparent 50% green
// setBackground(new Color(0f, 1f, 0f, 1.0f)); // Opaque


		setUndecorated(true);	// Zap title bar & shadows

		final JButton b1 = new JButton("Thing One");
		b1.setOpaque(true);
		b1.setBackground(Color.blue);
		b1.setForeground(Color.white);
//		b1.setContentAreaFilled(false);
		b1.setBorderPainted(false);
		b1.setFocusPainted(false);

		final JButton b2 = new JButton("Thing Two");
		b2.setOpaque(true);
		b2.setBackground(Color.red);
		b2.setForeground(Color.white);
//		b2.setContentAreaFilled(false);
		b2.setBorderPainted(false);
		b2.setFocusPainted(false);

		final JPanel p = new JPanel(new GridLayout(2,1, 10,10));
		p.setOpaque(false);
		p.add(b1);
		p.add(b2);

		final JPanel cp = new JPanel(new BorderLayout());
		cp.setOpaque(false);
		cp.setBorder(BorderFactory.createEmptyBorder(36,36,36,36));
		cp.add(p, BorderLayout.CENTER);
		setContentPane(cp);
	}

	public static void main(final String args[])
	{
		final TransFrame f = new TransFrame();

		SwingUtilities.invokeLater
		(
			new Runnable()
			{
				public void run()
				{
					f.setVisible(true);
				}
			}
		);
	}
}


_______________________________________________ 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
References: 
 >Re: Turning off drop shadow on windows (From: Craig Mattocks <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.