To Make Window groups for Non Sigleton Windows

To Make Window groups for Non Sigleton Windows, choose one window as the main window,,i.e., that is the second window can be opened and closed only when first one is present.
For example, in my case I have two singleton windows ( as have been described in a different post How to make Singleton windows) or two TopComponents, AlignmentFilterOption and AlignmentView. Here, I have choosen AlignmentFilterOption a my main window.

Now in the AlignmentFilterOption TopComponent, (main window) make following changes:
1. make a private TopComponent object and define it as AlignmentView in the constructor

private TopComponent tc;

tc = new AlignmentView(this.ado.getAlignment());

2.  In componentOpened() function, add AlignmentView object, so that whenever AlignmentFilterOption window is opened, AlignmentView widnow also opens.

@Override
    public void componentOpened() {
       
        if (tc != null) {
            tc.open();
       }
    }

3. In componentClosed() function add tc.close(); so that whenever AlignmentFilterOption window is closed, AlignmentView widnow also closes.
@Override
    public void componentClosed() {
         tc.close();
   }

4.  In componentActivated()add following
@Override
    public void componentActivated() {
       tc.putClientProperty("netbeans.winsys.tc.closing_disabled", Boolean.TRUE);
    }

so that while AlignmentFilterOption window is active, AlignmentView widnow cannot be closed.

That's it, add you get a new Window group of you non-singleton TopComponents.

Comments

Popular posts from this blog

Printing of large double values in JAVA with or without scientific notation

To increase the size of heap memory for a Netbeans project

Adding/Updating Java projects from existing sources to Netbeans Project