List of usage examples for java.beans PropertyChangeEvent getNewValue
public Object getNewValue()
From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.TreeViewerAction.java
/** * Reacts to property changes//w ww .j av a 2 s . co m * {@link Browser#SELECTED_TREE_NODE_DISPLAY_PROPERTY} * event fired by the {@link Browser} and to * the {@link TreeViewer#SELECTED_BROWSER_PROPERTY} event. * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (TreeViewer.SELECTED_BROWSER_PROPERTY.equals(name)) { onBrowserSelection((Browser) evt.getNewValue()); } else if (TreeViewer.DISPLAY_MODE_PROPERTY.equals(name)) { int displayMode = ((Integer) evt.getNewValue()).intValue(); switch (displayMode) { case TreeViewer.SEARCH_MODE: setEnabled(true); break; case TreeViewer.EXPLORER_MODE: setEnabled(true); Browser browser = model.getSelectedBrowser(); TreeImageDisplay v = null; if (browser != null) v = browser.getLastSelectedDisplay(); onBrowserStateChange(browser); onDisplayChange(v); break; } onDisplayMode(); } else if (TreeViewer.ON_COMPONENT_STATE_CHANGED_PROPERTY.equals(name) || TreeViewer.GROUP_CHANGED_PROPERTY.equals(name) || TreeViewer.SELECTION_PROPERTY.equals(name) || Browser.SELECTED_TREE_NODE_DISPLAY_PROPERTY.equals(name)) { Browser browser = model.getSelectedBrowser(); TreeImageDisplay v = null; if (browser != null) v = browser.getLastSelectedDisplay(); onDisplayChange(v); } else if (TreeViewer.IMPORT_PROPERTY.equals(name)) { onDataImport(); } }
From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java
public JSMAAMainFrame(SMAAModel model) { super(AppInfo.getAppName()); ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); ToolTipManager.sharedInstance().setInitialDelay(0); setPreferredSize(new Dimension(950, 700)); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); modelManager = new ModelFileManager(); modelManager.addPropertyChangeListener(ModelFileManager.PROPERTY_TITLE, new PropertyChangeListener() { @Override/*from w w w . j ava 2s .c om*/ public void propertyChange(PropertyChangeEvent ev) { setTitle((String) ev.getNewValue()); } }); modelManager.addPropertyChangeListener(ModelFileManager.PROPERTY_MODEL, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { initWithModel((SMAAModel) evt.getNewValue()); } }); modelManager.setModel(model); }
From source file:org.jcurl.core.swing.RockLocationDisplayBase.java
/** * Property (rocks) changed./* w w w .j av a2 s. c o m*/ * * @param evt * @see #setPos(double, PositionSet) */ public void propertyChange(PropertyChangeEvent evt) { final Object tmp = evt.getNewValue(); if (tmp == null || PositionSet.class.isAssignableFrom(tmp.getClass())) { setPos(0, (PositionSet) tmp); } }
From source file:org.openmicroscopy.shoola.agents.dataBrowser.actions.DownloadAction.java
/** * Downloads the selected files./* w ww .j av a 2 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:com.totsp.sotu.app.ScreenAreaWatcher.java
/** Creates a new instance of ScreenWatcher */ public ScreenAreaWatcher(final Configuration config) throws AWTException { super();//from w w w. j a v a 2s .c om this.config = config; System.out.println(config.getWidth() + "x" + config.getHeight()); JPanel jp = null; JWindow top = new JWindow(); top.setBackground(GREEN); top.setLocation(0, 0); top.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); top.add(jp); top.pack(); top.setSize(config.getWidth(), config.getBorderSize()); JWindow bottom = new JWindow(); bottom.setBackground(GREEN); bottom.setLocation(0, config.getHeight() - config.getBorderSize()); bottom.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); bottom.add(jp); bottom.pack(); bottom.setSize(config.getWidth(), config.getBorderSize()); JWindow left = new JWindow(); left.setBackground(GREEN); left.setLocation(0, 0); left.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); left.add(jp); left.pack(); left.setSize(config.getBorderSize(), config.getHeight()); JWindow right = new JWindow(); right.setLocation(config.getWidth() - config.getBorderSize(), 0); right.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); right.add(jp); right.pack(); right.setSize(config.getBorderSize(), config.getHeight()); top.setVisible(true); bottom.setVisible(true); left.setVisible(true); right.setVisible(true); windows = new JWindow[4]; windows[0] = top; windows[1] = bottom; windows[2] = left; windows[3] = right; MouseInputAdapter adapter = new Adapter(windows); top.addMouseListener(adapter); top.addMouseMotionListener(adapter); bottom.addMouseListener(adapter); bottom.addMouseMotionListener(adapter); left.addMouseListener(adapter); left.addMouseMotionListener(adapter); right.addMouseListener(adapter); right.addMouseMotionListener(adapter); timer.schedule(new ImageUpdateTimerTask(this), 0, config.getMaxUpdateInterval()); this.addPropertyChangeListener("image", new PropertyChangeListener() { HttpClient client = new HttpClient(); public void propertyChange(PropertyChangeEvent propertyChangeEvent) { BufferedImage img = (BufferedImage) propertyChangeEvent.getNewValue(); try { File outputFile = File.createTempFile("save-" + System.currentTimeMillis(), ".png"); JAI.create("filestore", img, outputFile.getCanonicalPath(), "PNG", null); System.out.println("Temp File: " + outputFile.getCanonicalPath()); MultipartPostMethod method = new MultipartPostMethod( config.getServerUrl() + "/ImagePublishingServlet"); method.addParameter("adminPassword", config.getAdminPassword()); method.addParameter("conversation", config.getConversationName()); method.addParameter("image", outputFile); client.executeMethod(method); } catch (Exception e) { System.err.println("Error handling image"); e.printStackTrace(); } } }); }
From source file:org.opencastproject.staticfiles.impl.StaticFileServiceImpl.java
@Override public String storeFile(String filename, InputStream inputStream) throws IOException { notNull(filename, "filename"); notNull(inputStream, "inputStream"); final String uuid = UUID.randomUUID().toString(); final String org = securityService.getOrganization().getId(); Path file = getTemporaryStorageDir(org).resolve(Paths.get(uuid, filename)); try (ProgressInputStream progressInputStream = new ProgressInputStream(inputStream)) { progressInputStream.addPropertyChangeListener(new PropertyChangeListener() { @Override//from w w w. j av a2s .c om public void propertyChange(PropertyChangeEvent evt) { long totalNumBytesRead = (Long) evt.getNewValue(); long oldTotalNumBytesRead = (Long) evt.getOldValue(); staticFileStatistics.add(totalNumBytesRead - oldTotalNumBytesRead); } }); Files.createDirectories(file.getParent()); Files.copy(progressInputStream, file); } catch (IOException e) { logger.error("Unable to save file '{}' to {} because: {}", new Object[] { filename, file, ExceptionUtils.getStackTrace(e) }); throw e; } return uuid; }
From source file:ui.panel.UIAccessKeySelect.java
public void runaccessKeySelect() { getAccessKeyData();/* www . j a v a 2 s .c om*/ Panel p = new Panel(); Button b = new Button(); Label l = new Label(); setLayout(new BorderLayout()); JPanel pnlInstruction = p.createPanel(Layouts.flow); JLabel lblInstruction = l.createLabel("Access Keys"); pnlInstruction.setBackground(CustomColor.LightBlue.returnColor()); lblInstruction.setForeground(Color.white); lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18)); pnlInstruction.add(lblInstruction); JPanel pnlBucketList = p.createPanel(Layouts.border); listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollBucket = new JScrollPane(listBucket); Component[] BucketListComponents = { scrollBucket }; pnlBucketList.add(scrollBucket, BorderLayout.CENTER); JPanel pnlButtons = p.createPanel(Layouts.flow); JButton btnBack = b.createButton("Back"); JButton btnSelectElements = b.createButton("Next"); JButton btnAdd = b.createButton("Generate Access Key"); JButton btnRefresh = b.createButton("Refresh"); pnlButtons.add(btnBack); pnlButtons.add(btnAdd); pnlButtons.add(btnRefresh); pnlButtons.add(btnSelectElements); add(pnlInstruction, BorderLayout.NORTH); add(pnlBucketList, BorderLayout.CENTER); add(pnlButtons, BorderLayout.SOUTH); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.showPanel("license"); } }); btnRefresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getAccessKeyData(); } }); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.uiGenerateKey = new UIGenerateKey(); Data.mainFrame.addPanel(Data.mainFrame.uiGenerateKey, "generateKey"); Data.mainFrame.pack(); Data.mainFrame.showPanel("generateKey"); } }); btnSelectElements.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { int selected = listBucket.getSelectedRow(); if (selected != -1) { Data.accessKey = (String) listBucket.getModel().getValueAt(selected, 0); Data.mainFrame.qrGenerator = new JavaQR(); Data.mainFrame.pack(); Data.mainFrame.addPanel(Data.mainFrame.qrGenerator, "generateQR"); Data.mainFrame.showPanel("generateQR"); } else { JOptionPane.showMessageDialog(Data.mainFrame, "Please Select Access Key", "Error", JOptionPane.ERROR_MESSAGE); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL); mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("state")) { if (evt.getNewValue() == SwingWorker.StateValue.DONE) { dialog.dispose(); } } } }); mySwingWorker.execute(); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); JPanel panel = new JPanel(new BorderLayout()); panel.add(progressBar, BorderLayout.CENTER); panel.add(new JLabel("Generating QR Code......."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); }
From source file:InternalFrameTest.java
/** * Creates an internal frame on the desktop. * @param c the component to display in the internal frame * @param t the title of the internal frame. *///from w w w. ja va2s .c om public void createInternalFrame(Component c, String t) { final JInternalFrame iframe = new JInternalFrame(t, true, // resizable true, // closable true, // maximizable true); // iconifiable iframe.add(c, BorderLayout.CENTER); desktop.add(iframe); iframe.setFrameIcon(new ImageIcon("document.gif")); // add listener to confirm frame closing iframe.addVetoableChangeListener(new VetoableChangeListener() { public void vetoableChange(PropertyChangeEvent event) throws PropertyVetoException { String name = event.getPropertyName(); Object value = event.getNewValue(); // we only want to check attempts to close a frame if (name.equals("closed") && value.equals(true)) { // ask user if it is ok to close int result = JOptionPane.showInternalConfirmDialog(iframe, "OK to close?", "Select an Option", JOptionPane.YES_NO_OPTION); // if the user doesn't agree, veto the close if (result != JOptionPane.YES_OPTION) throw new PropertyVetoException("User canceled close", event); } } }); // position frame int width = desktop.getWidth() / 2; int height = desktop.getHeight() / 2; iframe.reshape(nextFrameX, nextFrameY, width, height); iframe.show(); // select the frame--might be vetoed try { iframe.setSelected(true); } catch (PropertyVetoException e) { } frameDistance = iframe.getHeight() - iframe.getContentPane().getHeight(); // compute placement for next frame nextFrameX += frameDistance; nextFrameY += frameDistance; if (nextFrameX + width > desktop.getWidth()) nextFrameX = 0; if (nextFrameY + height > desktop.getHeight()) nextFrameY = 0; }
From source file:org.eclipse.php.composer.api.entities.JsonEntity.java
protected void listen() { try {// w w w .j a v a2s. c o m for (Field field : getFields(this.getClass())) { if (JsonCollection.class.isAssignableFrom(field.getType())) { final String prop = getFieldName(field); final JsonEntity sender = this; if (listening.contains(prop)) { continue; } field.setAccessible(true); JsonEntity obj = (JsonEntity) field.get(this); if (obj != null) { obj.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { firePropertyChange(prop + "." + e.getPropertyName(), e.getOldValue(), //$NON-NLS-1$ e.getNewValue()); // append to sort order - use reflection if (sender instanceof AbstractJsonObject) { try { Method mtd = JsonEntity.class.getDeclaredMethod("appendSortOrder", //$NON-NLS-1$ String.class); mtd.setAccessible(true); mtd.invoke(sender, prop); } catch (Exception e1) { e1.printStackTrace(); } } } }); listening.add(prop); } } } } catch (Exception e) { log.error(e); } }
From source file:FilterSample.java
public void propertyChange(PropertyChangeEvent changeEvent) { String changeName = changeEvent.getPropertyName(); if (changeName.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { File file = (File) changeEvent.getNewValue(); if (file != null) { ImageIcon icon = new ImageIcon(file.getPath()); if (icon.getIconWidth() > PREFERRED_WIDTH) { icon = new ImageIcon( icon.getImage().getScaledInstance(PREFERRED_WIDTH, -1, Image.SCALE_DEFAULT)); if (icon.getIconHeight() > PREFERRED_HEIGHT) { icon = new ImageIcon( icon.getImage().getScaledInstance(-1, PREFERRED_HEIGHT, Image.SCALE_DEFAULT)); }//w w w.ja v a 2 s .co m } setIcon(icon); } } }