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

The following examples show how to use javax.swing.JPanel#addHierarchyListener() . These examples are extracted from open source projects. 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 Project: netbeans   File: ClassesControllerUI.java    License: Apache License 2.0 5 votes vote down vote up
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
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 3
Source Project: netbeans   File: InstancesControllerUI.java    License: Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 4
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);
}