List of usage examples for javax.swing JToolBar addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
From source file:Main.java
public static void main(String[] argv) throws Exception { JToolBar toolbar = new JToolBar(); toolbar.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { String propName = evt.getPropertyName(); if ("orientation".equals(propName)) { Integer oldValue = (Integer) evt.getOldValue(); Integer newValue = (Integer) evt.getNewValue(); if (newValue.intValue() == JToolBar.HORIZONTAL) { System.out.println("horizontal orientation"); } else { System.out.println("vertical orientation"); }// ww w. j a v a 2 s. c o m } } }); }
From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java
/** * Invokes when the activity end. /*from w ww . j a v a 2 s.c o m*/ * * @param result The result of the activity. */ public void endActivity(Object result) { this.result = result; boolean busy = status.isBusy(); reset(); if (result instanceof Map) { Map<String, Object> m = convertResult((Map<String, Object>) result); int size = m.size(); this.result = m; remove(resultPane); Color c = getBackground(); if (size == 0) { JToolBar row = new JToolBar(); row.setOpaque(false); row.setFloatable(false); row.setBorder(null); row.setBackground(c); JButton button; if (errorObject != null) { button = createButton(ActivityResultRow.ERROR_TEXT, ERROR, this); button.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showMenu((JComponent) e.getSource(), ERROR, e.getX(), e.getY()); } }); row.add(button); } if (infoObject != null) { button = createButton(ActivityResultRow.INFO_TEXT, INFO, this); button.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showMenu((JComponent) e.getSource(), INFO, e.getX(), e.getY()); } }); row.add(button); } add(row, paneIndex); } else { Entry<String, Object> entry; Iterator<Entry<String, Object>> i = m.entrySet().iterator(); ActivityResultRow row = null; JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.setBackground(c); int index = 0; int max = 2; JButton moreButton = null; while (i.hasNext()) { entry = (Entry<String, Object>) i.next(); this.result = entry.getValue(); row = new ActivityResultRow((String) entry.getKey(), entry.getValue(), this); row.setBackground(c); row.addPropertyChangeListener(listener); resultButtons.add(row); if (index < max) content.add(row); else { if (moreButton == null) { moreButton = createButton("" + (m.size() - max) + " more", ALL_RESULT, this); content.add(moreButton); } } index++; } if (m.size() == 1) add(row, paneIndex); else add(content, paneIndex); resultPane = content; } repaint(); } firePropertyChange(UNREGISTER_ACTIVITY_PROPERTY, null, this); notifyActivityEnd(); //Post an event to //if (busy) { EventBus bus = registry.getEventBus(); bus.post(new ActivityProcessEvent(this, busy)); //} }