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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:04:14+00:00 2026-06-04T08:04:14+00:00

I wonder if it possible: to make a jdialog (which can be modal) with

  • 0

I wonder if it possible:

  1. to make a jdialog (which can be modal) with maximize button (is it possible to make custom but which will maximize frame?)
  2. or to make jframe (which has default maximize button) modal?

There lots of topic about this, but I found no clean solutions. Only tricks with setEnabled(), etc.

Thanks everyone in advance!

  • 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-06-04T08:04:14+00:00Added an answer on June 4, 2026 at 8:04 am
    • AFAIK not possible, because Top-Level Containers came from Native OS,

    • then mouse double click to the JFrame’s toolbar resize container to fills whole screen Dimension, second double ćlick restore lastz known Dimension

    • this not possible with JDialog

    • from any of Mouse(Xxx)Listener doesn’t response mouse_events from toolbar that came from Native OS, only from are that fills RootPane

    code example

    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.EventQueue;
    import java.awt.Toolkit;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.MouseAdapter;
    import javax.swing.JDialog;
    import javax.swing.Timer;
    //http://stackoverflow.com/questions/8670297/make-java-swing-modal-dialog-behave-like-mac-osx-dialogs
    public class ModalDialogDemoFrame extends JFrame {
    
        private static final long serialVersionUID = 1L;
        private ModalDialogDemoFrame modalDialogDemo;
    
        public ModalDialogDemoFrame() {
            modalDialogDemo = this;
            setBounds(100, 100, 400, 400);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JButton buttonDialog = new JButton("Open Dialog");
            buttonDialog.addActionListener(new ActionListener() {
    
                public void actionPerformed(ActionEvent arg0) {
                    // Create a Modal Dialog with this Frame as Parent.
                    ModalDialog modalDialog = new ModalDialog(modalDialogDemo, true);
                    modalDialog.setVisible(true);
                }
            });
            getContentPane().add(buttonDialog, BorderLayout.CENTER);
        }
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
    
                public void run() {
                    try {
                        ModalDialogDemoFrame window = new ModalDialogDemoFrame();
                        window.setVisible(true);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    }
    //http://stackoverflow.com/questions/4577424/distinguish-between-a-single-click-and-a-double-click-in-java/4577475#4577475
    class ClickListener extends MouseAdapter implements ActionListener {
    
        private final static int clickInterval = (Integer) Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval");
        private MouseEvent lastEvent;
        private Timer timer;
    
        public ClickListener() {
            this(clickInterval);
        }
    
        public ClickListener(int delay) {
            timer = new Timer(delay, this);
        }
    
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 2) {
                return;
            }
            lastEvent = e;
            if (timer.isRunning()) {
                timer.stop();
                doubleClick(lastEvent);
            } else {
                timer.restart();
            }
        }
    
        @Override
        public void actionPerformed(ActionEvent e) {
            timer.stop();
            singleClick(lastEvent);
        }
    
        public void singleClick(MouseEvent e) {
        }
    
        public void doubleClick(MouseEvent e) {
        }
    }
    
    class ModalDialog extends JDialog {
    
        private static final long serialVersionUID = 1L;
    
        public ModalDialog(JFrame parent, boolean modal) {
            Dimension dimensionParentFrame = parent.getSize();
            setSize(new Dimension((parent == null) ? 300 : dimensionParentFrame.width / 2, 75));
            Dimension dimensionDialog = getSize();
            int x = parent.getX() + ((dimensionParentFrame.width - dimensionDialog.width) / 2);
            setLocation(x, parent.getY() + parent.getInsets().top);
            //setUndecorated(true);
            setModal(modal);
            setModalityType(ModalityType.APPLICATION_MODAL);
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            JButton buttonClose = new JButton("Close");
            buttonClose.addActionListener(new ActionListener() {
    
                public void actionPerformed(ActionEvent e) {
                    dispose();
                }
            });
            add(buttonClose, BorderLayout.CENTER); // comment for listening 
            addMouseListener(new ClickListener() {
    
                @Override
                public void singleClick(MouseEvent e) {
                    System.out.println("single");
                }
    
                @Override
                public void doubleClick(MouseEvent e) {
                    System.out.println("double");
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if it's possible to create an extension method which has functionality &
I wonder if is it possible to run mysql command which can select an
I wonder how could is possible to make custom shape key on android keyboard.
I wonder if it's possible to show a warning or open a pop-up, which
I wonder if it is possible to make your application multilingual by simply creating
i wonder if it's possible to make a RegEx for the following data pattern:
I wonder if it is possible to make Cucumber output matching errors in Russian
I wonder if it possible to make a game by c++ with directx(in GFX)
I wonder if it is possible to make the tracking of a facebook application:
I wonder if it is possible to make transitions between frames smoother in WxPython.

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.