All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.TransparentJFrameTest Maven / Gradle / Ivy

Go to download

A Mavenisation of the Quaqua Mac OSX Swing Look and Feel (Java library) Quaqua Look and Feel (C) 2003-2010, Werner Randelshofer. Mavenisation by Matt Gumbley, DevZendo.org - for problems with Mavenisation, see Matt; for issues with Quaqua, see the Quaqua home page. For full license details, see http://randelshofer.ch/quaqua/license.html

The newest version!
/*
 * @(#)TransparentJFrameTest.java
 *
 * Copyright (c) 2003-2010 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer.
 * You may not use, copy or modify this software, except in
 * accordance with the license agreement you entered into with
 * Werner Randelshofer. For details see accompanying license terms.
 */
package test;

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

/**
 * Transparent JFrame test.
 *
 * @author Werner Randelshofer
 * @version $Id: TransparentJFrameTest.java 363 2010-11-21 17:41:04Z wrandelshofer $
 */
public class TransparentJFrameTest extends javax.swing.JFrame {
    
    /**
     * Creates new form TransparentJFrameTest
     */
    public TransparentJFrameTest() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        getRootPane().putClientProperty(
                "apple.awt.draggableWindowBackground", Boolean.FALSE
                );
        setLayout(new FlowLayout());
        
        setBackground(new Color(0x80000000,true));
        //((JComponent) getContentPane()).setOpaque(true);
        //((JComponent) getContentPane()).setBackground(Color.LIGHT_GRAY);
        
        JPanel p = new JPanel() {
            public void paintComponent(Graphics gr) {
                super.paintComponents(gr);
                Graphics2D g = (Graphics2D) gr;
                g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
                g.setColor(new Color(0,true));
                g.fillOval(0,0,getWidth(),getHeight());
            }
        };
        p.setPreferredSize(new Dimension(60,60));
        getContentPane().add(p);
        setSize(300,300);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new java.awt.FlowLayout());

        pack();
    }// //GEN-END:initComponents
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TransparentJFrameTest().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy