Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to use glassPane to create transparent window?  (Read 2948 times)
0 Members and 1 Guest are viewing this topic.
Offline CyanPrime
« Posted 2010-10-30 21:06:31 »

Okay, so I wanna make a Java JFrame that is transparent, but than has a the glassPane not transparent so I can make my own style of windows. can this be done?
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #1 - Posted 2010-10-30 21:23:46 »

Try here Wink

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline CyanPrime
« Reply #2 - Posted 2010-10-30 21:27:27 »

I have googled it :\
I wouldn't be asking if I didn't lol.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #3 - Posted 2010-10-30 21:45:21 »

I have googled it :\
I wouldn't be asking if I didn't lol.

I'm confused; the very first link from Google gives you an exhaustive explanation of how translucent windows (including demos!) are implemented in Java?

An updated version of the tutorial can be found here.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline CyanPrime
« Reply #4 - Posted 2010-10-30 22:03:36 »

I'm confused; the very first link from Google gives you an exhaustive explanation of how translucent windows (including demos!) are implemented in Java?

An updated version of the tutorial can be found here.
AWTUtilities isn't used anymore T_T

PS does Java 1.7 have anything new for transparent windows and other eye-candy?

Offline zammbi

JGO Coder


Medals: 4



« Reply #5 - Posted 2010-10-31 04:27:52 »

This has example code for both Java 6 and 7: http://www.pushing-pixels.org/?p=1886

Current project - Rename and Sort
Offline CyanPrime
« Reply #6 - Posted 2010-10-31 20:53:10 »

I just bit the bullet and used AWTUtils. Now I have a new problem though:

I'm trying to draw a solid red oval on a transparent window. I later want to do something more complex with multiple shapes, so using setWindowShape isn't what I'm looking for. This is the code I'm using so far:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
import java.awt.*;
import javax.swing.*;

public class JavaDock extends JFrame{

    public JavaDock(){
        super("This is a test");

        setSize(400, 150);

        setUndecorated(true);
        getContentPane().setLayout(new FlowLayout());
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         JPanel panel = new JPanel()  
         {  
            public void paintComponent(Graphics g)  
            {  
               Graphics2D g2d = (Graphics2D) g.create();
               g2d.setComposite(AlphaComposite.Clear);
               g.setColor(Color.red);  

               //Draw an oval in the panel  
              g.fillOval(10, 10, getWidth() - 20, getHeight() - 20);  
            }  
         };

        panel.setOpaque(false);
        setGlassPane(panel);  
        getGlassPane().setVisible(true);
        com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.5f);
        setVisible(true);
    }

     protected void paintComponent(Graphics g) {

        }

     public static void main(String[] args){
         JavaDock jd = new JavaDock();
     }
}
Offline CyanPrime
« Reply #7 - Posted 2010-11-01 08:55:48 »

bump
Offline zammbi

JGO Coder


Medals: 4



« Reply #8 - Posted 2010-11-01 13:01:42 »

Good info here: http://download.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html

About soft clipping: http://www.pushing-pixels.org/?p=272

If you want to use a JNA library instead (to allow older Java versions) read: http://rabbit-hole.blogspot.com/

I believe SWT also has such features too.

Current project - Rename and Sort
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (32 views)
2014-07-18 06:55:21

Zero Volt (28 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (25 views)
2014-07-16 23:30:00

Cero (40 views)
2014-07-16 00:42:17

Riven (42 views)
2014-07-14 18:02:53

OpenGLShaders (29 views)
2014-07-14 16:23:47

Riven (29 views)
2014-07-14 11:51:35

quew8 (26 views)
2014-07-13 13:57:52

SHC (63 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!