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 7653141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:57:09+00:00 2026-05-31T11:57:09+00:00

I have a main frame and a second frame and a modal dialog with

  • 0

I have a main frame and a second frame and a modal dialog with the main frame as parent.

But now are both frames blocked by the modal dialog.
How can I let the second frame accessable while the main frame has a modal dialog?

public class Example extends JFrame {

    public Example() {
        super("MainFrame");

        JButton btn1 = new JButton( new AbstractAction( "Frame" ) {
            @Override
            public void actionPerformed( ActionEvent e ) {
                EventQueue.invokeLater( new Runnable() {
                    @Override
                    public void run() {
                        JFrame f = new JFrame( "Frame" );
                        f.getContentPane().add( new JLabel("This shoud be not blocked by ModalDialog.") );
                        f.setLocation( 50, 200 );
                        f.setSize( 300, 200 );
                        f.setVisible( true );
                    }
                } );
            }
        } );

        JButton btn2 = new JButton( new AbstractAction( "Modal" ) {
            @Override
            public void actionPerformed( ActionEvent e ) {
                EventQueue.invokeLater( new Runnable() {
                    @Override
                    public void run() {
                        JDialog d = new JDialog( Example.this, "Dialog" );
                        d.getContentPane().add( new JLabel("This shoud block only MainFrame.") );
                        d.setModal( true );
                        d.setLocation( 50, 100 );
                        d.setSize( 300, 200 );
                        d.setVisible( true );
                    }
                } );
            }
        } );

        setDefaultCloseOperation( EXIT_ON_CLOSE );
        getContentPane().setLayout( new BorderLayout() );
        getContentPane().add( btn1, BorderLayout.NORTH );
        getContentPane().add( new JLabel("MainFrame"), BorderLayout.CENTER );
        getContentPane().add( btn2, BorderLayout.SOUTH);
        setLocation( 50, 50 );
        setSize( 200, 150 );

        btn1.doClick();
        btn2.doClick();
    }

    public static void main( String[] args ) {
        EventQueue.invokeLater( new Runnable() {
            @Override
            public void run() {
                new Example().setVisible( true );
            }
        } );
    }

}
  • 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-31T11:57:11+00:00Added an answer on May 31, 2026 at 11:57 am

    you need to set modality field to document.

    JDialog d = new JDialog( Example.this, "Dialog" ,Dialog.ModalityType.DOCUMENT_MODAL); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a window(say main window) with a frame which has a page in
I have a wx.Frame, in which there is a main wx.Panel with several widgets
I have a main JFrame. There is a button inside the frame. When I
I have put a label into my frame, but it refuses to move. SetBounds()
I have three JPanels inside a main Frame. Clockwise from the left, in the
I have main categories and sub categories. I want to be able to sort
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
i have main activity in which i have Four menus. and i have one
I have main.cpp (including main function) and func1.cpp, and I want to link these
i have a table called category in which i have main category ids and

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.