Results 1 to 2 of 2
  1. #1
    tim8w is offline Member
    Join Date
    Jan 2013
    Posts
    9
    Rep Power
    0

    Default Click in JFrame Titlebar sets the JFrame Opaque

    Hi,
    I have a JFrame that I would like to set Opaque when the MouseButton is held down on the TitleBar and moved and returns to solid when released. I have two problems.

    (1) The only way I could get the Opacity to work was by setting: JFrame.setDefaultLookAndFeelDecorated(true); This works but changes the Titlebar to a really ugly non-Windows look and feel Titlebar. Would like it to work without changing the Windws look and feel.
    (2) Second problem is that when I click on the Titlebar, I cannot move the JFrame.


    Java Code:
        JFrame.setDefaultLookAndFeelDecorated(true);
    
        win=new JFrame("Calculator");
        win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        win.setBounds(400,200,335,630);
        win.setResizable(false);
        win.setFocusable(true);
    		
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        if (!gd.isWindowTranslucencySupported(TRANSLUCENT))
        {
            System.err.println("Translucency is not supported");
        } 
        win.getLayeredPane().getComponent(1).addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me){
    	    win.setOpacity(0.65f);
            }
            public void mouseReleased(MouseEvent me){
    	    win.setOpacity(1.0f);
            }
        });

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,918
    Rep Power
    16

    Default Re: Click in JFrame Titlebar sets the JFrame Opaque

    Cross posted
    Click in JFrame Titlebar sets the JFrame Opaque (Swing / AWT / SWT forum at JavaRanch)

    Didn't bother to reply to one response there before posting here.

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

Similar Threads

  1. Replies: 8
    Last Post: 02-23-2012, 06:08 PM
  2. Replies: 3
    Last Post: 11-27-2011, 05:18 AM
  3. Replies: 5
    Last Post: 06-14-2010, 06:10 PM
  4. Replies: 4
    Last Post: 04-22-2009, 11:02 PM
  5. How to detect double click with a JFrame
    By Jary316 in forum New To Java
    Replies: 3
    Last Post: 01-05-2009, 08:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •