List of usage examples for java.awt.event HierarchyEvent getChanged
public Component getChanged()
From source file:Main.java
@Override public void hierarchyChanged(HierarchyEvent e) { System.out.println("Components Change: " + e.getChanged()); if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) { if (e.getComponent().isDisplayable()) { System.out.println("Components DISPLAYABILITY_CHANGED : " + e.getChanged()); } else {/* w w w. j a va2 s .co m*/ System.out.println("Components DISPLAYABILITY_CHANGED : " + e.getChanged()); } } if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { if (e.getComponent().isDisplayable()) { System.out.println("Components SHOWING_CHANGED : " + e.getChanged()); } else { System.out.println("Components SHOWING_CHANGED : " + e.getChanged()); } } }
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/* www . j av a 2 s .co 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); }