List of usage examples for java.beans PropertyChangeListener PropertyChangeListener
PropertyChangeListener
From source file:org.jdesktop.swingworker.AccumulativeRunnable.java
public final void testWorkFlow() throws Exception { final List<Object> goldenSequence = Arrays.asList(new Object[]{StateValue.STARTED, "done", StateValue.DONE}); final List<Object> sequence = Collections.synchronizedList(new ArrayList<Object>()); final Exchanger<List<Object>> listExchanger = new Exchanger<List<Object>>(); //from w ww .j a v a 2s. c o m final SwingWorker<?,?> test = new SwingWorker<Object,Object>() { @Override protected Object doInBackground() throws Exception { return null; } @Override protected void done() { sequence.add("done"); } }; test.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("state".equals(evt.getPropertyName())) { sequence.add(evt.getNewValue()); if (StateValue.DONE == evt.getNewValue()) { try { listExchanger.exchange(sequence); } catch (Exception ignore) { ignore.printStackTrace(); } } } } }); test.execute(); assertEquals(goldenSequence, listExchanger.exchange(null, TIME_OUT, TIME_OUT_UNIT)); }
From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java
public void addContribution(BaseContribution contribution, boolean doLayout) { // ok, create a wrapper for this BaseContributionView<?> panel = null; if (!CONTRIBUTION_PANELS.containsKey(contribution.getClass())) { return;//w w w. j a v a2s .c om } try { Class<?> viewClass = CONTRIBUTION_PANELS.get(contribution.getClass()); panel = (BaseContributionView<?>) viewClass .getConstructor(Composite.class, contribution.getClass(), IContributions.class) .newInstance(contList, contribution, activeSolver.getContributions()); panel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); // see if we can give it a default color panel.setDefaultColor(colorFor(contribution)); // now store it contributionsControl.put(contribution, panel); if (doLayout) { contList.layout(); } // hmm, is this a new straight leg? if (contribution instanceof StraightLegForecastContribution) { // ok - listen out for period changes StraightLegForecastContribution slf = (StraightLegForecastContribution) contribution; if (_legListener == null) _legListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { redoStraightLegs(); } }; startListeningTo(slf); // ok - chuck in a graph update redoStraightLegs(); } else if (contribution instanceof BearingMeasurementContribution) { BearingMeasurementContribution bmc = (BearingMeasurementContribution) contribution; if (_sliceListener == null) { _sliceListener = new BearingMeasurementContribution.MDAResultsListener() { @Override public void startingSlice(String contName) { // ok - ownship course is important for this - show it showOSCourse.setSelection(true); startSlicingOwnshipLegs(contName); } @Override public void ownshipLegs(String contName, ArrayList<BMeasurement> bearings, List<LegOfData> ownshipLegs, ArrayList<HostState> hostStates) { // clear the domain markers, this is a new dataset legPlot.clearDomainMarkers(); // and show the ownship states redoOwnshipStates(); } @Override public void sliced(String contName, ArrayList<StraightLegForecastContribution> arrayList) { // are we currently showing ownship course? if (showOSCourse.getSelection()) { // ok, ownship course is irrelevant to this, hide it showOSCourse.setSelection(false); // update the ownship states, now that we've hidden the O/S course redoOwnshipStates(); } // ok, now display the target legs redoStraightLegs(); } }; } bmc.addSliceListener(_sliceListener); // hey, let's also re-display the ownship states redoOwnshipStates(); } } catch (Exception ex) { LogFactory.getLog().error("Failed to generate panel for " + contribution); SATC_Activator.getDefault().getLog() .log(new Status(IStatus.ERROR, SATC_Activator.PLUGIN_ID, ex.getMessage(), ex)); } }
From source file:op.care.dfn.PnlDFN.java
private List<Component> addFilters() { List<Component> list = new ArrayList<Component>(); jdcDate = new JDateChooser(new Date()); jdcDate.setFont(new Font("Arial", Font.PLAIN, 14)); jdcDate.setBackground(Color.WHITE); list.add(jdcDate);//from www . j av a 2 s. c om JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); buttonPanel.setLayout(new HorizontalLayout(5)); buttonPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); final JButton homeButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start.png"))); homeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDate.setDate(jdcDate.getMinSelectableDate()); } }); homeButton.setPressedIcon( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start_pressed.png"))); homeButton.setBorder(null); homeButton.setBorderPainted(false); homeButton.setOpaque(false); homeButton.setContentAreaFilled(false); homeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton backButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back.png"))); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDate.getDate()); DateMidnight min = new DateMidnight(jdcDate.getMinSelectableDate()); if (current.equals(min)) { return; } jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), -1)); } }); backButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back_pressed.png"))); backButton.setBorder(null); backButton.setBorderPainted(false); backButton.setOpaque(false); backButton.setContentAreaFilled(false); backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton fwdButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play.png"))); fwdButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDate.getDate()); if (current.equals(new DateMidnight())) { return; } jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), 1)); } }); fwdButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play_pressed.png"))); fwdButton.setBorder(null); fwdButton.setBorderPainted(false); fwdButton.setOpaque(false); fwdButton.setContentAreaFilled(false); fwdButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton endButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end.png"))); endButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDate.setDate(new Date()); } }); endButton.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end_pressed.png"))); endButton.setBorder(null); endButton.setBorderPainted(false); endButton.setOpaque(false); endButton.setContentAreaFilled(false); endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); buttonPanel.add(homeButton); buttonPanel.add(backButton); buttonPanel.add(fwdButton); buttonPanel.add(endButton); list.add(buttonPanel); jdcDate.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (initPhase) { return; } if (evt.getPropertyName().equals("date")) { reloadDisplay(); } } }); return list; }
From source file:org.pentaho.ui.database.event.DataHandler.java
protected void getControls() { // Not all of these controls are created at the same time.. that's OK, for now, just check // each one for null before using. dialogDeck = (XulDeck) document.getElementById("dialog-panel-deck"); deckOptionsBox = (XulListbox) document.getElementById("deck-options-list"); connectionBox = (XulListbox) document.getElementById("connection-type-list"); accessBox = (XulListbox) document.getElementById("access-type-list"); connectionNameBox = (XulTextbox) document.getElementById("connection-name-text"); hostNameBox = (XulTextbox) document.getElementById("server-host-name-text"); databaseNameBox = (XulTextbox) document.getElementById("database-name-text"); portNumberBox = (XulTextbox) document.getElementById("port-number-text"); userNameBox = (XulTextbox) document.getElementById("username-text"); passwordBox = (XulTextbox) document.getElementById("password-text"); dataTablespaceBox = (XulTextbox) document.getElementById("data-tablespace-text"); indexTablespaceBox = (XulTextbox) document.getElementById("index-tablespace-text"); serverInstanceBox = (XulTextbox) document.getElementById("instance-text"); serverNameBox = (XulTextbox) document.getElementById("server-name-text"); customUrlBox = (XulTextbox) document.getElementById("custom-url-text"); customDriverClassBox = (XulTextbox) document.getElementById("custom-driver-class-text"); languageBox = (XulTextbox) document.getElementById("language-text"); systemNumberBox = (XulTextbox) document.getElementById("system-number-text"); clientBox = (XulTextbox) document.getElementById("client-text"); doubleDecimalSeparatorCheck = (XulCheckbox) document.getElementById("decimal-separator-check"); resultStreamingCursorCheck = (XulCheckbox) document.getElementById("result-streaming-check"); poolingCheck = (XulCheckbox) document.getElementById("use-pool-check"); clusteringCheck = (XulCheckbox) document.getElementById("use-cluster-check"); clusterParameterDescriptionLabel = (XulLabel) document .getElementById("cluster-parameter-description-label"); poolSizeLabel = (XulLabel) document.getElementById("pool-size-label"); poolSizeBox = (XulTextbox) document.getElementById("pool-size-text"); maxPoolSizeLabel = (XulLabel) document.getElementById("max-pool-size-label"); maxPoolSizeBox = (XulTextbox) document.getElementById("max-pool-size-text"); poolParameterTree = (XulTree) document.getElementById("pool-parameter-tree"); clusterParameterTree = (XulTree) document.getElementById("cluster-parameter-tree"); optionsParameterTree = (XulTree) document.getElementById("options-parameter-tree"); poolingDescription = (XulTextbox) document.getElementById("pooling-description"); poolingParameterDescriptionLabel = (XulLabel) document.getElementById("pool-parameter-description-label"); poolingDescriptionLabel = (XulLabel) document.getElementById("pooling-description-label"); supportBooleanDataType = (XulCheckbox) document.getElementById("supports-boolean-data-type"); supportTimestampDataType = (XulCheckbox) document.getElementById("supports-timestamp-data-type"); quoteIdentifiersCheck = (XulCheckbox) document.getElementById("quote-identifiers-check"); lowerCaseIdentifiersCheck = (XulCheckbox) document.getElementById("force-lower-case-check"); upperCaseIdentifiersCheck = (XulCheckbox) document.getElementById("force-upper-case-check"); preserveReservedCaseCheck = (XulCheckbox) document.getElementById("preserve-reserved-case"); preferredSchemaName = (XulTextbox) document.getElementById("preferred-schema-name-text"); sqlBox = (XulTextbox) document.getElementById("sql-text"); useIntegratedSecurityCheck = (XulCheckbox) document.getElementById("use-integrated-security-check"); acceptButton = (XulButton) document.getElementById("general-datasource-window_accept"); cancelButton = (XulButton) document.getElementById("general-datasource-window_cancel"); testButton = (XulButton) document.getElementById("test-button"); noticeLabel = (XulLabel) document.getElementById("notice-label"); if (portNumberBox != null && serverInstanceBox != null) { if (Boolean.parseBoolean(serverInstanceBox.getAttributeValue("shouldDisablePortIfPopulated"))) { serverInstanceBox.addPropertyChangeListener(new PropertyChangeListener() { @Override//from w w w.j a va2s . c o m public void propertyChange(PropertyChangeEvent evt) { if ("value".equals(evt.getPropertyName())) { disablePortIfInstancePopulated(); } } }); } } }
From source file:org.jdesktop.swingworker.AccumulativeRunnable.java
public final void test6493680() throws Exception { final AtomicInteger lastProgressValue = new AtomicInteger(-1); final Exchanger<Boolean> exchanger = new Exchanger<Boolean>(); class Test {//from w ww. j a va2 s . c om private final AtomicInteger lastProgressValue = new AtomicInteger(-1); private final Exchanger<Boolean> exchanger = new Exchanger<Boolean>(); boolean test() throws Exception { TestSwingWorker swingWorker = new TestSwingWorker(); swingWorker.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { lastProgressValue.set((Integer) evt.getNewValue()); } } }); swingWorker.execute(); return exchanger.exchange(true); } class TestSwingWorker extends SwingWorker<Void, Void> { @Override protected Void doInBackground() throws Exception { for (int i = 0; i <= 100; i++) { Thread.sleep(1); setProgress(i); } return null; } @Override protected void done() { boolean isPassed = (lastProgressValue.get() == 100); try { exchanger.exchange(isPassed); } catch (Exception ingore) { } } } } /* * because timing is involved in this bug we will run the test * NUMBER_OF_TRIES times. * the tes`t passes if it does not fail once. */ final int NUMBER_OF_TRIES = 50; for (int i = 0; i < NUMBER_OF_TRIES; i++) { assertTrue((new Test()).test()); } }
From source file:org.isatools.isacreator.spreadsheet.SpreadsheetFunctions.java
/** * Delete column given an index.//from w w w. j ava2 s. c om * * @param vColIndex - column to remove. */ protected void deleteColumn(int vColIndex) { spreadsheet.curColDelete = vColIndex; spreadsheet.currentState = Spreadsheet.DELETING_COLUMN; TableColumn col = spreadsheet.getTable().getColumnModel().getColumn(spreadsheet.curColDelete); if (!col.getHeaderValue().toString().equals(TableReferenceObject.ROW_NO_TEXT)) { if (spreadsheet.getTableReferenceObject().isRequired(col.getHeaderValue().toString()) && !areMultipleOccurences(col.getHeaderValue().toString())) { spreadsheet.optionPane = new JOptionPane( "<html>This column can not be deleted due to it being a required field in this assay!</html>", JOptionPane.OK_OPTION); spreadsheet.optionPane.setIcon(spreadsheet.requiredColumnWarningIcon); UIHelper.applyOptionPaneBackground(spreadsheet.optionPane, UIHelper.BG_COLOR); spreadsheet.optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { spreadsheet.getParentFrame().hideSheet(); } } }); spreadsheet.getParentFrame() .showJDialogAsSheet(spreadsheet.optionPane.createDialog(spreadsheet, "Can not delete")); } else { spreadsheet.optionPane = new JOptionPane( "<html>Are you sure you want to delete this column? <p>This Action can not be undone!</p></html>", JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION, spreadsheet.confirmRemoveColumnIcon); UIHelper.applyOptionPaneBackground(spreadsheet.optionPane, UIHelper.BG_COLOR); spreadsheet.optionPane.addPropertyChangeListener(spreadsheet); spreadsheet.getParentFrame().showJDialogAsSheet( spreadsheet.optionPane.createDialog(spreadsheet, "Confirm Delete Column")); } } }
From source file:org.opencastproject.ingest.impl.IngestServiceImpl.java
private URI addContentToRepo(MediaPackage mp, String elementId, String filename, InputStream file) throws IOException { ProgressInputStream progressInputStream = new ProgressInputStream(file); progressInputStream.addPropertyChangeListener(new PropertyChangeListener() { @Override//from ww w.j ava2 s . c o m public void propertyChange(PropertyChangeEvent evt) { long totalNumBytesRead = (Long) evt.getNewValue(); long oldTotalNumBytesRead = (Long) evt.getOldValue(); ingestStatistics.add(totalNumBytesRead - oldTotalNumBytesRead); } }); return workingFileRepository.put(mp.getIdentifier().compact(), elementId, filename, progressInputStream); }
From source file:org.apache.log4j.chainsaw.LogUI.java
private void initPrefModelListeners() { applicationPreferenceModel.addPropertyChangeListener("identifierExpression", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { handler.setIdentifierExpression(evt.getNewValue().toString()); }//from w w w . j av a2 s . c o m }); handler.setIdentifierExpression(applicationPreferenceModel.getIdentifierExpression()); applicationPreferenceModel.addPropertyChangeListener("toolTipDisplayMillis", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { ToolTipManager.sharedInstance().setDismissDelay(((Integer) evt.getNewValue()).intValue()); } }); ToolTipManager.sharedInstance().setDismissDelay(applicationPreferenceModel.getToolTipDisplayMillis()); applicationPreferenceModel.addPropertyChangeListener("responsiveness", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { int value = ((Integer) evt.getNewValue()).intValue(); handler.setQueueInterval((value * 1000) - 750); } }); handler.setQueueInterval((applicationPreferenceModel.getResponsiveness() * 1000) - 750); applicationPreferenceModel.addPropertyChangeListener("tabPlacement", new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { SwingUtilities.invokeLater(new Runnable() { public void run() { int placement = ((Integer) evt.getNewValue()).intValue(); switch (placement) { case SwingConstants.TOP: case SwingConstants.BOTTOM: tabbedPane.setTabPlacement(placement); break; default: break; } } }); } }); applicationPreferenceModel.addPropertyChangeListener("statusBar", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); setStatusBarVisible(value); } }); setStatusBarVisible(applicationPreferenceModel.isStatusBar()); applicationPreferenceModel.addPropertyChangeListener("receivers", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); if (value) { showReceiverPanel(); } else { hideReceiverPanel(); } } }); // if (applicationPreferenceModel.isReceivers()) { // showReceiverPanel(); // } else { // hideReceiverPanel(); // } applicationPreferenceModel.addPropertyChangeListener("toolbar", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean value = ((Boolean) evt.getNewValue()).booleanValue(); toolbar.setVisible(value); } }); toolbar.setVisible(applicationPreferenceModel.isToolbar()); }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jContentPane/*from w w w . j av a 2s . c o m*/ * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); tabbedPane = new JTabbedPane(); if (getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_OVERVIEW_TAB, true)) { tabbedPane.addTab(Messages.getString("GTDFree.Overview"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_overview), getOverviewPane()); } inBasketPane = new InBasketPane(); //inBasketPane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Collect"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_collecting), inBasketPane); processPane = new ProcessPane(); //processPane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Process"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_processing), processPane); organizePane = new OrganizePane(); //organizePane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Organize"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_review), organizePane); executePane = new ExecutePane(); //executePane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Execute") + " (" + getSummaryBean().getQueueCount() + ")", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_queue_execute), executePane); executeTabIndex = tabbedPane.getTabCount() - 1; getSummaryBean().addPropertyChangeListener("queueCount", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent evt) { tabbedPane.setTitleAt(executeTabIndex, Messages.getString("GTDFree.Execute") + " (" + getSummaryBean().getQueueCount() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }); if (Boolean.valueOf(getEngine().getConfiguration().getProperty("journal.enabled", "false"))) { //$NON-NLS-1$ //$NON-NLS-2$ journalPane = new JournalPane(); journalPane.setEngine(getEngine()); tabbedPane.addTab("Journal", //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_journaling), journalPane); } tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { enableQuickCollectPanel(); Component c = tabbedPane.getSelectedComponent(); if (c instanceof WorkflowPane && !((WorkflowPane) c).isInitialized()) { ((WorkflowPane) c).initialize(getEngine()); } if (c instanceof GTDFreePane) { getEngine().setActivePane((GTDFreePane) c); } else { getEngine().setActivePane(null); } } }); jContentPane.add(tabbedPane); quickCollectPanel = new QuickCollectPanel(); quickCollectPanel.setEngine(getEngine()); enableQuickCollectPanel(); jContentPane.add(quickCollectPanel, BorderLayout.SOUTH); } return jContentPane; }
From source file:self.philbrown.javaQuery.$.java
/** * Registers common component changes/*w w w . j a va 2s .c o m*/ * @param function receives an instance of javaQuery with the changed view selected, as well as the * following arguments: * <ol> * <li>{@link changeEvent} to define the type of event that was triggered * <li>The associated event * </ol> * @return * @see changeEvent */ public $ change(final Function function) { for (final Component component : views) { component.addInputMethodListener(new InputMethodListener() { @Override public void caretPositionChanged(InputMethodEvent event) { function.invoke($.with(component), ChangeEvent.INPUT_CARET_POSITION_CHANGED, event); } @Override public void inputMethodTextChanged(InputMethodEvent event) { function.invoke($.with(component), ChangeEvent.INPUT_METHOD_TEXT_CHANGED, event); } }); component.addHierarchyBoundsListener(new HierarchyBoundsListener() { @Override public void ancestorMoved(HierarchyEvent event) { function.invoke($.with(component), ChangeEvent.HIERARCHY_ANCESTOR_MOVED, event); } @Override public void ancestorResized(HierarchyEvent event) { function.invoke($.with(component), ChangeEvent.HIERARCHY_ANCENSTOR_RESIZED, event); } }); component.addHierarchyListener(new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent event) { function.invoke($.with(component), ChangeEvent.HIERARCHY_CHANGED, event); } }); component.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { function.invoke($.with(component), ChangeEvent.PROPERTY_CHANGED, event); } }); component.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_HIDDEN, event); } @Override public void componentMoved(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_MOVED, event); } @Override public void componentResized(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_RESIZED, event); } @Override public void componentShown(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_SHOWN, event); } }); if (component instanceof Container) { ((Container) component).addContainerListener(new ContainerListener() { @Override public void componentAdded(ContainerEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_ADDED, event); } @Override public void componentRemoved(ContainerEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_REMOVED, event); } }); } } return this; }