java.awt.event.HierarchyListener Java Examples

The following examples show how to use java.awt.event.HierarchyListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JFRSnapshotOverviewView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void initComponents(JFRModel model) {
            setLayout(new BorderLayout());
            setOpaque(false);
            
            HTMLTextArea area = new HTMLTextArea("<nobr>" + getGeneralProperties(model) + "</nobr>");    // NOI18N
            area.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8));
            
//            add(area, BorderLayout.CENTER);
            add(model == null ? new ScrollableContainer(area) : area, BorderLayout.CENTER);
            
            if (model != null) addHierarchyListener(new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                        if (isShowing()) {
                            removeHierarchyListener(this);
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() { firstShown(); }
                            });
                        }
                    }
                }
            });
        }
 
Example #2
Source File: WindowsMenuBarUI.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #3
Source File: Lizzie.java    From mylizzie with GNU General Public License v3.0 6 votes vote down vote up
private static void setFileChooserAutoFocusOnTextField(JFileChooser chooser) {
    chooser.addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent he) {
            grabFocusForTextField(chooser.getComponents());
        }

        // Loop to find the JTextField, the first
        // JTextField in JFileChooser
        // Even if you setAccessory which contains a JTextField
        // or which is JTextField itself, it will not get focus
        private void grabFocusForTextField(Component[] components) {
            for (Component component : components) {
                if (component instanceof JTextField) {
                    JTextField textField = (JTextField) component;
                    textField.grabFocus();
                    break;
                } else if (component instanceof JPanel) {
                    JPanel panel = (JPanel) component;
                    grabFocusForTextField(panel.getComponents());
                }
            }
        }
    });
}
 
Example #4
Source File: WindowsMenuBarUI.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #5
Source File: WindowsMenuBarUI.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #6
Source File: WindowsMenuBarUI.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #7
Source File: WindowsMenuBarUI.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #8
Source File: WindowsMenuBarUI.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #9
Source File: WindowsMenuBarUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #10
Source File: WindowsMenuBarUI.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #11
Source File: WindowsMenuBarUI.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #12
Source File: WindowsMenuBarUI.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #13
Source File: WindowsMenuBarUI.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
 
Example #14
Source File: JavaPreviewPlugin.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
InstanceScrollPane() {
            setBorder(BorderFactory.createEmptyBorder());
            setViewportBorder(BorderFactory.createEmptyBorder());
//            setViewportBorder(BorderFactory.createLineBorder(
//                    UIManager.getLookAndFeel().getID().equals("Metal") ? // NOI18N
//                    UIManager.getColor("Button.darkShadow") : // NOI18N
//                    UIManager.getColor("Button.shadow"))); // NOI18N
            
            addHierarchyListener(new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                        if (instancePending && isShowing()) showInstanceImpl();
                    }
                }
            });
            
            showInstanceImpl();
        }
 
Example #15
Source File: HTMLTextComponent.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void addNotify() {
    super.addNotify();
    
    if (neverDisplayed) {
        if (isShowing()) {
            neverDisplayed = false;
            firstDisplayed();
        } else {
            addHierarchyListener(new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && HTMLTextComponent.this.isShowing()) {
                        neverDisplayed = false;
                        HTMLTextComponent.this.removeHierarchyListener(this);
                        HTMLTextComponent.this.firstDisplayed();
                    }
                }
            });
        }
    }
}
 
Example #16
Source File: JTreeTablePanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates a new instance of JTreeTablePanel */
public JTreeTablePanel(JTreeTable treeTable) {
    super(new BorderLayout());
    this.treeTable = treeTable;

    initComponents();
    hookHeaderColumnResize();
    hookScrollBarValueChange();
    hookTreeCollapsedExpanded();

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) {
                    updateScrollBar(true);
                }
            }
        }
    });
}
 
Example #17
Source File: PackagesView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void initListeners(final JComponent view) {
    view.addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (view.isShowing()) {
                    view.removeHierarchyListener(this);
                    loadPackages(view);
                }
            }
        }
    });
    controller.addListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            refreshState(view);
        }
    });
}
 
Example #18
Source File: SamplerImpl.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
DataViewComponent.MasterView getMasterView() {
        initComponents();
        setState(State.INACTIVE);

        final HierarchyListener hl = new HierarchyListener() {
            public void hierarchyChanged(HierarchyEvent e) {
                if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                    if (view.isShowing()) {
                        initializeCpuSampling();
//                        initializeMemorySampling();
                        view.removeHierarchyListener(this);
                    }
                }
            }
        };
        view.addHierarchyListener(hl);

        return new DataViewComponent.MasterView(NbBundle.getMessage(
                   SamplerImpl.class, "LBL_Sampler"), null, view); // NOI18N
    }
 
Example #19
Source File: CPUView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
CPUView(AbstractSamplerSupport.Refresher refresher, CPUSamplerSupport.SnapshotDumper
        snapshotDumper, CPUSamplerSupport.ThreadDumper threadDumper, Application application) {
    this.refresher = refresher;
    this.snapshotDumper = snapshotDumper;
    this.threadDumper = threadDumper;
    
    initComponents(application);

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) CPUView.this.refresher.refresh();
            }
        }
    });
}
 
Example #20
Source File: AboutDialogPanel.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
AboutDialogPanel() {
    initComponents();

    final Runnable repainter = new Runnable() {
        public void run() { AboutDialogPanel.this.repaint(); }
    };
    
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && isShowing()) {
                SwingUtilities.invokeLater(repainter);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() { SwingUtilities.invokeLater(repainter); }
                });
            }
        }
    });
}
 
Example #21
Source File: MemoryView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
MemoryView(Application application, AbstractSamplerSupport.Refresher refresher,
           MemoryMXBean memoryBean, MemorySamplerSupport.SnapshotDumper snapshotDumper,
           MemorySamplerSupport.HeapDumper heapDumper) {

    this.refresher = refresher;

    this.memoryBean = memoryBean;
    this.snapshotDumper = snapshotDumper;
    this.heapDumper = heapDumper;
    
    initComponents(application);

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) MemoryView.this.refresher.refresh();
            }
        }
    });
}
 
Example #22
Source File: TruffleObjectPreviewPlugin.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
InstanceScrollPane() {
            setBorder(BorderFactory.createEmptyBorder());
            setViewportBorder(BorderFactory.createEmptyBorder());
//            setViewportBorder(BorderFactory.createLineBorder(
//                    UIManager.getLookAndFeel().getID().equals("Metal") ? // NOI18N
//                    UIManager.getColor("Button.darkShadow") : // NOI18N
//                    UIManager.getColor("Button.shadow"))); // NOI18N
            
            addHierarchyListener(new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                        if (instancePending && isShowing()) showInstanceImpl();
                    }
                }
            });
            
            showInstanceImpl();
        }
 
Example #23
Source File: SamplerImpl.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
DataViewComponent.MasterView getMasterView() {
    initComponents();
    setState(State.INACTIVE);

    final HierarchyListener hl = new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (view.isShowing()) {
                    initializeCpuSampling();
                    initializeMemorySampling();
                    view.removeHierarchyListener(this);
                }
            }
        }
    };
    view.addHierarchyListener(hl);

    return new DataViewComponent.MasterView(NbBundle.getMessage(
               SamplerImpl.class, "LBL_Sampler"), null, view); // NOI18N
}
 
Example #24
Source File: ThreadsCPUView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
ThreadsCPUView(AbstractSamplerSupport.Refresher refresher, CPUSamplerSupport.ThreadDumper threadDumper) {    
    this.refresher = refresher;
    this.threadDumper = threadDumper;
    
    threads = Collections.EMPTY_LIST;
    threadCPUInfo = Collections.EMPTY_LIST;
    threadCPUInfoPerSec = Collections.EMPTY_LIST;
    
    initComponents();
    
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) ThreadsCPUView.this.refresher.refresh();
            }
        }
    });
}
 
Example #25
Source File: CPUView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
CPUView(AbstractSamplerSupport.Refresher refresher, CPUSamplerSupport.SnapshotDumper
        snapshotDumper, CPUSamplerSupport.ThreadDumper threadDumper, Application application) {
    this.refresher = refresher;
    this.snapshotDumper = snapshotDumper;
    this.threadDumper = threadDumper;
    
    initComponents(application);

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) CPUView.this.refresher.refresh();
            }
        }
    });
}
 
Example #26
Source File: OQLControllerUI.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public QueryUI(OQLController.QueryController queryController, OQLEngine engine) {
    super(Bundle.OQLControllerUI_QueryEditorCaption(), ICON, true);

    this.queryController = queryController;

    initComponents(engine);
    
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) {
                    updateUIState();
                    QueryUI.this.removeHierarchyListener(this);
                }
            }
        }
    });
}
 
Example #27
Source File: InstancesListControllerUI.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
InstanceScrollPane(Heap heap) {
    this.heap = heap;
    
    setBorder(BorderFactory.createEmptyBorder());
    setViewportBorder(BorderFactory.createLineBorder(
            UIManager.getLookAndFeel().getID().equals("Metal") ? // NOI18N
            UIManager.getColor("Button.darkShadow") : // NOI18N
            UIManager.getColor("Button.shadow"))); // NOI18N
    
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (instancePending && isShowing()) showInstanceImpl();
            }
        }
    });
}
 
Example #28
Source File: MemoryView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
MemoryView(Application application, AbstractSamplerSupport.Refresher refresher, int mode,
           MemoryMXBean memoryBean, MemorySamplerSupport.SnapshotDumper snapshotDumper,
           MemorySamplerSupport.HeapDumper heapDumper) {

    this.refresher = refresher;
    this.mode = mode;

    this.memoryBean = memoryBean;
    this.snapshotDumper = snapshotDumper;
    this.heapDumper = heapDumper;
    
    initComponents(application);

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) MemoryView.this.refresher.refresh();
            }
        }
    });
}
 
Example #29
Source File: JTreeTablePanel.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
/** Creates a new instance of JTreeTablePanel */
public JTreeTablePanel(JTreeTable treeTable) {
    super(new BorderLayout());
    this.treeTable = treeTable;

    initComponents();
    hookHeaderColumnResize();
    hookScrollBarValueChange();
    hookTreeCollapsedExpanded();

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) {
                    updateScrollBar(true);
                }
            }
        }
    });
}
 
Example #30
Source File: ThreadsMemoryView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
ThreadsMemoryView(AbstractSamplerSupport.Refresher refresher, MemoryMXBean memoryBean, MemorySamplerSupport.HeapDumper heapDumper) {    
    this.refresher = refresher;
    this.memoryBean = memoryBean;
    this.heapDumper = heapDumper;
    
    threads = Collections.EMPTY_LIST;
    allocatedBytes = Collections.EMPTY_LIST;
    allocatedBytesPerSec = Collections.EMPTY_LIST;
    
    initComponents();
    
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) ThreadsMemoryView.this.refresher.refresh();
            }
        }
    });
}