List of usage examples for javax.swing JOptionPane VALUE_PROPERTY
String VALUE_PROPERTY
To view the source code for javax.swing JOptionPane VALUE_PROPERTY.
Click Source Link
value
. From source file:org.myrobotlab.service.MarySpeech.java
private void showProgressPanel(List<ComponentDescription> comps, boolean install) { final ProgressPanel pp = new ProgressPanel(comps, install); final JOptionPane optionPane = new JOptionPane(pp, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new String[] { "Abort" }, "Abort"); // optionPane.setPreferredSize(new Dimension(640,480)); final JDialog dialog = new JDialog((Frame) null, "Progress", false); dialog.setContentPane(optionPane);//from w w w .j a v a 2 s .c om optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { pp.requestExit(); dialog.setVisible(false); } } }); dialog.pack(); dialog.setVisible(true); new Thread(pp).start(); }
From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java
private void createCards() { introPanel = new StandaloneLicensePanel(); content.add(introPanel, CARD_INTRO); playCard = new JPanel(new BorderLayout()); content.add(playCard, CARD_PLAY);//w ww. j a v a2 s .c om JPanel confirm = new JPanel(new GridBagLayout()); JOptionPane option = new JOptionPane("A game is in open. End this game?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_PLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_PLAY); currentCard = CARD_PLAY; playButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); GridBagConstraints cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_PLAY_END); content.add(new StandaloneModeselectPanel(), CARD_MODESELECT); netplayCard = new JPanel(new BorderLayout()); netplayCard.add(netLobby, BorderLayout.SOUTH); content.add(netplayCard, CARD_NETPLAY); confirm = new JPanel(new GridBagLayout()); option = new JOptionPane("A netplay game is open. End this game and disconnect?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_NETPLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } netLobby.disconnect(); contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_NETPLAY); currentCard = CARD_NETPLAY; netplayButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_NETPLAY_END); StandaloneKeyConfig kc = new StandaloneKeyConfig(this); kc.load(0); content.add(kc, CARD_KEYS_1P); kc = new StandaloneKeyConfig(this); kc.load(1); content.add(kc, CARD_KEYS_2P); StandaloneGameTuningPanel gt = new StandaloneGameTuningPanel(); gt.load(0); content.add(gt, CARD_TUNING_1P); gt = new StandaloneGameTuningPanel(); gt.load(1); content.add(gt, CARD_TUNING_2P); StandaloneAISelectPanel ai = new StandaloneAISelectPanel(); ai.load(0); content.add(ai, CARD_AI_1P); ai = new StandaloneAISelectPanel(); ai.load(1); content.add(ai, CARD_AI_2P); StandaloneGeneralConfigPanel gc = new StandaloneGeneralConfigPanel(); gc.load(); content.add(gc, CARD_GENERAL); final JFileChooser fc = FileSystemViews.get().fileChooser("replay/"); fc.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Zeromeaner Replay Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().endsWith(".zrep"); } }); fc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) return; JFileChooser fc = (JFileChooser) e.getSource(); String path = fc.getSelectedFile().getPath(); if (!path.contains("replay/")) path = "replay/" + path; startReplayGame(path); } }); fc.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { fc.rescanCurrentDirectory(); } }); content.add(fc, CARD_OPEN); content.add(new StandaloneFeedbackPanel(), CARD_FEEDBACK); }