Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:23:46+00:00 2026-05-26T16:23:46+00:00

I wan’t to make my main JFrame become darken when the focus is on

  • 0

I wan’t to make my main JFrame become darken when the focus is on another window.
This is an example from the game Football Manager 2012. First the main window is selected and it looks like it should, then when it is loading, it turns darker and unselectable. I wan’t to have this effects on my own application, but im not really sure how, not even sure what to google?

Im guessing its a JWindow that appears and the JFram becomes unselectable in the background. I’m planing to use it on a help-window in my application, that is a JWindow right now.

enter image description here
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:23:46+00:00Added an answer on May 26, 2026 at 4:23 pm

    Andrew Thompson has the right idea, only it’s easier to use the glass pane feature of your frame’s JRootPane. Here’s some working code: In your frame class, invoke

    getRootPane().setGlassPane(new JComponent() {
        public void paintComponent(Graphics g) {
            g.setColor(new Color(0, 0, 0, 100));
            g.fillRect(0, 0, getWidth(), getHeight());
            super.paintComponent(g);
        }
    });
    

    Then, to show the “curtain”, invoke

    getRootPane().getGlassPane().setVisible(true);
    

    In the code above, change the alpha transparency value of 100 in order to find the suitable darkness.


    ..wan’t the JFrame to go back to normal after the new window is closed. I tried setVisible(false) but it didn’t work.

    It works in this example.

    Shadowed Frame

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    class ShadowedFrame extends JFrame {
    
        ShadowedFrame() {
            super("Shadowed Frame");
            getRootPane().setGlassPane(new JComponent() {
                public void paintComponent(Graphics g) {
                    g.setColor(new Color(0, 0, 0, 100));
                    g.fillRect(0, 0, getWidth(), getHeight());
                    super.paintComponent(g);
                }
            });
            JButton popDialog = new JButton("Block Frame");
            popDialog.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    getRootPane().getGlassPane().setVisible(true);
                    JOptionPane.showMessageDialog(ShadowedFrame.this, "Shady!");
                    getRootPane().getGlassPane().setVisible(false);
                }
            });
            setContentPane(popDialog);
            pack();
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setLocationByPlatform(true);
            setSize(350,180);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new ShadowedFrame().setVisible(true);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wan't to search a filename for example like this string: $filetype = file.php.jpg;
I wan to get id from the gridview and using this code string UserID
This is my folder structure I wan to call a partialview from my view
I wan't to load some data from my XML file using this function: public
I wan to convert the following code from this $diff = strtotime($row['start']) - strtotime($current);
i wan to retrieve data from query involving many tables. i have a query
I wan't to register the OnMouseOver and OnMouseOut-Event for an Image from the Code
Lets say I wan't to add 1 to an integer. This will only be
i have uitextfield i wan that it should start entering text from top instead
I wan't to redirect www.example.com/folder inlcuding the subfolder and ALL files to land just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.