Java Code Examples for javax.swing.JPanel.addHierarchyListener()

The following are Jave code examples for showing how to use addHierarchyListener() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: ClassesControllerUI.java   View Source Code Vote up 5 votes
private void initComponents() {
    setLayout(new BorderLayout());

    final JPanel staticFieldsBrowserPanel = classesController.getStaticFieldsBrowserController().getPanel();
    staticFieldsBrowserPanel.setPreferredSize(new Dimension(250, 500));
    staticFieldsBrowserPanel.setVisible(false);

    contentsSplit = new JExtendedSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                           classesController.getClassesListController().getPanel(), staticFieldsBrowserPanel);
    contentsSplit.setResizeWeight(1d);

    final JPanel legendPanel = new LegendPanel(false);
    legendPanel.setVisible(false);

    tweakSplitPaneUI(contentsSplit);

    add(contentsSplit, BorderLayout.CENTER);
    add(legendPanel, BorderLayout.SOUTH);

    staticFieldsBrowserPanel.addHierarchyListener(new HierarchyListener() {
            public void hierarchyChanged(HierarchyEvent e) {
                if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                    legendPanel.setVisible(staticFieldsBrowserPanel.isShowing());
                }
            }
        });
}
 
Example 2
Project: incubator-netbeans   File: InstancesControllerUI.java   View Source Code Vote up 4 votes
private void initComponents() {
    JPanel fieldsBrowserPanel = instancesController.getFieldsBrowserController().getPanel();
    JPanel referencesBrowserPanel = instancesController.getReferencesBrowserController().getPanel();
    JPanel instancesListPanel = instancesController.getInstancesListController().getPanel();

    browsersSplit = new JExtendedSplitPane(JSplitPane.VERTICAL_SPLIT, fieldsBrowserPanel, referencesBrowserPanel);
    tweakSplitPaneUI(browsersSplit);
    browsersSplit.setResizeWeight(0.5d);

    contentsSplit = new JExtendedSplitPane(JSplitPane.HORIZONTAL_SPLIT, instancesListPanel, browsersSplit);
    tweakSplitPaneUI(contentsSplit);
    contentsSplit.setDividerLocation(instancesListPanel.getPreferredSize().width);

    JPanel classPresenterPanel = instancesController.getClassPresenterPanel();
    classPresenterPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 3, 0,
                                                                                                     getBackground()),
                                                                     classPresenterPanel.getBorder()));

    legendPanel = new LegendPanel(true);

    dataPanel = new JPanel(new BorderLayout());
    dataPanel.setOpaque(false);
    dataPanel.add(classPresenterPanel, BorderLayout.NORTH);
    dataPanel.add(contentsSplit, BorderLayout.CENTER);
    dataPanel.add(legendPanel, BorderLayout.SOUTH);

    noDataPanel = new JPanel(new BorderLayout());
    noDataPanel.setBorder(BorderFactory.createLoweredBevelBorder());

    HTMLTextArea hintArea = new HTMLTextArea() {
        protected void showURL(URL url) {
            instancesController.getHeapFragmentWalker().switchToClassesView();
        }
    };

    hintArea.setBorder(BorderFactory.createEmptyBorder(10, 8, 8, 8));

    String classesRes = Icons.getResource(LanguageIcons.CLASS);
    String hintText = Bundle.InstancesControllerUI_NoClassDefinedMsg(
                        "<a href='#'><img border='0' align='bottom' src='nbresloc:/" + classesRes + "'></a>"); // NOI18N
    hintArea.setText(hintText);
    noDataPanel.add(hintArea, BorderLayout.CENTER);

    contents = new CardLayout();
    setLayout(contents);
    add(noDataPanel, NO_DATA);
    add(dataPanel, DATA);

    LegendUpdater legendUpdater = new LegendUpdater();
    fieldsBrowserPanel.addHierarchyListener(legendUpdater);
    referencesBrowserPanel.addHierarchyListener(legendUpdater);
}