Link to home
Start Free TrialLog in
Avatar of tomschuring1
tomschuring1

asked on

JDialog minimizing

Hello,

I was wondering if the top level JDialog can have a minimize button ? I found how to do it for a JInternalFrame but I don't think I can use this as my top level window for the application (is this correct ?)

------ code----------
ABConsole m_console = new ABConsole();
m_console.show();
------ end code------

where :

ABConsole is

------ code----------
public class ABConsole extends JDialog
{
.....
}
------ end code------

what do I need to do to enable the "minimize" button in the title bar?
ASKER CERTIFIED SOLUTION
Avatar of Sendoh
Sendoh
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try this,

public class ABConsole extends javax.swing.JDialog {

    public ABConsole(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    private void initComponents() {
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });
       
        pack();
    }

    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {
        setVisible(false);
        dispose();
     System.exit(1);
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
     new ABConsole(new javax.swing.JFrame(), true).show();
    }
}
Avatar of tomschuring1
tomschuring1

ASKER

Hi Kotan, that just kills the whole dialog. I was looking for a minimize button.
perhaps it is 'abusing' the JDialog functionality. I decided to go with a Frame instead. thanks