views:

37

answers:

1

I'm trying to accomplish an undock effect for a custom Swing JComponent. By default the component is used inside a form along with other components. I want to be able to maximize this component to use the whole screen and then be able to dock it again. So far I've tested

    public void showDialog() {
    JFrame mainFrame = App.getApplication().getMainFrame();
    JDialog dialog = new JDialog(mainFrame);
    dialog.setModal(true);
    dialog.setSize(800, 600); //Set to 80x660 for now
    dialog.add(this); //This is my JComponent
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
}

This gives me desired effect but when closing the dialog my component doesn't receive events no more. How can I prevent this?

Or is there perhaps a better way to accomplish this?

+2  A: 

Maybe you should take a look at Java docking frameworks. i've recently answered such a question : http://stackoverflow.com/questions/2431262/how-to-create-docking-panel-in-java/2431413#2431413 I would suggest you take a look at those docking frameworks, which may directly answer your need.

Riduidel