Results 1 to 5 of 5

Thread: How to create Translucent and Shaped Windows in Java?

  1. #1
    Join Date
    Jul 2006
    Posts
    218

    How to create Translucent and Shaped Windows in Java?

    Hi friends,
    I have just done some basic things with the core Java. I just want to create a translucent and shaped windows for my application. I have tried lot of different things but was not getting the desired result. So anyone can help me by telling how to create Translucent and Shaped Windows in Java.?? Please help me as soon as possible.!!
    ~*~Silent~Kid~*~
    "To The World You May Be Just One Person, But To One Person You May Be The World"

  2. #2
    Join Date
    Nov 2008
    Posts
    996

    Re: How to create Translucent and Shaped Windows in Java?

    Since you are the starter, I thought to tell you about the inner Translucency enum which is very useful for creating the translucent and shaped Windows. The inner Translucency enum has three values has three values which are described as follows :
    1. Translucent - This value has ability to create a translucent window.
    2. PerPixel_Transparent - This value has ability to create a shaped window.
    3. PerPixel_Transslucent - This value has ability to create a translucent shaped window'.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,192

    Re: How to create Translucent and Shaped Windows in Java?

    You can also test the translucency mode and can also test that specific GraphicsConfiguration supports translucency or not. If you want to test support for a specific translucency mode, you can use the following :
    • AWTUtilities.isTranslucencySupported(Translucency) API.

    And if you want to test whether the specific GraphicsConfiguration supports translucency, you can use :
    • AWTUtilities.isTranslucencyCapable(GraphicsConfiguration) API.

  4. #4
    Join Date
    Jul 2006
    Posts
    289

    Re: How to create Translucent and Shaped Windows in Java?

    The three values of inner Translucency enum described by the 'CodGuru' can also be checked. For checking that values, you can use the following code :
    Code:
    import static java.awt.GraphicsDevice.WindowTranslucency.*;
    
    GraphicsEnvironment grapen =
        GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice grapd = grapen.getDefaultScreenDevice();
    
    boolean isUniformTranslucencySupported =
        grapd.isWindowTranslucencySupported(TRANSLUCENT);
    boolean isPerPixelTranslucencySupported =
        grapd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
    boolean isShapedWindowSupported =
        grapd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);
    Signatures reduce available bandwidth

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to create Translucent and Shaped Windows in Java?

    The following example creates a window that is 55 percent translucent and 45 percent opaque.
    Code:
    import java.awt.*;
    import javax.swing.*;
    import static java.awt.GraphicsDevice.WindowTranslucency.*;
    
    public class TranslucentWindow extends JFrame {
        public TranslucentWindow() {
            super("TranslucentWindow");
            setLayout(new GridBagLayout());
    
            setSize(330,180);
            setLocationRelativeTo(null);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            add(new JButton("This is Button"));
        }
    
        public static void main(String[] args) {
            GraphicsEnvironment ge = 
                GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gd = ge.getDefaultScreenDevice();
    
            if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) {
                System.err.println(
                    "Translucency is not supported");
                    System.exit(0);
            }
    
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    TranslucentWindow tw = new TranslucentWindow();
    
                    tw.setOpacity(0.45f);
    
    		tw.setVisible(true);
    	    }
            });
        }
    }

Similar Threads

  1. Telephone-shaped USB hub
    By bishop in forum Portable Devices
    Replies: 3
    Last Post: 09-05-2012, 01:46 PM
  2. Replies: 6
    Last Post: 24-01-2012, 01:18 PM
  3. JavaScript for Translucent Scroller
    By hatred in forum Software Development
    Replies: 4
    Last Post: 07-02-2010, 01:23 AM
  4. How to create object in JAVA
    By HP_Crook in forum Software Development
    Replies: 3
    Last Post: 09-10-2009, 11:52 PM
  5. Translucent taskbar
    By Jokerz in forum Customize Desktop
    Replies: 2
    Last Post: 05-12-2008, 04:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,303,213.35617 seconds with 17 queries