List of usage examples for javax.swing JOptionPane showOptionDialog
@SuppressWarnings("deprecation") public static int showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) throws HeadlessException
initialValue
parameter and the number of choices is determined by the optionType
parameter. From source file:view.MultipleValidationDialog.java
private void writeToFile(String str) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle(Bundle.getBundle().getString("title.saveAs")); boolean validPath = false; FileNameExtensionFilter pdfFilter = new FileNameExtensionFilter( Bundle.getBundle().getString("filter.textFiles") + " (*.txt)", "txt"); fileChooser.setFileFilter(pdfFilter); File preferedFile = new File(Bundle.getBundle().getString("validationReport") + ".txt"); fileChooser.setSelectedFile(preferedFile); while (!validPath) { int userSelection = fileChooser.showSaveDialog(this); if (userSelection == JFileChooser.CANCEL_OPTION) { return; }//from w ww . j a v a 2 s. c o m if (userSelection == JFileChooser.APPROVE_OPTION) { String dest = fileChooser.getSelectedFile().getAbsolutePath(); if (new File(dest).exists()) { String msg = Bundle.getBundle().getString("msg.reportFileNameAlreadyExists"); Object[] options = { Bundle.getBundle().getString("btn.overwrite"), Bundle.getBundle().getString("btn.chooseNewPath"), Bundle.getBundle().getString("btn.cancel") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { validPath = true; } else if (opt == JOptionPane.CANCEL_OPTION) { return; } } else { validPath = true; } if (validPath) { try (PrintStream out = new PrintStream(new FileOutputStream(dest))) { out.print(str); JOptionPane.showMessageDialog(null, Bundle.getBundle().getString("msg.reportSavedSuccessfully"), "", JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException ex) { controller.Logger.getLogger().addEntry(ex); JOptionPane.showMessageDialog(null, Bundle.getBundle().getString("msg.reportSaveFailed"), "", JOptionPane.ERROR_MESSAGE); } break; } } } }
From source file:view.WorkspacePanel.java
public void setDocument(Document document) { if (null == document) { this.document = null; topToolbar.setVisible(false);//from w w w. ja v a 2s . c om bottomToolbar.setVisible(false); imagePanel.clear(); status = Status.READY; btnPageBackward.setEnabled(false); btnPageForward.setEnabled(false); lblTip.setVisible(true); removeTempSignature(); hideRightPanel(); } else { if (status.equals(Status.SIGNING)) { String msg = Bundle.getBundle().getString("msg.signatureStillNotAppliedOpenOther"); Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.NO_OPTION) { return; } } lblTip.setVisible(false); this.document = document; imagePanel.setDocumentAndComponents(mainWindow, jsImagePanel, document, btnPageBackward, btnPageForward); } jSplitPane1.setDividerSize(0); }
From source file:view.WorkspacePanel.java
@Override public void onSignatureClick(SignatureValidation sv) { if (status != Status.SIGNING) { jtValidation.clearSelection();/* ww w .j av a 2 s . co m*/ if (!rightPanel.isVisible()) { cl.show(this.rightPanel, String.valueOf(CardEnum.VALIDATE_PANEL)); rightPanel.setVisible(true); jSplitPane1.setDividerSize(5); jSplitPane1.setDividerLocation(0.6); } else if (this.status == Status.SIGNING) { String msg = ""; Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, Bundle.getBundle().getString("msg.signatureStillNotAppliedCancel1"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { removeTempSignature(); cl.show(this.rightPanel, String.valueOf(CardEnum.VALIDATE_PANEL)); } else { return; } } for (int i = 0; i < jtValidation.getRowCount(); i++) { TreePath tp = jtValidation.getPathForRow(i); DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) tp.getLastPathComponent(); if (dmtn.getUserObject() instanceof SignatureValidation) { SignatureValidation sVal = (SignatureValidation) dmtn.getUserObject(); if (sv.equals(sVal)) { jtValidation.setSelectionRow(i); jtValidation.expandRow(i); } } } status = Status.READY; } }
From source file:view.WorkspacePanel.java
private void btnValidateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnValidateActionPerformed if (mainWindow.getOpenedFiles().size() > 1) { JPopupMenu popup = new JPopupMenu(); JMenuItem m = null;/* w ww .ja va2 s.c o m*/ ActionListener validateOne = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!rightPanel.isVisible()) { changeCard(CardEnum.VALIDATE_PANEL, true); startValidationThread(); } else if (WorkspacePanel.this.status == WorkspacePanel.Status.SIGNING) { String msg = Bundle.getBundle().getString("yes"); Object[] options = { Bundle.getBundle().getString("msg.signatureStillNotAppliedCancel1"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { status = Status.READY; changeCard(CardEnum.VALIDATE_PANEL, true); startValidationThread(); } } } }; ActionListener validateAll = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MultipleValidationDialog mvd = new MultipleValidationDialog(mainWindow, true, mainWindow.getOpenedFiles()); mvd.setLocationRelativeTo(null); mvd.setVisible(true); } }; int numSigs = CCInstance.getInstance().getNumberOfSignatures(document.getDocumentLocation()); if (numSigs == 0) { m = new JMenuItem(Bundle.getBundle().getString("notSigned")); m.addActionListener(validateOne); m.setEnabled(false); popup.add(m); } else { m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateOnlyThis")); m.addActionListener(validateOne); popup.add(m); } if (mainWindow.getSelectedOpenedFiles().size() > 1 && mainWindow.getSelectedOpenedFiles().size() < mainWindow.getOpenedFiles().size()) { m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateAllSelected")); m.addActionListener(validateAll); popup.add(m); m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateAll")); m.addActionListener(validateAll); popup.add(m); } else { m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateAll")); m.addActionListener(validateAll); popup.add(m); } popup.setLightWeightPopupEnabled(true); popup.show(btnValidate, 0, btnValidate.getHeight()); } else if (!rightPanel.isVisible()) { changeCard(CardEnum.VALIDATE_PANEL, true); startValidationThread(); } else if (WorkspacePanel.this.status == WorkspacePanel.Status.SIGNING) { String msg = Bundle.getBundle().getString("msg.signatureStillNotAppliedCancel1"); Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { status = Status.READY; changeCard(CardEnum.VALIDATE_PANEL, true); startValidationThread(); } else { return; } } removeTempSignature(); }
From source file:view.WorkspacePanel.java
private void signDocument(Document document, boolean ocsp, boolean timestamp) { try {//from w w w .ja v a 2s.c o m if (tempCCAlias.getMainCertificate().getPublicKey().equals( CCInstance.getInstance().loadKeyStoreAndAliases().get(0).getMainCertificate().getPublicKey())) { try { String path1 = document.getDocumentLocation(); String path2 = null; if (path1.endsWith(".pdf")) { path2 = path1.substring(0, path1.length() - 4).concat("(aCCinado).pdf"); } JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle(Bundle.getBundle().getString("btn.saveAs")); if (null != path2) { boolean validPath = false; FileNameExtensionFilter pdfFilter = new FileNameExtensionFilter( Bundle.getBundle().getString("filter.pdfDocuments") + " (*.pdf)", "pdf"); fileChooser.setFileFilter(pdfFilter); File preferedFile = new File(path2); fileChooser.setCurrentDirectory(preferedFile); fileChooser.setSelectedFile(preferedFile); while (!validPath) { int userSelection = fileChooser.showSaveDialog(this); if (userSelection == JFileChooser.CANCEL_OPTION) { return; } if (userSelection == JFileChooser.APPROVE_OPTION) { String dest = fileChooser.getSelectedFile().getAbsolutePath(); if (new File(dest).exists()) { String msg = Bundle.getBundle().getString("msg.fileExists"); Object[] options = { Bundle.getBundle().getString("opt.replace"), Bundle.getBundle().getString("opt.chooseNewPath"), Bundle.getBundle().getString("btn.cancel") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { validPath = true; } else if (opt == JOptionPane.CANCEL_OPTION) { return; } } else { validPath = true; } signatureSettings.setOcspClient(ocsp); signatureSettings.setTimestamp(timestamp); if (validPath) { if (!CCInstance.getInstance().signPdf(document.getDocumentLocation(), dest, signatureSettings, null)) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("unknownErrorLog"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); return; } status = Status.READY; ArrayList<File> list = new ArrayList<>(); list.add(new File(document.getDocumentLocation())); int tempPage = imagePanel.getPageNumber(); mainWindow.closeDocuments(list, false); mainWindow.loadPdf(new File(dest), false); hideRightPanel(); imagePanel.setPageNumber(tempPage); JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("label.signatureOk"), "", JOptionPane.INFORMATION_MESSAGE); break; } } } } return; } catch (IOException ex) { if (ex instanceof FileNotFoundException) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.keystoreFileNotFound"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); controller.Logger.getLogger().addEntry(ex); } else if (ex.getLocalizedMessage().equals(Bundle.getBundle().getString("outputFileError"))) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.failedCreateOutputFile"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); controller.Logger.getLogger().addEntry(ex); signDocument(document, ocsp, timestamp); } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("unknownErrorLog"), Bundle.getBundle().getString("label.signatureFailed"), JOptionPane.ERROR_MESSAGE); controller.Logger.getLogger().addEntry(ex); } } catch (DocumentException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | HeadlessException | CertificateException | KeyStoreException ex) { controller.Logger.getLogger().addEntry(ex); } catch (SignatureFailedException ex) { if (ex.getLocalizedMessage().equals(Bundle.getBundle().getString("timestampFailed"))) { String msg = Bundle.getBundle().getString("msg.timestampFailedNoInternet"); Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { signDocument(document, false, false); } } else { controller.Logger.getLogger().addEntry(ex); } } return; } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); } } catch (LibraryNotLoadedException | KeyStoreNotLoadedException | CertificateException | KeyStoreException | LibraryNotFoundException | AliasException ex) { controller.Logger.getLogger().addEntry(ex); } JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); }
From source file:view.WorkspacePanel.java
public void signBatch(CCSignatureSettings settings) { ArrayList<File> toSignList = mainWindow.getOpenedFiles(); try {//from w ww.j a va2s . c om if (tempCCAlias.getMainCertificate().getPublicKey().equals( CCInstance.getInstance().loadKeyStoreAndAliases().get(0).getMainCertificate().getPublicKey())) { String dest = null; Object[] options = { Bundle.getBundle().getString("opt.saveInOriginalFolder"), Bundle.getBundle().getString("msg.choosePath"), Bundle.getBundle().getString("btn.cancel") }; int i = JOptionPane.showOptionDialog(null, Bundle.getBundle().getString("msg.chooseSignedPath"), "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (i == 1) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(".")); chooser.setDialogTitle(Bundle.getBundle().getString("btn.choosePath")); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { dest = chooser.getSelectedFile().getAbsolutePath(); } else { return; } } else if (i == 2) { return; } MultipleSignDialog msd = new MultipleSignDialog(mainWindow, true, toSignList, settings, dest); msd.setLocationRelativeTo(null); msd.setVisible(true); ArrayList<File> signedDocsList = msd.getSignedDocsList(); if (!signedDocsList.isEmpty()) { removeTempSignature(); clearSignatureFields(); hideRightPanel(); status = Status.READY; mainWindow.closeDocuments(mainWindow.getOpenedFiles(), false); for (File f : signedDocsList) { mainWindow.loadPdf(f, false); } } return; } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); } } catch (LibraryNotLoadedException | KeyStoreNotLoadedException | CertificateException | KeyStoreException | LibraryNotFoundException | AliasException ex) { controller.Logger.getLogger().addEntry(ex); } JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); }
From source file:view.WorkspacePanel.java
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed String msg = Bundle.getBundle().getString("msg.cancelSignature"); Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { // Cancelar Assinatura if (null != exec) { if (!exec.isShutdown()) { exec.shutdown();/*from ww w. j ava 2s .c o m*/ exec = null; //signatureOptionsPanel.setVisible(false); } } removeTempSignature(); hideRightPanel(); status = Status.READY; } }
From source file:view.WorkspacePanel.java
private void btnApplySignatureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplySignatureActionPerformed if (tempCCAlias != null) { signatureSettings.setPageNumber(imagePanel.getPageNumber()); signatureSettings.setCcAlias(tempCCAlias); signatureSettings.setReason(tfReason.getText()); signatureSettings.setLocation(tfLocation.getText()); if (jRadioButton1.isSelected()) { signatureSettings.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED); } else if (jRadioButton2.isSelected()) { signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED); } else if (jRadioButton3.isSelected()) { signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING); } else if (jRadioButton4.isSelected()) { signatureSettings//from ww w . j av a 2 s .c o m .setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS); } signatureSettings.setOcspClient(true); if (cbTimestamp.isSelected()) { signatureSettings.setTimestamp(true); if (tfTimestamp.getText().isEmpty()) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.timestampEmpty"), "", JOptionPane.ERROR_MESSAGE); return; } else { signatureSettings.setTimestampServer(tfTimestamp.getText()); } } else { signatureSettings.setTimestamp(false); cbTimestamp.setSelected(false); tfTimestamp.setVisible(false); } signatureSettings.setVisibleSignature(cbVisibleSignature.isSelected()); if (cbVisibleSignature.isSelected()) { Point p = tempSignature.getScaledPositionOnDocument(); Dimension d = tempSignature.getScaledSizeOnDocument(); float p1 = (float) p.getX(); float p3 = (float) d.getWidth() + p1; float p2 = (float) ((document.getPageDimension(imagePanel.getPageNumber(), 0).getHeight()) - (p.getY() + d.getHeight())); float p4 = (float) d.getHeight() + p2; signatureSettings.setVisibleSignature(true); if (tempSignature.getImageLocation() != null) { signatureSettings.getAppearance().setImageLocation(tempSignature.getImageLocation()); } Rectangle rect = new Rectangle(p1, p2, p3, p4); signatureSettings.setSignaturePositionOnDocument(rect); signatureSettings.setText(tfText.getText()); } else { signatureSettings.setVisibleSignature(false); } if (mainWindow.getOpenedFiles().size() > 1) { Object[] options = { Bundle.getBundle().getString("menuItem.allDocuments"), Bundle.getBundle().getString("menuItem.onlyThis"), Bundle.getBundle().getString("btn.cancel") }; int i = JOptionPane.showOptionDialog(null, Bundle.getBundle().getString("msg.multipleDocumentsOpened"), Bundle.getBundle().getString("msg.multipleDocumentsOpenedTitle"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (i == 0) { signBatch(signatureSettings); } else if (i == 1) { signDocument(document, true, true); } } else { signDocument(document, true, true); } } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("noSmartcardFound"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); changeCard(CardEnum.SIGN_PANEL, false); } }
From source file:xtrememp.update.SoftwareUpdate.java
public static void checkForUpdates(final boolean showDialogs) { checkForUpdatesWorker = new SwingWorker<Version, Void>() { @Override//from w w w .j av a 2 s . co m protected Version doInBackground() throws Exception { logger.debug("checkForUpdates: started..."); long startTime = System.currentTimeMillis(); Version version = getLastVersion(new URL(updatesURL)); if (showDialogs) { // Simulate (if needed) a delay of 2 sec max to let the user cancel the task. long delayTime = System.currentTimeMillis() - startTime - 2000; if (delayTime > 0) { Thread.sleep(delayTime); } } return version; } @Override protected void done() { logger.debug("checkForUpdates: done"); if (checkForUpdatesDialog != null && checkForUpdatesDialog.isVisible()) { checkForUpdatesDialog.dispose(); } if (!isCancelled()) { try { newerVersion = get(); if (newerVersion != null && newerVersion.compareTo(currentVersion) == 1) { logger.debug("checkForUpdates: currentVersion = {}", currentVersion); logger.debug("checkForUpdates: newerVersion = {}", newerVersion); logger.debug("SoftwareUpdate::checkForUpdates: updates found"); Object[] options = { tr("Button.Cancel") }; Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.BROWSE)) { options = new Object[] { tr("Button.Download"), tr("Button.Cancel") }; } } JPanel panel = new JPanel(new BorderLayout(0, 10)); panel.add(new JLabel("<html>" + tr("Dialog.SoftwareUpdate.UpdatesFound") + " (" + newerVersion + ")</html>"), BorderLayout.CENTER); JCheckBox hideCheckBox = null; if (Settings.isAutomaticUpdatesEnabled()) { hideCheckBox = new JCheckBox( tr("Dialog.SoftwareUpdate.DisableAutomaticCheckForUpdates")); panel.add(hideCheckBox, BorderLayout.SOUTH); } int option = JOptionPane.showOptionDialog(XtremeMP.getInstance().getMainFrame(), panel, tr("Dialog.SoftwareUpdate"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (hideCheckBox != null) { Settings.setAutomaticUpdatesEnabled(!hideCheckBox.isSelected()); } if ((options.length == 2) && (option == JOptionPane.OK_OPTION)) { try { URL url = new URL(newerVersion.getDownloadURL()); desktop.browse(url.toURI()); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } } else { logger.debug("checkForUpdates: no updates found"); if (showDialogs) { JOptionPane.showMessageDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate.NoUpdatesFound"), tr("Dialog.SoftwareUpdate"), JOptionPane.INFORMATION_MESSAGE); } } } catch (Exception ex) { logger.error(ex.getMessage(), ex); if (showDialogs) { JOptionPane.showMessageDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate.ConnectionFailure"), tr("Dialog.SoftwareUpdate"), JOptionPane.INFORMATION_MESSAGE); } } } } }; checkForUpdatesWorker.execute(); }
From source file:xtrememp.XtremeMP.java
@Override public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == openMenuItem) { playlistManager.addFilesDialog(true); } else if (source == openURLMenuItem) { String url = JOptionPane.showInputDialog(mainFrame, tr("Dialog.OpenURL.Message"), tr("Dialog.OpenURL"), JOptionPane.INFORMATION_MESSAGE); if (url != null && Utilities.startWithProtocol(url)) { boolean isPlaylistFile = false; for (String ext : PlaylistFileFilter.PlaylistFileExt) { if (url.endsWith(ext)) { isPlaylistFile = true; }// w ww . ja v a2s . c om } if (isPlaylistFile) { playlistManager.clearPlaylist(); playlistManager.loadPlaylist(url); playlist.begin(); } else { PlaylistItem newPli = new PlaylistItem(url, url, -1, false); playlistManager.add(newPli); playlist.setCursor(newPli); } acOpenAndPlay(); } } else if (source == openPlaylistMenuItem) { playlistManager.openPlaylistDialog(); } else if (source == savePlaylistMenuItem) { playlistManager.savePlaylistDialog(); } else if (source == preferencesMenuItem) { PreferencesDialog preferencesDialog = new PreferencesDialog(audioPlayer, this); preferencesDialog.setVisible(true); } else if (source == exitMenuItem) { exit(); } else if (source == playPauseMenuItem || source == playPauseButton) { acPlayPause(); } else if (source == previousMenuItem || source == previousButton) { acPrevious(); } else if (source == nextMenuItem || source == nextButton) { acNext(); } else if (source == randomizePlaylistMenuItem) { playlistManager.randomizePlaylist(); } else if (source == stopMenuItem || source == stopButton) { acStop(); } else if (source == playlistManagerMenuItem) { if (visualizationManager.isVisible()) { visualizationManager.setDssEnabled(false); CardLayout cardLayout = (CardLayout) (mainPanel.getLayout()); cardLayout.show(mainPanel, Utilities.PLAYLIST_MANAGER); playlistManagerMenuItem.setSelected(true); Settings.setLastView(Utilities.PLAYLIST_MANAGER); } } else if (source == visualizationMenuItem) { if (playlistManager.isVisible()) { visualizationManager.setDssEnabled(true); CardLayout cardLayout = (CardLayout) (mainPanel.getLayout()); cardLayout.show(mainPanel, Utilities.VISUALIZATION_PANEL); visualizationMenuItem.setSelected(true); Settings.setLastView(Utilities.VISUALIZATION_PANEL); } } else if (source == updateMenuItem) { SoftwareUpdate.checkForUpdates(true); SoftwareUpdate.showCheckForUpdatesDialog(); } else if (source == aboutMenuItem) { Object[] options = { tr("Button.Close") }; Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.BROWSE)) { options = new Object[] { tr("Button.Close"), tr("Button.Website") }; } } StringBuffer message = new StringBuffer(); message.append("<html><b><font color='red' size='5'>").append(tr("Application.title")); message.append("</font></b><br>").append(tr("Application.description")); message.append("<br>Copyright 2005-2014 The Xtreme Media Player Project"); message.append("<br><br><b>").append(tr("Dialog.About.Authors")).append(": </b>") .append(tr("Application.authors")); message.append("<br><b>").append(tr("Dialog.About.Version")).append(": </b>").append(currentVersion); message.append("<br><b>").append(tr("Dialog.About.Codename")).append(": </b>") .append(currentVersion.getCodename()); message.append("<br><b>").append(tr("Dialog.About.ReleaseDate")).append(": </b>") .append(currentVersion.getReleaseDate()); message.append("<br><b>").append(tr("Dialog.About.Homepage")).append(": </b>") .append(tr("Application.homepage")); message.append("<br><br><b>").append(tr("Dialog.About.JavaVersion")).append(": </b>") .append(System.getProperty("java.version")); message.append("<br><b>").append(tr("Dialog.About.JavaVendor")).append(": </b>") .append(System.getProperty("java.vendor")); message.append("<br><b>").append(tr("Dialog.About.JavaHome")).append(": </b>") .append(System.getProperty("java.home")); message.append("<br><b>").append(tr("Dialog.About.OSName")).append(": </b>") .append(System.getProperty("os.name")); message.append("<br><b>").append(tr("Dialog.About.OSArch")).append(": </b>") .append(System.getProperty("os.arch")); message.append("<br><b>").append(tr("Dialog.About.UserName")).append(": </b>") .append(System.getProperty("user.name")); message.append("<br><b>").append(tr("Dialog.About.UserHome")).append(": </b>") .append(System.getProperty("user.home")); message.append("<br><b>").append(tr("Dialog.About.UserDir")).append(": </b>") .append(System.getProperty("user.dir")); message.append("</html>"); int n = JOptionPane.showOptionDialog(mainFrame, message, tr("Dialog.About"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, Utilities.APP_256_ICON, options, options[0]); if (n == 1 && desktop != null) { try { URL url = new URL(tr("Application.homepage")); desktop.browse(url.toURI()); } catch (IOException | URISyntaxException ex) { logger.error(ex.getMessage(), ex); } } } else if (source.equals(playModeRepeatNoneMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.REPEAT_NONE); } else if (source.equals(playModeRepeatOneMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.REPEAT_ONE); } else if (source.equals(playModeRepeatAllMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.REPEAT_ALL); } else if (source.equals(playModeShuffleMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.SHUFFLE); } }