List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:org.javaswift.cloudie.CloudiePanel.java
public void onLogin() { final JDialog loginDialog = new JDialog(owner, "Login"); final LoginPanel loginPanel = new LoginPanel(new LoginCallback() { @Override/*from ww w . ja va 2s . c o m*/ public void doLogin(AccountConfig accountConfig) { CloudieCallback cb = GuiTreadingUtils.guiThreadSafe(CloudieCallback.class, new CloudieCallbackWrapper(callback) { @Override public void onLoginSuccess() { loginDialog.setVisible(false); super.onLoginSuccess(); } @Override public void onError(CommandException ex) { JOptionPane.showMessageDialog(loginDialog, "Login Failed\n" + ex.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }); ops.login(accountConfig, cb); } }, credentialsStore); try { loginPanel.setOwner(loginDialog); loginDialog.getContentPane().add(loginPanel); loginDialog.setModal(true); loginDialog.setSize(480, 340); loginDialog.setResizable(false); loginDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); center(loginDialog); loginDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { loginPanel.onCancel(); } @Override public void windowOpened(WindowEvent e) { loginPanel.onShow(); } }); loginDialog.setVisible(true); } finally { loginDialog.dispose(); } }
From source file:org.kontalk.view.ThreadListView.java
ThreadListView(final View view, ThreadList threadList) { mView = view;/* w w w . j a v a 2s. co m*/ mThreadList = threadList; this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // right click popup menu mPopupMenu = new WebPopupMenu(); WebMenuItem editMenuItem = new WebMenuItem(Tr.tr("Edit Thread")); editMenuItem.setToolTipText(Tr.tr("Edit this thread")); editMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ThreadItem t = ThreadListView.this.getSelectedItem(); JDialog editUserDialog = new EditThreadDialog(t); editUserDialog.setVisible(true); } }); mPopupMenu.add(editMenuItem); WebMenuItem deleteMenuItem = new WebMenuItem(Tr.tr("Delete Thread")); deleteMenuItem.setToolTipText(Tr.tr("Delete this thread")); deleteMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String warningText = Tr.tr("Permanently delete all messages in this thread?"); int selectedOption = WebOptionPane.showConfirmDialog(ThreadListView.this, warningText, Tr.tr("Please Confirm"), WebOptionPane.OK_CANCEL_OPTION, WebOptionPane.WARNING_MESSAGE); if (selectedOption == WebOptionPane.OK_OPTION) { ThreadItem threadItem = ThreadListView.this.getSelectedItem(); mThreadList.delete(threadItem.mValue.getID()); } } }); mPopupMenu.add(deleteMenuItem); // actions triggered by selection this.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; mView.selectedThreadChanged(ThreadListView.this.getSelectedValue()); } }); // actions triggered by mouse events this.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { check(e); } @Override public void mouseReleased(MouseEvent e) { check(e); } private void check(MouseEvent e) { if (e.isPopupTrigger()) { int row = ThreadListView.this.rowAtPoint(e.getPoint()); ThreadListView.this.setSelectedItem(row); ThreadListView.this.showPopupMenu(e); } } }); this.updateOnEDT(null); }
From source file:org.kontalk.view.View.java
void showConfig() { JDialog configFrame = new ConfigurationDialog(mMainFrame, this); configFrame.setVisible(true); }
From source file:org.kontalk.view.View.java
void showPasswordDialog(boolean wasWrong) { WebPanel passPanel = new WebPanel(); WebLabel passLabel = new WebLabel(Tr.tr("Please enter your key password:")); passPanel.add(passLabel, BorderLayout.NORTH); final WebPasswordField passField = new WebPasswordField(); passPanel.add(passField, BorderLayout.CENTER); if (wasWrong) { WebLabel wrongLabel = new WebLabel(Tr.tr("Wrong password")); wrongLabel.setForeground(Color.RED); passPanel.add(wrongLabel, BorderLayout.SOUTH); }//w w w . ja va 2 s .co m WebOptionPane passPane = new WebOptionPane(passPanel, WebOptionPane.QUESTION_MESSAGE, WebOptionPane.OK_CANCEL_OPTION); JDialog dialog = passPane.createDialog(mMainFrame, Tr.tr("Enter password")); dialog.setModal(true); dialog.addWindowFocusListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { passField.requestFocusInWindow(); } }); // blocking dialog.setVisible(true); Object value = passPane.getValue(); if (value != null && value.equals(WebOptionPane.OK_OPTION)) mControl.connect(passField.getPassword()); }
From source file:org.multibit.viewsystem.swing.action.SendAssetConfirmAction.java
/** * Complete the transaction to work out the fee) and then show the send bitcoin confirm dialog. *//*from w w w.j a v a2s.c o m*/ @Override public void actionPerformed(ActionEvent e) { if (abort()) { return; } // SendAssetConfirmDialog sendAssetConfirmDialog = null; AssetValidationErrorDialog validationErrorDialog = null; try { String sendAddress = dataProvider.getAddress(); String sendAmount = Utils.bitcoinValueToPlainString(BitcoinModel.COINSPARK_SEND_MINIMUM_AMOUNT); String sendMessage = null; boolean canSendMessage = false; final int assetId = dataProvider.getAssetId(); String assetAmount = dataProvider.getAssetAmount(); boolean isSenderPays = dataProvider.isSenderPays(); /* Is there a payment charge? If yes, the asset amount will change */ CSAsset asset = bitcoinController.getModel().getActiveWallet().CS.getAsset(assetId); CoinSparkGenesis genesis = asset.getGenesis(); BigInteger assetAmountRawUnits = CSMiscUtils.getRawUnitsFromDisplayString(asset, assetAmount); // Was there any rounding, which the user did not see because they clicked on send first, // without losing focus to any other widget which corrects field? String typedAmount = dataProvider.getAssetAmountText(); BigDecimal bd1 = new BigDecimal(typedAmount); BigDecimal bd2 = new BigDecimal(assetAmount); bd1 = bd1.stripTrailingZeros(); bd2 = bd2.stripTrailingZeros(); if (bd1.equals(bd2) == false) { String displayUnit = CSMiscUtils.getFormattedDisplayStringForRawUnits(asset, BigInteger.ONE); String s = "The smallest transactable unit is " + displayUnit + ", so we have rounded the sum down.\nPlease confirm the final amount and click 'Send' again."; JOptionPane.showMessageDialog(mainFrame, s); return; } // End rounding check/warning long desiredRawUnits = assetAmountRawUnits.longValue(); short chargeBasisPoints = genesis.getChargeBasisPoints(); long rawFlatChargeAmount = genesis.getChargeFlat(); boolean chargeExists = (rawFlatChargeAmount > 0 || chargeBasisPoints > 0); if (chargeExists) { if (isSenderPays) { long x = genesis.calcGross(desiredRawUnits); assetAmountRawUnits = new BigInteger(String.valueOf(x)); } else { // We don't have to do anything if recipient pays, just send gross amount. // calcNet() returns what the recipient will receive, but it's not what we send. // long x = genesis.calcNet(desiredRawUnits); // assetAmountRawUnits = new BigInteger(String.valueOf(x)); } } // Todo: Allow invalid assets to be sent even if spendable balance is 0 //if (CSMiscUtils.canSendInvalidAsset(bitcoinController) final AssetValidator validator = new AssetValidator(super.bitcoinController); if (validator.validate(sendAddress, sendAmount, assetId, assetAmountRawUnits.toString())) { /* CoinSpark START */ CoinSparkPaymentRef paymentRef = null; // We have already validated that the coinspark address and underlying bitcoin are good // and that the transfer flag is set on the coinspark address. We just want the actual // underlying bitcoin address to send assets to, which is used to create SendRequest object. CoinSparkAddress csa = CSMiscUtils.decodeCoinSparkAddress(sendAddress); String btcAddress = CSMiscUtils.getBitcoinAddressStringFromCoinSparkAddress(csa); sendAddress = btcAddress; // Does a payment ref exist? int flags = csa.getAddressFlags(); if ((flags & CoinSparkAddress.COINSPARK_ADDRESS_FLAG_PAYMENT_REFS) > 0) { paymentRef = csa.getPaymentRef(); log.debug(">>>> CoinSpark address has payment refs flag set: " + paymentRef.toString()); } // Messages - can send message and BTC to CoinSpark address, without any assets. sendMessage = dataProvider.getMessage(); canSendMessage = (flags & CoinSparkAddress.COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES) > 0; /* CoinSpark END */ // Create a SendRequest. Address sendAddressObject; sendAddressObject = new Address(bitcoinController.getModel().getNetworkParameters(), sendAddress); //SendRequest sendRequest = SendRequest.to(sendAddressObject, Utils.toNanoCoins(sendAmount)); //public static SendRequest to(Address destination,BigInteger value,int assetID, BigInteger assetValue,int split) { //BigInteger assetAmountRawUnits = new BigInteger(assetAmount); BigInteger bitcoinAmountSatoshis = Utils.toNanoCoins(sendAmount); final SendRequest sendRequest = SendRequest.to(sendAddressObject, bitcoinAmountSatoshis, assetId, assetAmountRawUnits, 1); sendRequest.ensureMinRequiredFee = true; sendRequest.fee = BigInteger.ZERO; sendRequest.feePerKb = BitcoinModel.SEND_FEE_PER_KB_DEFAULT; // Note - Request is populated with the AES key in the SendBitcoinNowAction after the user has entered it on the SendBitcoinConfirm form. // Send with payment ref - if it exists and is not 0 which SparkBit treats semantically as null if (paymentRef != null && paymentRef.getRef() != 0) { sendRequest.setPaymentRef(paymentRef); } // Send a message if the address will take it and message is not empty boolean willSendMessage = false; if (canSendMessage) { boolean isEmptyMessage = false; if (sendMessage == null || sendMessage.isEmpty() || sendMessage.trim().length() == 0) { isEmptyMessage = true; } if (!isEmptyMessage) { willSendMessage = true; //int numParts = 1; CoinSparkMessagePart[] parts = { CSMiscUtils.createPlainTextCoinSparkMessagePart(sendMessage) }; String[] serverURLs = CSMiscUtils.getMessageDeliveryServersArray(bitcoinController); sendRequest.setMessage(parts, serverURLs); log.debug(">>>> Messaging servers = " + ArrayUtils.toString(serverURLs)); log.debug(">>>> parts[0] = " + parts[0]); log.debug(">>>> parts[0].fileName = " + parts[0].fileName); log.debug(">>>> parts[0].mimeType = " + parts[0].mimeType); log.debug(">>>> parts[0].content = " + new String(parts[0].content, "UTF-8")); //String message = "Hello, the time is now..." + DateTime.now().toString(); // parts[2].fileName = imagePath; // parts[2].mimeType = "image/png"; // byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath)); // parts[2].content = imageBytes; } } // // When sending a message, show a modal dialog. // CompleteTX now occurs in background thread so UI does not block // when "Send" is clicked with widget updates frozen. // // Show dialog with indeterminate progress bar final JDialog dialog = CSMiscUtils.createModalMessageDialogWithIndeterminateProgress(mainFrame, "SparkBit", "Contacting message delivery servers..."); // Dialog is made visible after futures have been set up ListeningExecutorService service = MoreExecutors .listeningDecorator(Executors.newSingleThreadExecutor()); //newFixedThreadPool(10)); ListenableFuture<Boolean> future = service.submit(new Callable<Boolean>() { public Boolean call() throws Exception { try { // Complete it (which works out the fee) but do not sign it yet. log.debug("Just about to complete the tx (and calculate the fee)..."); bitcoinController.getModel().getActiveWallet().completeTx(sendRequest, false); log.debug("The fee after completing the transaction was " + sendRequest.fee); } catch (Exception e) { throw e; } return true; } }); final BigInteger myAssetAmountRawUnits = assetAmountRawUnits; Futures.addCallback(future, new FutureCallback<Boolean>() { public void onSuccess(Boolean b) { // There is enough money. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dialog.dispose(); SendAssetConfirmDialog mySendAssetConfirmDialog = new SendAssetConfirmDialog( bitcoinController, mainFrame, sendRequest, assetId, myAssetAmountRawUnits, validator); mySendAssetConfirmDialog.setVisible(true); } }); } public void onFailure(Throwable thrown) { final String failureReason = thrown.getMessage(); final boolean isCSException = thrown instanceof org.coinspark.core.CSExceptions.CannotEncode; final boolean isInsufficientMoney = thrown instanceof com.google.bitcoin.core.InsufficientMoneyException; // There is not enough money. // TODO setup validation parameters accordingly so that it displays ok. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dialog.dispose(); if (isCSException) { JOptionPane .showMessageDialog(mainFrame, "SparkBit is unable to proceed with this transaction:\n\n" + failureReason, "SparkBit Error", JOptionPane.ERROR_MESSAGE); } else if (isInsufficientMoney) { // Try to show a human friendly message, need to pass the missing satoshis from failure reason. try { String numberOnly = failureReason.replaceAll("[^0-9]", ""); BigInteger needed = new BigInteger(numberOnly); JOptionPane.showMessageDialog(mainFrame, "SparkBit is unable to proceed with this transaction.\n\nInsufficient money in wallet, require " + Utils.bitcoinValueToFriendlyString(needed) + " BTC more.", "SparkBit Error", JOptionPane.ERROR_MESSAGE); } catch (NumberFormatException e) { AssetValidationErrorDialog myValidationErrorDialog = new AssetValidationErrorDialog( bitcoinController, mainFrame, sendRequest, true, validator); myValidationErrorDialog.setVisible(true); } } else { AssetValidationErrorDialog myValidationErrorDialog = new AssetValidationErrorDialog( bitcoinController, mainFrame, sendRequest, true, validator); myValidationErrorDialog.setVisible(true); } } }); } }); // Show message server dialog only if we are going to send if (willSendMessage) { dialog.setVisible(true); } /* // Complete it (which works out the fee) but do not sign it yet. log.debug("Just about to complete the tx (and calculate the fee)..."); boolean completedOk; try { bitcoinController.getModel().getActiveWallet().completeTx(sendRequest, false); completedOk = true; log.debug("The fee after completing the transaction was " + sendRequest.fee); } catch (InsufficientMoneyException ime) { completedOk = false; } if (completedOk) { // There is enough money. sendAssetConfirmDialog = new SendAssetConfirmDialog(super.bitcoinController, mainFrame, sendRequest, assetId, assetAmountRawUnits, validator); sendAssetConfirmDialog.setVisible(true); } else { // There is not enough money. // TODO setup validation parameters accordingly so that it displays ok. validationErrorDialog = new AssetValidationErrorDialog(super.bitcoinController, mainFrame, sendRequest, true, validator); validationErrorDialog.setVisible(true); } */ } else { validationErrorDialog = new AssetValidationErrorDialog(super.bitcoinController, mainFrame, null, false, validator); validationErrorDialog.setVisible(true); } } catch (WrongNetworkException e1) { logMessage(e1); } catch (AddressFormatException e1) { logMessage(e1); } catch (KeyCrypterException e1) { logMessage(e1); } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(mainFrame, "Please enter a valid amount."); } catch (Exception e1) { logMessage(e1); } }
From source file:org.multibit.viewsystem.swing.action.SendBitcoinConfirmAction.java
/** * Complete the transaction to work out the fee) and then show the send bitcoin confirm dialog. *///from ww w . j av a 2 s. c o m @Override public void actionPerformed(ActionEvent e) { if (abort()) { return; } // SendBitcoinConfirmDialog sendBitcoinConfirmDialog = null; ValidationErrorDialog validationErrorDialog = null; try { String sendAddress = dataProvider.getAddress(); String sendAmount = dataProvider.getAmount(); String sendMessage = null; boolean canSendMessage = false; /*CoinSpark START */ CoinSparkPaymentRef paymentRef = null; /* If the address is a coinspark address, retrieve the bitcoin address and let the validator check it. The SendRequest object will use the bitcoin address, while the confirmation dialog will use whatever is displayed in the address text field i.e. coinspark address, if there is one. For reference, you can see what is in the textfield, which has been saved in prefs: String address = this.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_ADDRESS */ if (sendAddress.startsWith("s")) { CoinSparkAddress csa = CSMiscUtils.decodeCoinSparkAddress(sendAddress); String btcAddress = CSMiscUtils.getBitcoinAddressStringFromCoinSparkAddress(csa); if (btcAddress != null) { sendAddress = btcAddress; // the validator will check the btcAddress like normal. } // Does a payment ref exist? int flags = csa.getAddressFlags(); if ((flags & CoinSparkAddress.COINSPARK_ADDRESS_FLAG_PAYMENT_REFS) > 0) { paymentRef = csa.getPaymentRef(); } // Messages - can send message and BTC to CoinSpark address, without any assets. sendMessage = ((AssetFormDataProvider) dataProvider).getMessage(); canSendMessage = (flags & CoinSparkAddress.COINSPARK_ADDRESS_FLAG_TEXT_MESSAGES) > 0; } /*CoinSpark END */ Validator validator = new Validator(super.bitcoinController); if (validator.validate(sendAddress, sendAmount)) { // The address and amount are valid. // Create a SendRequest. Address sendAddressObject; sendAddressObject = new Address(bitcoinController.getModel().getNetworkParameters(), sendAddress); final SendRequest sendRequest = SendRequest.to(sendAddressObject, Utils.toNanoCoins(sendAmount)); // SendRequest sendRequest = SendRequest.to(sendAddressObject, Utils.toNanoCoins(sendAmount), 6, new BigInteger("10000"),1); sendRequest.ensureMinRequiredFee = true; sendRequest.fee = BigInteger.ZERO; sendRequest.feePerKb = BitcoinModel.SEND_FEE_PER_KB_DEFAULT; // Note - Request is populated with the AES key in the SendBitcoinNowAction after the user has entered it on the SendBitcoinConfirm form. // Send with payment ref - if it exists and is not 0 which SparkBit treats semantically as null if (paymentRef != null && paymentRef.getRef() != 0) { sendRequest.setPaymentRef(paymentRef); } // Send a message if the address will take it and message is not empty boolean willSendMessage = false; if (canSendMessage) { boolean isEmptyMessage = false; if (sendMessage == null || sendMessage.isEmpty() || sendMessage.trim().length() == 0) { isEmptyMessage = true; } if (!isEmptyMessage) { willSendMessage = true; CoinSparkMessagePart[] parts = { CSMiscUtils.createPlainTextCoinSparkMessagePart(sendMessage) }; String[] serverURLs = CSMiscUtils.getMessageDeliveryServersArray(bitcoinController); sendRequest.setMessage(parts, serverURLs); log.debug(">>>> Messaging servers = " + ArrayUtils.toString(serverURLs)); log.debug(">>>> parts[0] = " + parts[0]); log.debug(">>>> parts[0].fileName = " + parts[0].fileName); log.debug(">>>> parts[0].mimeType = " + parts[0].mimeType); log.debug(">>>> parts[0].content = " + new String(parts[0].content, "UTF-8")); //String message = "Hello, the time is now..." + DateTime.now().toString(); // parts[2].fileName = imagePath; // parts[2].mimeType = "image/png"; // byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath)); // parts[2].content = imageBytes; } } // // When sending a message, show a modal dialog. // CompleteTX now occurs in background thread so UI does not block // when "Send" is clicked with widget updates frozen. // // Show dialog with indeterminate progress bar final JDialog dialog = CSMiscUtils.createModalMessageDialogWithIndeterminateProgress(mainFrame, "SparkBit", "Contacting message delivery servers..."); // Dialog is made visible after futures have been set up ListeningExecutorService service = MoreExecutors .listeningDecorator(Executors.newSingleThreadExecutor()); //newFixedThreadPool(10)); ListenableFuture<Boolean> future = service.submit(new Callable<Boolean>() { public Boolean call() throws Exception { try { // Complete it (which works out the fee) but do not sign it yet. log.debug("Just about to complete the tx (and calculate the fee)..."); bitcoinController.getModel().getActiveWallet().completeTx(sendRequest, false); log.debug("The fee after completing the transaction was " + sendRequest.fee); } catch (Exception e) { throw e; } return true; } }); Futures.addCallback(future, new FutureCallback<Boolean>() { public void onSuccess(Boolean b) { // There is enough money. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dialog.dispose(); SendBitcoinConfirmDialog mySendBitcoinConfirmDialog = new SendBitcoinConfirmDialog( bitcoinController, mainFrame, sendRequest); mySendBitcoinConfirmDialog.setVisible(true); } }); } public void onFailure(Throwable thrown) { final String failureReason = thrown.getMessage(); final boolean isCSException = thrown instanceof org.coinspark.core.CSExceptions.CannotEncode; final boolean isInsufficientMoney = thrown instanceof com.google.bitcoin.core.InsufficientMoneyException; // There is not enough money. // TODO setup validation parameters accordingly so that it displays ok. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dialog.dispose(); if (isCSException) { JOptionPane .showMessageDialog(mainFrame, "SparkBit is unable to proceed with this transaction:\n\n" + failureReason, "SparkBit Error", JOptionPane.ERROR_MESSAGE); } else if (isInsufficientMoney) { // Try to show a human friendly message, need to pass the missing satoshis from failure reason. try { String numberOnly = failureReason.replaceAll("[^0-9]", ""); BigInteger needed = new BigInteger(numberOnly); JOptionPane.showMessageDialog(mainFrame, "SparkBit is unable to proceed with this transaction.\n\nInsufficient money in wallet, require " + Utils.bitcoinValueToFriendlyString(needed) + " BTC more.", "SparkBit Error", JOptionPane.ERROR_MESSAGE); } catch (NumberFormatException e) { ValidationErrorDialog myValidationErrorDialog = new ValidationErrorDialog( bitcoinController, mainFrame, sendRequest, true); myValidationErrorDialog.setVisible(true); } } else { ValidationErrorDialog myValidationErrorDialog = new ValidationErrorDialog( bitcoinController, mainFrame, sendRequest, true); myValidationErrorDialog.setVisible(true); } } }); } }); // Show message server dialog only if we are going to send if (willSendMessage) { dialog.setVisible(true); } /* // Complete it (which works out the fee) but do not sign it yet. log.debug("Just about to complete the tx (and calculate the fee)..."); boolean completedOk; try { bitcoinController.getModel().getActiveWallet().completeTx(sendRequest, false); completedOk = true; log.debug("The fee after completing the transaction was " + sendRequest.fee); } catch (InsufficientMoneyException ime) { completedOk = false; } if (completedOk) { // There is enough money. sendBitcoinConfirmDialog = new SendBitcoinConfirmDialog(super.bitcoinController, mainFrame, sendRequest); sendBitcoinConfirmDialog.setVisible(true); } else { // There is not enough money. // TODO setup validation parameters accordingly so that it displays ok. validationErrorDialog = new ValidationErrorDialog(super.bitcoinController, mainFrame, sendRequest, true); validationErrorDialog.setVisible(true); } */ } else { validationErrorDialog = new ValidationErrorDialog(super.bitcoinController, mainFrame, null, false); validationErrorDialog.setVisible(true); } } catch (WrongNetworkException e1) { logMessage(e1); } catch (AddressFormatException e1) { logMessage(e1); } catch (KeyCrypterException e1) { logMessage(e1); } catch (Exception e1) { logMessage(e1); } }
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. ja v a 2s . 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.ngrinder.recorder.ui.RecordingControlPanel.java
private boolean stopConfirm() { JOptionPane pane = new JOptionPane("Do you want to stop recording?", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION, null); JDialog dialog = pane.createDialog(SwingUtilities.getWindowAncestor(this), "Stop recording"); dialog.setVisible(true); Object selectedValue = pane.getValue(); if (selectedValue == null) { return false; }/*from www . ja v a 2s. c o m*/ return JOptionPane.YES_OPTION == (Integer) selectedValue; }
From source file:org.notebook.gui.widget.GuiUtils.java
/** * Adds the close action with escape key. * /*www. j a v a 2 s. com*/ * @param dialog * the dialog */ public static void addCloseActionWithEscapeKey(final JDialog dialog) { // Handle escape key to close the dialog KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); Action escapeAction = new AbstractAction() { private static final long serialVersionUID = 0L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }; dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); dialog.getRootPane().getActionMap().put("ESCAPE", escapeAction); }
From source file:org.nuclos.client.main.MainController.java
public static void cmdOpenSettings() { NuclosSettingsContainer panel = new NuclosSettingsContainer(frm); JOptionPane p = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null); JDialog dlg = p.createDialog(Main.getInstance().getMainFrame(), SpringLocaleDelegate.getInstance().getMessage("R00022927", "Einstellungen")); dlg.pack();/*from ww w.j ava 2 s. c om*/ dlg.setResizable(true); dlg.setVisible(true); Object o = p.getValue(); int res = ((o instanceof Integer) ? ((Integer) o).intValue() : JOptionPane.CANCEL_OPTION); if (res == JOptionPane.OK_OPTION) { try { panel.save(); } catch (PreferencesException e) { Errors.getInstance().showExceptionDialog(frm, e); } } }