Example usage for java.awt.event HierarchyEvent getChangeFlags

List of usage examples for java.awt.event HierarchyEvent getChangeFlags

Introduction

In this page you can find the example usage for java.awt.event HierarchyEvent getChangeFlags.

Prototype

public long getChangeFlags() 

Source Link

Document

Returns a bitmask which indicates the type(s) of HIERARCHY_CHANGED events represented in this event object.

Usage

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ???????????/*www . j av  a  2s . c om*/
 * 
 * @param hierarchyChanged ?
 * @return ??
 * @see <a href="http://terai.xrea.jp/Swing/DefaultFocus.html ">Window?????? - Java Swing Tips</a>
 * @see HierarchyListener#hierarchyChanged(HierarchyEvent)
 */
public EventQuery ready(final HierarchyListener hierarchyChanged) {
    for (Component child : list) {
        child.addHierarchyListener(new HierarchyListener() {
            public void hierarchyChanged(HierarchyEvent e) {
                if (e.getChangeFlags() == HierarchyEvent.DISPLAYABILITY_CHANGED)
                    hierarchyChanged.hierarchyChanged(e);
            }
        });
    }
    return this;
}

From source file:pl.otros.logview.gui.LogViewPanelWrapper.java

public LogViewPanelWrapper(String name, Stoppable stoppable, TableColumns[] visibleColumns,
        LogDataTableModel logDataTableModel, DataConfiguration configuration,
        OtrosApplication otrosApplication) {
    this.name = name;
    this.configuration = configuration;
    this.otrosApplication = otrosApplication;
    this.addHierarchyListener(new HierarchyListener() {

        @Override/*  w w w. j  av  a2  s .  c o m*/
        public void hierarchyChanged(HierarchyEvent e) {
            if (e.getChangeFlags() == 1 && e.getChanged().getParent() == null) {
                LOGGER.info("Log view panel is removed from view. Clearing data table for GC");
                dataTableModel.clear();
            }
        }
    });
    if (visibleColumns == null) {
        visibleColumns = TableColumns.ALL_WITHOUT_LOG_SOURCE;
    }

    fillDefaultConfiguration();

    stopableReference = new SoftReference<Stoppable>(stoppable);
    // this.statusObserver = statusObserver;
    dataTableModel = logDataTableModel == null ? new LogDataTableModel() : logDataTableModel;
    logViewPanel = new LogViewPanel(dataTableModel, visibleColumns, otrosApplication);

    cardLayout = new CardLayout();
    JPanel panelLoading = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(10, 10, 10, 10);
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.ipadx = 1;
    c.ipady = 1;
    c.weightx = 10;
    c.weighty = 1;

    JLabel label = new JLabel("Loading file " + name);
    panelLoading.add(label, c);
    c.gridy++;
    c.weighty = 3;
    loadingProgressBar = new JProgressBar();
    loadingProgressBar.setIndeterminate(false);
    loadingProgressBar.setStringPainted(true);
    loadingProgressBar.setString("Connecting...");
    panelLoading.add(loadingProgressBar, c);
    statsTable = new JTable();

    c.gridy++;
    c.weighty = 1;
    c.weightx = 2;
    panelLoading.add(statsTable, c);
    c.gridy++;
    c.weightx = 1;
    stopButton = new JButton("Stop, you have imported already enough!");
    stopButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Stoppable stoppable = stopableReference.get();
            if (stoppable != null) {
                stoppable.stop();
            }
        }
    });
    panelLoading.add(stopButton, c);

    setLayout(cardLayout);
    add(panelLoading, CARD_LAYOUT_LOADING);
    add(logViewPanel, CARD_LAYOUT_CONTENT);
    cardLayout.show(this, CARD_LAYOUT_LOADING);

}