Dúvida

Preciso de uma ajudinha aqui.

Primeiro: Quero criar duas Janelas Jframe, em uma só, sendo que a primeira deve estar desativada, enquanto a outra estiver em uso.
E na barra de ferramentas, deve aparecer como se só uma janela estivesse aberta, e a outra seria submissa a ela.
Tem como fazer?

Segundo : como definir a ação do botão x da janela?
eu só sei usar o setdefaultcloseoperation();

<marquee>Agradeço se ajudarem</marquee>

A primeira é uma JFrame e a segunda, terceira, quarta etc. JDialogs.
Cada JFrame que você criar no seu programa é um botão na barra de tarefas.

[quote=entanglement]A primeira é uma JFrame e a segunda, terceira, quarta etc. JDialogs.
Cada JFrame que você criar no seu programa é um botão na barra de tarefas.
[/quote]

Eu sei, mas um amigo meu disse que não dá de add um JMenu nessa dialog, tem como?

package guj;

import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Window;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

public class ExemploJDialog extends JDialog {

    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JPanel pnlBotoes = null;
    private JButton btnOK = null;

    public ExemploJDialog() {
        super();
        initialize();
    }

    public ExemploJDialog(Frame owner) {
        super(owner);
        initialize();
    }

    public ExemploJDialog(Dialog owner) {
        super(owner);
        initialize();
    }

    public ExemploJDialog(Window owner) {
        super(owner);
        initialize();
    }

    public ExemploJDialog(Frame owner, boolean modal) {
        super(owner, modal);
        initialize();
    }

    public ExemploJDialog(Frame owner, String title) {
        super(owner, title);
        initialize();
    }

    public ExemploJDialog(Dialog owner, boolean modal) {
        super(owner, modal);
        initialize();
    }

    public ExemploJDialog(Dialog owner, String title) {
        super(owner, title);
        initialize();
    }

    public ExemploJDialog(Window owner, ModalityType modalityType) {
        super(owner, modalityType);
        initialize();
    }

    public ExemploJDialog(Window owner, String title) {
        super(owner, title);
        initialize();
    }

    public ExemploJDialog(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        initialize();
    }

    public ExemploJDialog(Dialog owner, String title, boolean modal) {
        super(owner, title, modal);
        initialize();
    }

    public ExemploJDialog(Window owner, String title, ModalityType modalityType) {
        super(owner, title, modalityType);
        initialize();
    }

    public ExemploJDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) {
        super(owner, title, modal, gc);
        initialize();
    }

    public ExemploJDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) {
        super(owner, title, modal, gc);
        initialize();
    }

    public ExemploJDialog(Window owner, String title, ModalityType modalityType, GraphicsConfiguration gc) {
        super(owner, title, modalityType, gc);
        initialize();
    }

    private void initialize() {
        this.setSize(200, 100);
        this.setTitle("Exemplo de JDialog");
        this.setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getPnlBotoes(), BorderLayout.SOUTH);
        }
        return jContentPane;
    }

    private JPanel getPnlBotoes() {
        if (pnlBotoes == null) {
            pnlBotoes = new JPanel();
            pnlBotoes.setLayout(new FlowLayout());
            pnlBotoes.add(getBtnOK(), null);
        }
        return pnlBotoes;
    }

    private JButton getBtnOK() {
        if (btnOK == null) {
            btnOK = new JButton();
            btnOK.setText("OK");
            btnOK.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    dispose();
                }
            });
        }
        return btnOK;
    }
}
package guj;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class ExemploJFrame extends JFrame {

    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JPanel pnlBotoes = null;
    private JButton btnTeste = null;

    private JPanel getPnlBotoes() {
        if (pnlBotoes == null) {
            pnlBotoes = new JPanel();
            pnlBotoes.setLayout(new FlowLayout());
            pnlBotoes.add(getBtnTeste(), null);
        }
        return pnlBotoes;
    }

    private JButton getBtnTeste() {
        if (btnTeste == null) {
            btnTeste = new JButton();
            btnTeste.setText("Chame o JDialog Teste");
            btnTeste.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    ExemploJDialog ejd = new ExemploJDialog (ExemploJFrame.this);
                    ejd.setModal(true);
                    ejd.setVisible(true);
                }
            });
        }
        return btnTeste;
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                final ExemploJFrame ejf = new ExemploJFrame();
                ejf.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                ejf.addWindowListener(new WindowAdapter() {
                    @Override
                    public void windowClosing(WindowEvent e) {
                        int opcoes = JOptionPane.showConfirmDialog (ejf, "Deseja sair?", "Exemplo JFrame + JDialog",
                            JOptionPane.YES_NO_OPTION);
                        if (opcoes == JOptionPane.YES_OPTION) {
                            ejf.dispose();
                            System.exit (0);
                        }
                    }
                });
                ejf.setVisible(true);
            }
        });
    }

    public ExemploJFrame() {
        super();
        initialize();
    }

    private void initialize() {
        this.setSize(300, 200);
        this.setContentPane(getJContentPane());
        this.setTitle("Exemplo de JFrame");
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getPnlBotoes(), BorderLayout.SOUTH);
        }
        return jContentPane;
    }
}

Quem te disse que JDialogs não podem ter menus? Vou postar o JDialog com menu para você ver.

package guj;

import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Window;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import java.awt.event.KeyEvent;
import javax.swing.JMenuItem;

public class ExemploJDialog extends JDialog {

    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JPanel pnlBotoes = null;
    private JButton btnOK = null;
    private JMenuBar mbarDialog = null;
    private JMenu mnuFile = null;
    private JMenuItem mniFileOpen = null;
    private JMenuItem mniFileExit = null;

    public ExemploJDialog() {
        super();
        initialize();
    }

    public ExemploJDialog(Frame owner) {
        super(owner);
        initialize();
    }

    public ExemploJDialog(Dialog owner) {
        super(owner);
        initialize();
    }

    public ExemploJDialog(Window owner) {
        super(owner);
        initialize();
    }

    public ExemploJDialog(Frame owner, boolean modal) {
        super(owner, modal);
        initialize();
    }

    public ExemploJDialog(Frame owner, String title) {
        super(owner, title);
        initialize();
    }

    public ExemploJDialog(Dialog owner, boolean modal) {
        super(owner, modal);
        initialize();
    }

    public ExemploJDialog(Dialog owner, String title) {
        super(owner, title);
        initialize();
    }

    public ExemploJDialog(Window owner, ModalityType modalityType) {
        super(owner, modalityType);
        initialize();
    }

    public ExemploJDialog(Window owner, String title) {
        super(owner, title);
        initialize();
    }

    public ExemploJDialog(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        initialize();
    }

    public ExemploJDialog(Dialog owner, String title, boolean modal) {
        super(owner, title, modal);
        initialize();
    }

    public ExemploJDialog(Window owner, String title, ModalityType modalityType) {
        super(owner, title, modalityType);
        initialize();
    }

    public ExemploJDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) {
        super(owner, title, modal, gc);
        initialize();
    }

    public ExemploJDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) {
        super(owner, title, modal, gc);
        initialize();
    }

    public ExemploJDialog(Window owner, String title, ModalityType modalityType, GraphicsConfiguration gc) {
        super(owner, title, modalityType, gc);
        initialize();
    }

    private void initialize() {
        this.setSize(200, 100);
        this.setJMenuBar(getMbarDialog());
        this.setTitle("Exemplo de JDialog");
        this.setContentPane(getJContentPane());
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getPnlBotoes(), BorderLayout.SOUTH);
        }
        return jContentPane;
    }

    private JPanel getPnlBotoes() {
        if (pnlBotoes == null) {
            pnlBotoes = new JPanel();
            pnlBotoes.setLayout(new FlowLayout());
            pnlBotoes.add(getBtnOK(), null);
        }
        return pnlBotoes;
    }

    private JButton getBtnOK() {
        if (btnOK == null) {
            btnOK = new JButton();
            btnOK.setText("OK");
            btnOK.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    dispose();
                }
            });
        }
        return btnOK;
    }

    private JMenuBar getMbarDialog() {
        if (mbarDialog == null) {
            mbarDialog = new JMenuBar();
            mbarDialog.add(getMnuFile());
        }
        return mbarDialog;
    }

    private JMenu getMnuFile() {
        if (mnuFile == null) {
            mnuFile = new JMenu();
            mnuFile.setText("File");
            mnuFile.setMnemonic(KeyEvent.VK_M);
            mnuFile.add(getMniFileOpen());
            mnuFile.add(getMniFileExit());
        }
        return mnuFile;
    }

    private JMenuItem getMniFileOpen() {
        if (mniFileOpen == null) {
            mniFileOpen = new JMenuItem();
            mniFileOpen.setText("Open");
            mniFileOpen.setMnemonic(KeyEvent.VK_O);
        }
        return mniFileOpen;
    }

    private JMenuItem getMniFileExit() {
        if (mniFileExit == null) {
            mniFileExit = new JMenuItem();
            mniFileExit.setText("Exit");
            mniFileExit.setMnemonic(KeyEvent.VK_X);
            mniFileExit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    int opcoes = JOptionPane.showConfirmDialog (ExemploJDialog.this, "Deseja sair?", "Exemplo JFrame + JDialog",
                        JOptionPane.YES_NO_OPTION);
                    if (opcoes == JOptionPane.YES_OPTION) {
                        dispose();
                    }
                }
            });
        }
        return mniFileExit;
    }
}