List of usage examples for javax.swing JFileChooser setApproveButtonText
@BeanProperty(preferred = true, description = "The text that goes in the ApproveButton.") public void setApproveButtonText(String approveButtonText)
ApproveButton
in the FileChooserUI
. From source file:org.pgptool.gui.ui.tools.browsefs.ExistingFileChooserDialog.java
private JFileChooser buildFileChooserDialog() { JFileChooser ofd = new JFileChooser(); ofd.setFileSelectionMode(JFileChooser.FILES_ONLY); ofd.setAcceptAllFileFilterUsed(true); ofd.setMultiSelectionEnabled(false); ofd.setDialogTitle(Messages.get("action.chooseExistingFile")); ofd.setApproveButtonText(Messages.get("action.choose")); suggestInitialDirectory(ofd);/*from w w w . j a va2 s . c om*/ doFileChooserPostConstruct(ofd); return ofd; }
From source file:org.pgptool.gui.ui.tools.browsefs.MultipleFilesChooserDialog.java
private JFileChooser buildFileChooserDialog() { JFileChooser ofd = new JFileChooser(); ofd.setFileSelectionMode(JFileChooser.FILES_ONLY); ofd.setAcceptAllFileFilterUsed(true); ofd.setMultiSelectionEnabled(true);/*from ww w. ja v a 2 s .com*/ ofd.setDialogTitle(Messages.get("action.chooseExistingFile")); ofd.setApproveButtonText(Messages.get("action.choose")); suggestInitialDirectory(ofd); doFileChooserPostConstruct(ofd); return ofd; }
From source file:storybook.ui.chart.AbstractChartPanel.java
private AbstractAction getExportAction() { if (this.exportAction == null) { this.exportAction = new AbstractAction() { @Override//from w ww .jav a 2 s. c om public void actionPerformed(ActionEvent paramAnonymousActionEvent) { try { Internal localInternal = BookUtil.get(AbstractChartPanel.this.mainFrame, SbConstants.BookKey.EXPORT_DIRECTORY, EnvUtil.getDefaultExportDir(AbstractChartPanel.this.mainFrame)); File localFile1 = new File(localInternal.getStringValue()); JFileChooser localJFileChooser = new JFileChooser(localFile1); localJFileChooser.setFileFilter(new PngFileFilter()); localJFileChooser.setApproveButtonText(I18N.getMsg("msg.common.export")); String str = AbstractChartPanel.this.mainFrame.getDbFile().getName() + " - " + AbstractChartPanel.this.chartTitle; str = IOUtil.cleanupFilename(str); localJFileChooser.setSelectedFile(new File(str)); int i = localJFileChooser.showDialog(AbstractChartPanel.this.getThis(), I18N.getMsg("msg.common.export")); if (i == 1) { return; } File localFile2 = localJFileChooser.getSelectedFile(); if (!localFile2.getName().endsWith(".png")) { localFile2 = new File(localFile2.getPath() + ".png"); } ScreenImage.createImage(AbstractChartPanel.this.panel, localFile2.toString()); JOptionPane.showMessageDialog(AbstractChartPanel.this.getThis(), I18N.getMsg("msg.common.export.success"), I18N.getMsg("msg.common.export"), 1); } catch (HeadlessException | IOException localException) { } } }; } return this.exportAction; }
From source file:org.jax.maanova.plot.SaveChartAction.java
/** * {@inheritDoc}//from w w w . j a v a 2 s . co m */ public void actionPerformed(ActionEvent e) { JFreeChart myChart = this.chart; Dimension mySize = this.size; if (myChart == null || mySize == null) { LOG.severe("Failed to save graph image because of a null value"); MessageDialogUtilities.errorLater(Maanova.getInstance().getApplicationFrame(), "Internal error: Failed to save graph image.", "Image Save Failed"); } else { // use the remembered starting dir MaanovaApplicationConfigurationManager configurationManager = MaanovaApplicationConfigurationManager .getInstance(); JMaanovaApplicationState applicationState = configurationManager.getApplicationState(); FileType rememberedJaxbImageDir = applicationState.getRecentImageExportDirectory(); File rememberedImageDir = null; if (rememberedJaxbImageDir != null && rememberedJaxbImageDir.getFileName() != null) { rememberedImageDir = new File(rememberedJaxbImageDir.getFileName()); } // select the image file to save JFileChooser fileChooser = new JFileChooser(rememberedImageDir); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setApproveButtonText("Save Graph"); fileChooser.setDialogTitle("Save Graph as Image"); fileChooser.setMultiSelectionEnabled(false); fileChooser.addChoosableFileFilter(PngFileFilter.getInstance()); fileChooser.setFileFilter(PngFileFilter.getInstance()); int response = fileChooser.showSaveDialog(Maanova.getInstance().getApplicationFrame()); if (response == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); // tack on the extension if there isn't one // already if (!PngFileFilter.getInstance().accept(selectedFile)) { String newFileName = selectedFile.getName() + "." + PngFileFilter.PNG_EXTENSION; selectedFile = new File(selectedFile.getParentFile(), newFileName); } if (selectedFile.exists()) { // ask the user if they're sure they want to overwrite String message = "Exporting the graph image to " + selectedFile.getAbsolutePath() + " will overwrite an " + " existing file. Would you like to continue anyway?"; if (LOG.isLoggable(Level.FINE)) { LOG.fine(message); } boolean overwriteOk = MessageDialogUtilities .confirmOverwrite(Maanova.getInstance().getApplicationFrame(), selectedFile); if (!overwriteOk) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("overwrite canceled"); } return; } } try { ChartUtilities.saveChartAsPNG(selectedFile, myChart, mySize.width, mySize.height); File parentDir = selectedFile.getParentFile(); if (parentDir != null) { // update the "recent image directory" ObjectFactory objectFactory = new ObjectFactory(); FileType latestJaxbImageDir = objectFactory.createFileType(); latestJaxbImageDir.setFileName(parentDir.getAbsolutePath()); applicationState.setRecentImageExportDirectory(latestJaxbImageDir); } } catch (Exception ex) { LOG.log(Level.SEVERE, "failed to save graph image", ex); } } } }
From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java
/** * Concetructor.//from w w w. j a v a2 s . c o m * * @param noteResource * The concept resource. * @param dragAndDropReference * The drag'n'drop reference. */ public AttachmentJDialog(ConceptResource conceptResource, DragAndDropReference dragAndDropReference) { super(Messages.getString("AttachmentJDialog.title")); this.conceptResource = conceptResource; getContentPane().setLayout(new BorderLayout()); JPanel p, pp; p = new JPanel(); p.setLayout(new BorderLayout()); JLabel intro = new JLabel("<html> " + Messages.getString("AttachmentJDialog.introduction") + " <br><br></html>"); p.add(intro, BorderLayout.NORTH); p.add(new JLabel("<html> " + Messages.getString("AttachmentJDialog.description") + "</html>"), BorderLayout.CENTER); description = new JTextField(38); pp = new JPanel(new FlowLayout(FlowLayout.LEFT)); pp.add(description); p.add(pp, BorderLayout.SOUTH); getContentPane().add(p, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.setBorder(new TitledBorder(Messages.getString("AttachmentJDialog.resource"))); ButtonGroup attachType = new ButtonGroup(); JPanel webPanel = new JPanel(); webPanel.setLayout(new BorderLayout()); webType = new JRadioButton(Messages.getString("AttachmentJDialog.web")); webType.setActionCommand(WEB); webType.addActionListener(this); webType.setSelected(true); attachType.add(webType); webPanel.add(webType, BorderLayout.NORTH); urlTextField = new JTextField("http://", 35); urlTextField.selectAll(); urlTextField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { attach(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); p.add(urlTextField); webPanel.add(p, BorderLayout.SOUTH); mainPanel.add(webPanel, BorderLayout.NORTH); JPanel localPanel = new JPanel(); localPanel.setLayout(new BorderLayout()); JRadioButton localType = new JRadioButton(Messages.getString("AttachmentJDialog.local")); localType.setActionCommand(LOCAL); localType.addActionListener(this); localPanel.add(localType, BorderLayout.NORTH); pathTextField = new JTextField(35); pathTextField.setEnabled(false); browseButton = new JButton(Messages.getString("AttachmentJDialog.browse")); browseButton.setToolTipText(Messages.getString("AttachmentJDialog.browseTip")); browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("AttachmentJDialog.attach")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("AttachmentJDialog.chooseAttachment")); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int returnVal = fc.showOpenDialog(AttachmentJDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); pathTextField.setText(file.toString()); } } }); browseButton.setEnabled(false); pp = new JPanel(); pp.setLayout(new BorderLayout()); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); pp.add(p, BorderLayout.NORTH); p.add(pathTextField); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(browseButton); pp.add(p, BorderLayout.SOUTH); localPanel.add(pp, BorderLayout.SOUTH); attachType.add(localType); mainPanel.add(localPanel, BorderLayout.SOUTH); getContentPane().add(mainPanel, BorderLayout.CENTER); // buttons p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton(Messages.getString("AttachmentJDialog.attach")); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { attach(); } }); JButton cancelButton = new JButton(Messages.getString("AttachmentJDialog.cancel")); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AttachmentJDialog.this.dispose(); } }); getContentPane().add(p, BorderLayout.SOUTH); /* * drag and drop initialization */ if (dragAndDropReference != null) { if (dragAndDropReference.getType() == DragAndDropReference.BROWSER_LINK) { urlTextField.setText(dragAndDropReference.getReference()); localType.setSelected(false); webType.setSelected(true); enableWebTypeButtons(); } else { pathTextField.setText(dragAndDropReference.getReference()); localType.setSelected(true); webType.setSelected(false); enableLocalTypeButtons(); } description.setText(dragAndDropReference.getTitle()); } pack(); Gfx.centerAndShowWindow(this); }
From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Perform action on event for this object. *///from w ww.j av a 2 s. c o m public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == boutonOpenFile) { JFileChooser jfcProgramme = new JFileChooser("."); jfcProgramme.setMultiSelectionEnabled(false); jfcProgramme.setDialogTitle("Selectionner un fichier"); jfcProgramme.setApproveButtonText("Selectionner"); jfcProgramme.setApproveButtonToolTipText("Cliquer apres avoir selectionn un fichier"); jfcProgramme.setAcceptAllFileFilterUsed(false); if (jfcProgramme.showDialog(this, null) == JFileChooser.APPROVE_OPTION) { try { filename.setText(jfcProgramme.getSelectedFile().getCanonicalPath()); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Erreur de nom de fichier.", "Erreur", JOptionPane.ERROR_MESSAGE); } } } if (o == boutonOk && filename.getText().length() != 0) { if (!this.loadFile(filename.getText(), (String) this.syntaxes.getSelectedItem())) { JOptionPane.showMessageDialog(this, this.getErrorMessage(), "Erreur", JOptionPane.ERROR_MESSAGE); } else { windowClosing(null); } } if (o == boutonAnnuler) { windowClosing(null); } }
From source file:de.ep3.ftpc.controller.portal.CrawlerDownloadController.java
@Override public void mouseClicked(MouseEvent e) { CrawlerResultsItem.PreviewPanel previewPanel = (CrawlerResultsItem.PreviewPanel) e.getSource(); CrawlerResult crawlerResult = previewPanel.getCrawlerResult(); CrawlerFile crawlerFile = crawlerResult.getFile(); FTPClient ftpClient = crawlerResult.getFtpClient(); if (ftpClient.isConnected()) { JOptionPane.showMessageDialog(portalFrame, i18n.translate("crawlerDownloadWhileConnected"), null, JOptionPane.ERROR_MESSAGE); return;//from w w w. j a v a2 s . c o m } String fileExtension = crawlerFile.getExtension(); JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter chooserFilter = new FileNameExtensionFilter( i18n.translate("fileType", fileExtension.toUpperCase()), crawlerFile.getExtension()); chooser.setApproveButtonText(i18n.translate("buttonSave")); chooser.setDialogTitle(i18n.translate("fileDownloadTo")); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileFilter(chooserFilter); chooser.setSelectedFile(new File(crawlerFile.getName())); int selection = chooser.showSaveDialog(portalFrame); if (selection == JFileChooser.APPROVE_OPTION) { File fileToSave = chooser.getSelectedFile(); Server relatedServer = crawlerResult.getServer(); try { ftpClient.connect(relatedServer.need("server.ip"), Integer.parseInt(relatedServer.need("server.port"))); int replyCode = ftpClient.getReplyCode(); if (!FTPReply.isPositiveCompletion(replyCode)) { throw new IOException(i18n.translate("crawlerServerRefused")); } if (relatedServer.has("user.name")) { String userName = relatedServer.get("user.name"); String userPassword = ""; if (relatedServer.hasTemporary("user.password")) { userPassword = relatedServer.getTemporary("user.password"); } boolean loggedIn = ftpClient.login(userName, userPassword); if (!loggedIn) { throw new IOException(i18n.translate("crawlerServerAuthFail")); } } ftpClient.setFileType(FTP.BINARY_FILE_TYPE); /* Download file */ InputStream is = ftpClient.retrieveFileStream(crawlerFile.getFullName()); if (is != null) { byte[] rawFile = new byte[(int) crawlerFile.getSize()]; int i = 0; while (true) { int b = is.read(); if (b == -1) { break; } rawFile[i] = (byte) b; i++; /* Occasionally update the download progress */ if (i % 1024 == 0) { int progress = Math.round((((float) i) / crawlerFile.getSize()) * 100); status.add(i18n.translate("crawlerDownloadProgress", progress)); } } is.close(); is = null; if (!ftpClient.completePendingCommand()) { throw new IOException(); } Files.write(fileToSave.toPath(), rawFile); } /* Logout and disconnect */ ftpClient.logout(); tryDisconnect(ftpClient); status.add(i18n.translate("crawlerDownloadDone")); } catch (IOException ex) { tryDisconnect(ftpClient); JOptionPane.showMessageDialog(portalFrame, i18n.translate("crawlerDownloadFailed", ex.getMessage()), null, JOptionPane.ERROR_MESSAGE); } } }
From source file:de.quadrillenschule.azocamsyncd.gui.ConfigurationWizardJFrame.java
private void autoruninstalljButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoruninstalljButton1ActionPerformed boolean success = false; JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setApproveButtonText("Prepare card..."); File startFile = new File(System.getProperty("user.dir")); //Get the current directory // Find System Root while (!FileSystemView.getFileSystemView().isFileSystemRoot(startFile)) { startFile = startFile.getParentFile(); }// www . j ava 2 s .c om jfc.setCurrentDirectory(startFile); int origDriveChooserRetVal = jfc.showDialog(rootPane, "Open"); if (origDriveChooserRetVal == JFileChooser.APPROVE_OPTION) { try { File myfile = new File(jfc.getSelectedFile().getAbsolutePath(), "autorun.sh"); myfile.createNewFile(); FileOutputStream fos; try { fos = new FileOutputStream(myfile); IOUtils.copy(getClass().getResourceAsStream( "/de/quadrillenschule/azocamsyncd/ftpservice/res/autorun.sh"), fos); fos.close(); success = true; } catch (FileNotFoundException ex) { Logger.getLogger(ConfigurationWizardJFrame.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(ConfigurationWizardJFrame.class.getName()).log(Level.SEVERE, null, ex); } } if (!success) { JOptionPane.showMessageDialog(rootPane, "The WiFi is SD card could not be written to. Please check if you selected the right card and it is not write-protected.", "SD card could not be prepared", JOptionPane.WARNING_MESSAGE); } else { JOptionPane.showMessageDialog(rootPane, "The WiFi SD card is prepared for operating an FTP and Telnet server.", "Success!", JOptionPane.INFORMATION_MESSAGE); step0jCheckBox.setSelected(true); step0jCheckBox.setText("Done"); updateSelectedPanel(1); } }
From source file:de.uka.ilkd.key.dl.gui.initialdialog.gui.ToolInstaller.java
public void install(JComponent parent, Window dialog) { final File installDirectory; switch (OSInfosDefault.INSTANCE.getOs()) { case OSX://from ww w . jav a 2 s . c om System.setProperty("apple.awt.fileDialogForDirectories", "true"); FileDialog d = new FileDialog(Frame.getFrames()[0], "Choose directory for installation of " + toolName, FileDialog.LOAD); d.setVisible(true); System.setProperty("apple.awt.fileDialogForDirectories", "false"); if (d.getFile() != null) { installDirectory = new File(d.getDirectory(), d.getFile()); } else { installDirectory = null; } break; default: final JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Choose directory for installation of " + toolName); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setApproveButtonText("Install " + toolName + " here"); int result = chooser.showDialog(parent, "Install " + toolName + " here"); if (result == JFileChooser.APPROVE_OPTION) { installDirectory = chooser.getSelectedFile(); } else { installDirectory = null; } } if (installDirectory != null) { try { final File tmp = File.createTempFile("keymaeraDownload", "." + ft.toString().toLowerCase()); final FileInfo info = new FileInfo(url, tmp.getName(), false); final DownloadManager dlm = new DownloadManager(); ProgressBarWindow pbw = new ProgressBarWindow(parent, installDirectory, tmp, ft, ps, dialog); dlm.addListener(pbw); Runnable down = new Runnable() { @Override public void run() { dlm.downloadAll(new FileInfo[] { info }, 2000, tmp.getParentFile().getAbsolutePath(), true); } }; Thread thread = new Thread(down); thread.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:Display.java
@SuppressWarnings("unchecked") Display() {// w ww .ja v a 2 s . c o m super(Reference.NAME); cardLayout = new CardLayout(); panel.setLayout(cardLayout); final int java7Update = Utils.Validators.java7Update.check(); final int java8Update = Utils.Validators.java8Update.check(); try { URL host = new URL(Reference.PROTOCOL, Reference.SOURCE_HOST, Reference.PORT, Reference.JSON_ARRAY); JSONParser parser = new JSONParser(); Object json = parser.parse(new URLReader(host)); final JSONArray array = (JSONArray) json; JSONObject nameObject1 = (JSONObject) array.get(0); XPackInstaller.selected_url = nameObject1.get("url").toString(); XPackInstaller.javaVersion = Integer.parseInt(nameObject1.get("version").toString()); XPackInstaller.profile = nameObject1.get("profile").toString(); XPackInstaller.canAcceptOptional = Boolean .parseBoolean(nameObject1.get("canAcceptOptional").toString()); if (!XPackInstaller.canAcceptOptional) { checkOptifine.setEnabled(false); checkOptifine.setSelected(false); zainstalujMoCreaturesCheckBox.setEnabled(false); zainstalujMoCreaturesCheckBox.setSelected(false); optionalText.setEnabled(false); } else { checkOptifine.setEnabled(true); zainstalujMoCreaturesCheckBox.setEnabled(true); optionalText.setEnabled(true); } for (Object anArray : array) { comboBox1.addItem(new JSONObject((JSONObject) anArray).get("name")); } comboBox1.addActionListener(e -> { int i = 0; while (true) { JSONObject nameObject = (JSONObject) array.get(i); String name1 = nameObject.get("name").toString(); if (name1 == comboBox1.getSelectedItem()) { XPackInstaller.canAcceptOptional = Boolean .parseBoolean(nameObject.get("canAcceptOptional").toString()); XPackInstaller.selected_url = nameObject.get("url").toString(); XPackInstaller.javaVersion = Integer.parseInt(nameObject.get("version").toString()); XPackInstaller.profile = nameObject.get("profile").toString(); if (!XPackInstaller.canAcceptOptional) { checkOptifine.setEnabled(false); checkOptifine.setSelected(false); zainstalujMoCreaturesCheckBox.setEnabled(false); zainstalujMoCreaturesCheckBox.setSelected(false); optionalText.setEnabled(false); } else { checkOptifine.setEnabled(true); zainstalujMoCreaturesCheckBox.setEnabled(true); optionalText.setEnabled(true); } break; } i++; } int javaStatus; if (XPackInstaller.javaVersion == 8) { javaStatus = java8Update; } else { javaStatus = java7Update; } if (javaStatus == 0) { javaversion.setText("TAK"); javaversion.setForeground(Reference.COLOR_DARK_GREEN); } else if (javaStatus == 1) { javaversion.setText("NIE"); javaversion.setForeground(Reference.COLOR_DARK_ORANGE); } else if (javaStatus == 2) { if (XPackInstaller.javaVersion == 8) { javaversion.setText("Nie posiadasz JRE8 w wersji 25 lub nowszej!"); } else { javaversion.setText("Nie posiadasz najnowszej wersji JRE7!"); } javaversion.setForeground(Color.RED); } if (osarch.getText().equals("TAK") && Ram.getText().equals("TAK") && javaarch.getText().equals("TAK") && (javaversion.getText().equals("TAK") || javaversion.getText().equals("NIE"))) { XPackInstaller.canGoForward = true; button2.setText("Dalej"); } else { XPackInstaller.canGoForward = false; button2.setText("Anuluj"); } }); } catch (FileNotFoundException | ParseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panel, "Brak poczenia z Internetem!", "Bd", JOptionPane.ERROR_MESSAGE); System.exit(0); } pobierzOryginalnyLauncherMCCheckBox.addActionListener(e -> { if (pobierzOryginalnyLauncherMCCheckBox.isSelected()) { PathLauncherLabel.setEnabled(true); textField1.setEnabled(true); button3.setEnabled(true); XPackInstaller.installLauncher = true; labelLauncher.setEnabled(true); progressBar3.setEnabled(true); } else { PathLauncherLabel.setEnabled(false); textField1.setEnabled(false); button3.setEnabled(false); XPackInstaller.installLauncher = false; labelLauncher.setEnabled(false); progressBar3.setEnabled(false); } }); button3.addActionListener(e -> { JFileChooser chooser = new JFileChooser(System.getProperty("user.home")); chooser.setApproveButtonText("Wybierz"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); chooser.setDialogTitle("Wybierz ciek"); int returnValue = chooser.showOpenDialog(getContentPane()); if (returnValue == JFileChooser.APPROVE_OPTION) { try { XPackInstaller.launcher_path = chooser.getSelectedFile().getCanonicalPath(); } catch (IOException x) { x.printStackTrace(); } textField1.setText(XPackInstaller.launcher_path); } }); slider1.setMaximum(Utils.Utils.humanReadableRAM() - 2); slider1.addChangeListener(e -> XPackInstaller.allocatedRAM = slider1.getValue()); button1.addActionListener(e -> { if (pobierzOryginalnyLauncherMCCheckBox.isSelected()) { File launcher = new File(XPackInstaller.launcher_path + File.separator + "Minecraft.exe"); if (textField1.getText().equals("")) { JOptionPane.showMessageDialog(panel, "Nie wybrae cieki instalacji Launcher'a!", "Bd", JOptionPane.ERROR_MESSAGE); } else if (launcher.exists()) { JOptionPane.showMessageDialog(panel, "W podanym katalogu istanieje ju plik o nazwie 'Minecraft.exe'!", "Bad", JOptionPane.ERROR_MESSAGE); } else { cardLayout.next(panel); } } else { cardLayout.next(panel); if (osarch.getText().equals("NIE") && Ram.getText().equals("TAK") && javaarch.getText().equals("NIE") && (javaversion.getText().equals("TAK") || javaversion.getText().equals("NIE"))) { XPackInstaller.canGoForward = false; button2.setText("Anuluj"); JOptionPane.showMessageDialog(gui, "Prosimy sprawdzi\u0107 czy na komputerze nie ma zainstalowanych dw\u00f3ch \u015brodowisk Java: w wersji 32-bitowej i 64-bitowej.\nJe\u015bli zainstalowane s\u0105 obie wersje prosimy o odinstalowanie wersji 32-bitowej. To rozwi\u0105\u017ce problem.", "B\u0142\u0105d konfiguracji Javy", JOptionPane.ERROR_MESSAGE); } } }); if (Utils.Validators.systemArchitecture.check()) { osarch.setText("TAK"); osarch.setForeground(Reference.COLOR_DARK_GREEN); } else { osarch.setText("NIE"); osarch.setForeground(Color.RED); } if (Utils.Validators.ramAmount.check()) { Ram.setText("TAK"); Ram.setForeground(Reference.COLOR_DARK_GREEN); } else { Ram.setText("NIE"); Ram.setForeground(Color.RED); } if (Utils.Validators.javaArchitecture.check()) { javaarch.setText("TAK"); javaarch.setForeground(Reference.COLOR_DARK_GREEN); } else { javaarch.setText("NIE"); javaarch.setForeground(Color.RED); } int javaStatus; if (XPackInstaller.javaVersion == 8) { javaStatus = java8Update; } else { javaStatus = java7Update; } if (javaStatus == 0) { javaversion.setText("TAK"); javaversion.setForeground(Reference.COLOR_DARK_GREEN); } else if (javaStatus == 1) { javaversion.setText("NIE"); javaversion.setForeground(Reference.COLOR_DARK_ORANGE); } else if (javaStatus == 2) { javaversion.setText("Nie posiadasz najnowszej wersji JRE!"); javaversion.setForeground(Color.RED); } if (osarch.getText().equals("TAK") && Ram.getText().equals("TAK") && javaarch.getText().equals("TAK") && (javaversion.getText().equals("TAK") || javaversion.getText().equals("NIE"))) { XPackInstaller.canGoForward = true; button2.setText("Dalej"); } else { XPackInstaller.canGoForward = false; button2.setText("Anuluj"); } button2.addActionListener(e -> { if (XPackInstaller.canGoForward) { cardLayout.next(panel); } else { System.exit(1); } }); wsteczButton.addActionListener(e -> cardLayout.previous(panel)); try { editorPane1.setPage("http://xpack.pl/licencja.html"); } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panel, "Brak poczenia z Internetem!", "Bd", JOptionPane.ERROR_MESSAGE); System.exit(0); } licenseC.addActionListener(e -> { if (licenseC.isSelected()) { dalejButton.setEnabled(true); } else { dalejButton.setEnabled(false); } }); try { File mainDir = new File(System.getenv("appdata") + File.separator + "XPackInstaller"); if (mainDir.exists()) { FileUtils.deleteDirectory(mainDir); if (!mainDir.mkdir()) { JOptionPane.showMessageDialog(gui, "Nie udao si utworzy katalogu, prosimy sprbowa ponownie!", "Bd", JOptionPane.ERROR_MESSAGE); System.out.println("Nie udao si utworzy katalogu!"); System.exit(1); } } else { if (!mainDir.mkdir()) { JOptionPane.showMessageDialog(gui, "Nie udao si utworzy katalogu, prosimy sprbowa ponownie!", "Bd", JOptionPane.ERROR_MESSAGE); System.out.println("Nie udao si utworzy katalogu!"); System.exit(1); } } File optionalDir = new File(mainDir.getAbsolutePath() + File.separator + "OptionalMods"); if (!optionalDir.mkdir()) { JOptionPane.showMessageDialog(gui, "Nie udao si utworzy katalogu, prosimy sprbowa ponownie!", "Bd", JOptionPane.ERROR_MESSAGE); System.out.println("Nie udao si utworzy katalogu!"); System.exit(1); } dalejButton.addActionListener(e -> { cardLayout.next(panel); try { progressBar1.setValue(0); if (checkOptifine.isSelected() && zainstalujMoCreaturesCheckBox.isSelected()) { DownloadTask task2 = new DownloadTask(gui, "mod", Reference.downloadOptifine, optionalDir.getAbsolutePath()); task2.addPropertyChangeListener(evt -> { if (evt.getPropertyName().equals("progress")) { labelmodpack.setText("Pobieranie Optifine HD w toku..."); if (task2.isDone()) { task3(); } optifineProgress = (Integer) evt.getNewValue(); progressBar1.setValue(optifineProgress); } }); task2.execute(); } else if (checkOptifine.isSelected()) { DownloadTask task2 = new DownloadTask(gui, "mod", Reference.downloadOptifine, optionalDir.getAbsolutePath()); task2.addPropertyChangeListener(evt -> { if (evt.getPropertyName().equals("progress")) { labelmodpack.setText("Pobieranie Optifine HD w toku..."); if (task2.isDone()) { task(); } optifineProgress = (Integer) evt.getNewValue(); progressBar1.setValue(optifineProgress); } }); task2.execute(); } else if (zainstalujMoCreaturesCheckBox.isSelected()) { task3(); } else { task(); } } catch (Exception exx) { exx.printStackTrace(); } }); } catch (IOException e) { e.printStackTrace(); } final JScrollBar bar = scrollPane1.getVerticalScrollBar(); bar.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { int extent = bar.getModel().getExtent(); int total = extent + bar.getValue(); int max = bar.getMaximum(); if (total == max) { licenseC.setEnabled(true); } } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { int extent = bar.getModel().getExtent(); int total = extent + bar.getValue(); int max = bar.getMaximum(); if (total == max) { licenseC.setEnabled(true); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); bar.addMouseWheelListener(e -> { int extent = bar.getModel().getExtent(); int total = extent + bar.getValue(); int max = bar.getMaximum(); if (total == max) { licenseC.setEnabled(true); } }); scrollPane1.setWheelScrollingEnabled(true); scrollPane1.addMouseWheelListener(e -> { int extent = bar.getModel().getExtent(); int total = extent + bar.getValue(); int max = bar.getMaximum(); if (total == max) { licenseC.setEnabled(true); } }); panel.add(panel3); panel.add(panel1); panel.add(panel2); panel.add(panel4); add(panel); }