Example usage for java.beans PropertyChangeEvent getPropertyName

List of usage examples for java.beans PropertyChangeEvent getPropertyName

Introduction

In this page you can find the example usage for java.beans PropertyChangeEvent getPropertyName.

Prototype

public String getPropertyName() 

Source Link

Document

Gets the programmatic name of the property that was changed.

Usage

From source file:hydrograph.ui.graph.controller.CommentBoxEditPart.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    if (StringUtils.equalsIgnoreCase(prop, LABEL_CONTENTS)) {
        refreshVisuals();//  w  w  w . ja v  a 2 s.c  om
    } else if (StringUtils.equalsIgnoreCase(prop, SIZE) || StringUtils.equalsIgnoreCase(prop, LOCATION)) {
        Point loc = getLabel().getLocation();
        Dimension size = getLabel().getSize();
        Rectangle r = new Rectangle(loc, size);
        ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), r);
        refreshVisuals();
    }
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.actions.DownloadAction.java

/**
 * Downloads the selected files.// ww  w  . ja  v  a2 s . c o  m
 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
 */
public void actionPerformed(ActionEvent e) {
    ImageDisplay node = model.getBrowser().getLastSelectedDisplay();
    if (node == null)
        return;

    JFrame f = DataBrowserAgent.getRegistry().getTaskBar().getFrame();

    int type = FileChooser.FOLDER_CHOOSER;

    FileChooser chooser = new FileChooser(f, type, FileChooser.DOWNLOAD_TEXT, FileChooser.DOWNLOAD_DESCRIPTION);

    IconManager icons = IconManager.getInstance();
    chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48));
    chooser.setApproveButtonText(FileChooser.DOWNLOAD_TEXT);
    chooser.setCheckOverride(true);
    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            FileChooser src = (FileChooser) evt.getSource();
            if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
                String path = (String) evt.getNewValue();
                EventBus bus = DataBrowserAgent.getRegistry().getEventBus();
                bus.post(new DownloadEvent(new File(path), src.isOverride()));
            }
        }
    });
    chooser.centerDialog();
}

From source file:Main.java

public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
    Component oldComp = (Component) evt.getOldValue();
    Component newComp = (Component) evt.getNewValue();

    if ("focusOwner".equals(evt.getPropertyName())) {
        if (oldComp == null) {
            System.out.println(newComp.getName());
        } else {//from w  w  w  . java  2s . c  o m
            System.out.println(oldComp.getName());
        }
    } else if ("focusedWindow".equals(evt.getPropertyName())) {
        if (oldComp == null) {
            System.out.println(newComp.getName());
        } else {
            System.out.println(oldComp.getName());
        }
    }

    boolean vetoFocusChange = false;
    if (vetoFocusChange) {
        throw new PropertyVetoException("message", evt);
    }
}

From source file:FileChooserTest.java

/**
 * Constructs an ImagePreviewer.//www .  j  a v a2s.  c o m
 * @param chooser the file chooser whose property changes trigger an image change in this
 * previewer
 */
public ImagePreviewer(JFileChooser chooser) {
    setPreferredSize(new Dimension(100, 100));
    setBorder(BorderFactory.createEtchedBorder());

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getPropertyName() == JFileChooser.SELECTED_FILE_CHANGED_PROPERTY) {
                // the user has selected a new file
                File f = (File) event.getNewValue();
                if (f == null) {
                    setIcon(null);
                    return;
                }

                // read the image into an icon
                ImageIcon icon = new ImageIcon(f.getPath());

                // if the icon is too large to fit, scale it
                if (icon.getIconWidth() > getWidth())
                    icon = new ImageIcon(
                            icon.getImage().getScaledInstance(getWidth(), -1, Image.SCALE_DEFAULT));

                setIcon(icon);
            }
        }
    });
}

From source file:misc.TrackFocusDemo.java

public TrackFocusDemo() {
    super(new BorderLayout());

    JPanel mugshots = new JPanel(new GridLayout(2, 3));
    pic1 = new Picture(createImageIcon("images/" + mayaString + ".jpg", mayaString).getImage());
    pic1.setName("1");
    mugshots.add(pic1);/*from  w ww  .j  av a 2 s  .  co  m*/
    pic2 = new Picture(createImageIcon("images/" + anyaString + ".jpg", anyaString).getImage());
    pic2.setName("2");
    mugshots.add(pic2);
    pic3 = new Picture(createImageIcon("images/" + laineString + ".jpg", laineString).getImage());
    pic3.setName("3");
    mugshots.add(pic3);
    pic4 = new Picture(createImageIcon("images/" + cosmoString + ".jpg", cosmoString).getImage());
    pic4.setName("4");
    mugshots.add(pic4);
    pic5 = new Picture(createImageIcon("images/" + adeleString + ".jpg", adeleString).getImage());
    pic5.setName("5");
    mugshots.add(pic5);
    pic6 = new Picture(createImageIcon("images/" + alexiString + ".jpg", alexiString).getImage());
    pic6.setName("6");
    mugshots.add(pic6);

    info = new JLabel("Nothing selected");

    setPreferredSize(new Dimension(450, 350));
    add(mugshots, BorderLayout.CENTER);
    add(info, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();
            if (("focusOwner".equals(prop)) && ((e.getNewValue()) instanceof Picture)) {

                Component comp = (Component) e.getNewValue();
                String name = comp.getName();
                Integer num = new Integer(name);
                int index = num.intValue();
                if (index < 0 || index > comments.length) {
                    index = 0;
                }
                info.setText(comments[index]);
            }
        }
    });
}

From source file:com.webcrawler.manager.impl.DownloadManagerImpl.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("progress")) {
        ui.setProgressBarValue((Integer) evt.getNewValue());
    }/*from  w  ww .ja v  a2  s.  co m*/

}

From source file:net.sf.maltcms.chromaui.project.spi.nodes.DescriptorNode.java

@Override
public void propertyChange(PropertyChangeEvent pce) {
    if (pce.getPropertyName().equals(PROP_NAME) || pce.getPropertyName().equals(IDescriptor.PROP_NAME)) {
        fireNameChange((String) pce.getOldValue(), (String) pce.getNewValue());
    }//from  w w w  .j a v a  2s  . com
    if (pce.getPropertyName().equals(PROP_DISPLAY_NAME)
            || pce.getPropertyName().equals(IDescriptor.PROP_DISPLAYNAME)) {
        fireDisplayNameChange((String) pce.getOldValue(), (String) pce.getNewValue());
    }
    if (pce.getPropertyName().equals(PROP_SHORT_DESCRIPTION)
            || pce.getPropertyName().equals(IDescriptor.PROP_SHORTDESCRIPTION)) {
        fireShortDescriptionChange((String) pce.getOldValue(), (String) pce.getNewValue());
    }
    if (pce.getPropertyName().equals(PROP_ICON)) {
        fireIconChange();
    }
    if (pce.getPropertyName().equals(PROP_OPENED_ICON)) {
        fireOpenedIconChange();
    }
    if (pce.getPropertyName().equals(IColorizableDescriptor.PROP_COLOR)) {
        fireIconChange();
        fireOpenedIconChange();
    }
}

From source file:it.cnr.icar.eric.client.ui.swing.metal.MetalThemeMenu.java

/**
 * Listens to property changes in the bound property
 * RegistryBrowser.PROPERTY_LOCALE.//from   ww w  .  j  a v a 2  s  . c  o  m
 */
public void propertyChange(PropertyChangeEvent ev) {
    if (ev.getPropertyName().equals(RegistryBrowser.PROPERTY_LOCALE)) {
        themeNames = ResourceBundle.getBundle(BASE_NAME, (Locale) ev.getNewValue());

        setLocale((Locale) ev.getNewValue());
        updateText();
    }
}

From source file:org.jcurl.model.ComputedPathsTest.java

public void testNoneMoving() throws FunctionEvaluationException, InterruptedException {
    final ComputedPaths cp = new ComputedPaths();
    assertEquals(0, ec);//from  w w w  .j a  va  2  s. c  o m
    cp.getCurrentPos().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof PositionSet);
            ec += pos;
        }
    });
    cp.getCurrentSpeed().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof SpeedSet);
            ec += vel;
        }
    });
    assertEquals(0, ec);
    assertEquals("", 0.0, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(1);
    // Strange! Eclipse fails here, but maven does it right!
    assertEquals((vel + pos), ec);
    assertEquals("", 1.0, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.MAX_VALUE);
    assertEquals((vel + pos) * 2, ec);
    assertEquals("", Double.MAX_VALUE, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.POSITIVE_INFINITY);
    assertEquals((vel + pos) * 3, ec);
    assertEquals("", Double.POSITIVE_INFINITY, cp.getCurrentT(), 1e-9);
}

From source file:org.jcurl.model.ComputedPathsTest.java

public void testOneMovingEvents() throws FunctionEvaluationException {
    final ComputedPaths cp = new ComputedPaths();
    assertEquals(0, ec);/*from   ww w. ja v a 2  s.  c o m*/
    cp.getCurrentPos().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof PositionSet);
            ec += pos;
        }
    });
    cp.getCurrentSpeed().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            assertEquals("rock", e.getPropertyName());
            assertTrue(e.getSource() instanceof SpeedSet);
            ec += vel;
        }
    });
    assertEquals(0, ec);
    cp.getInitialSpeed().getLight(0).setY(-1);
    cp.getInitialSpeed().notifyChange();
    assertEquals((vel + pos) * 1, ec);
    cp.setCurrentT(1);
    assertEquals((vel + pos) * 2, ec);
    assertEquals("", 1.0, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.MAX_VALUE);
    assertEquals((vel + pos) * 3, ec);
    assertEquals("", Double.MAX_VALUE, cp.getCurrentT(), 1e-9);
    cp.setCurrentT(Double.POSITIVE_INFINITY);
    assertEquals((vel + pos) * 4, ec);
    assertEquals("", Double.POSITIVE_INFINITY, cp.getCurrentT(), 1e-9);
}