List of usage examples for javax.swing JFileChooser setFileFilter
@BeanProperty(preferred = true, description = "Sets the File Filter used to filter out files of type.") public void setFileFilter(FileFilter filter)
From source file:pcd3.View.java
private void pilihGambarSharpMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pilihGambarSharpMouseClicked final String path = "./Citra Images/form.1"; javax.swing.JFileChooser chooser = new javax.swing.JFileChooser(); chooser.setCurrentDirectory(new File(path)); chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { public final static String jpeg = "jpeg"; public final String jpg = "jpg"; public final String gif = "gif"; public final String tiff = "tiff"; public final String tif = "tif"; public final String png = "png"; /*Get the extension of a file.*/ public String getExtension(java.io.File f) { String ext = null;//from w w w . j av a 2s . c o m String s = f.getName(); int i = s.lastIndexOf('.'); if (i > 0 && i < s.length() - 1) { ext = s.substring(i + 1).toLowerCase(); } return ext; } @Override public String getDescription() { return "All Images extensions (jpg, gif, tiff, tif, png)"; } @Override public boolean accept(java.io.File f) { if (f.isDirectory()) { return true; } String extension = getExtension(f); if (extension != null) { return extension.equals(tiff) || extension.equals(tif) || extension.equals(gif) || extension.equals(jpeg) || extension.equals(jpg) || extension.equals(png); } return false; } }); if (chooser.showDialog(this, " Open ") == javax.swing.JFileChooser.APPROVE_OPTION) { java.io.File file = chooser.getSelectedFile(); String filePath = file.toString(); try { final BufferedImage bimg = ImageIO.read(new File(filePath)); namaCitraTelu.setText("Nama Citra : " + file.getName()); Thread t = new Thread() { @Override public void run() { imageFormTelu.setImage(bimg); imageFormTelu.imageToGray(1); citraSharpheningAwal.setText(""); citraSharpheningGray.setText(""); citraSharpheningHasil.setText(""); citraSharpheningAwal.setIcon(new ImageIcon(bimg.getScaledInstance(300, 300, 0))); citraSharpheningGray.setIcon( new ImageIcon(imageFormTelu.getGrayImage().getScaledInstance(300, 300, 0))); ukuranCitraTelu.setText("Ukuran Citra : " + imageFormTelu.getTinggi() + " x " + imageFormTelu.getLebar() + ""); imageFormTelu.setSharpeningImage(); citraSharpheningHasil.setIcon( new ImageIcon(imageFormTelu.getSharpeningImage().getScaledInstance(300, 300, 0))); } }; t.start(); } catch (IOException e) { javax.swing.JOptionPane.showMessageDialog(this, "File Tidak Ditemukan " + e); } } }
From source file:pcd3.View.java
private void pilihGambarLoroMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pilihGambarLoroMouseClicked final String path = "./Citra Images/form.1"; javax.swing.JFileChooser chooser = new javax.swing.JFileChooser(); chooser.setCurrentDirectory(new File(path)); chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { public final static String jpeg = "jpeg"; public final String jpg = "jpg"; public final String gif = "gif"; public final String tiff = "tiff"; public final String tif = "tif"; public final String png = "png"; /*Get the extension of a file.*/ public String getExtension(java.io.File f) { String ext = null;//w w w . j a va 2s.c om String s = f.getName(); int i = s.lastIndexOf('.'); if (i > 0 && i < s.length() - 1) { ext = s.substring(i + 1).toLowerCase(); } return ext; } @Override public String getDescription() { return "All Images extensions (jpg, gif, tiff, tif, png)"; } @Override public boolean accept(java.io.File f) { if (f.isDirectory()) { return true; } String extension = getExtension(f); if (extension != null) { return extension.equals(tiff) || extension.equals(tif) || extension.equals(gif) || extension.equals(jpeg) || extension.equals(jpg) || extension.equals(png); } return false; } }); if (chooser.showDialog(this, " Open ") == javax.swing.JFileChooser.APPROVE_OPTION) { java.io.File file = chooser.getSelectedFile(); String filePath = file.toString(); try { final BufferedImage bimg = ImageIO.read(new File(filePath)); namaCitraLoro.setText("Nama Citra : " + file.getName()); Thread t = new Thread() { @Override public void run() { imageFormLoro.setImage(bimg); imageFormLoro.imageToGray(1); citraSmoothingAwal.setText(""); citraSmoothingGray.setText(""); citraSmoothingHasil.setText(""); citraSmoothingAwal.setIcon(new ImageIcon(bimg.getScaledInstance(300, 300, 0))); citraSmoothingGray.setIcon( new ImageIcon(imageFormLoro.getGrayImage().getScaledInstance(300, 300, 0))); ukuranCitraLoro.setText("Ukuran Citra : " + imageFormLoro.getTinggi() + " x " + imageFormLoro.getLebar() + ""); imageFormLoro.setSmoothingImage(); citraSmoothingHasil.setIcon( new ImageIcon(imageFormLoro.getSmoothingImage().getScaledInstance(300, 300, 0))); } }; t.start(); } catch (IOException e) { javax.swing.JOptionPane.showMessageDialog(this, "File Tidak Ditemukan " + e); } } }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java
private Component createImportButton() { JButton b = new JButton(new AbstractAction(null, UIAgent.getInstance().getIcon(UIAgent.ICON_IMPORT_24)) { private static final long serialVersionUID = 985413615438877711L; @Override// w w w . j av a 2 s .co m public void actionPerformed(ActionEvent e) { JFileChooser ch = new JFileChooser(); ch.setFileFilter(new ExtensionFilter("xls", "Excel File")); int i = ch.showOpenDialog(null); if (i == JFileChooser.APPROVE_OPTION) { DiveProfileExcelParser p = new DiveProfileExcelParser(); try { File f = ch.getSelectedFile(); DiveProfile dp = p.read(f); I18nResourceManager i18n = I18nResourceManager.sharedInstance(); int yes = JOptionPane.showConfirmDialog(DiveProfileGraphicDetailPanel.this, i18n.getString("overwritte.diveprofile.confirm"), i18n.getString("confirmation"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (yes == JOptionPane.YES_OPTION) { currentDive.setDiveProfile(dp); setDiveProfile(dp, currentDive); logBookManagerFacade.setDiveChanged(currentDive); } } catch (IOException e1) { ExceptionDialog.showDialog(e1, DiveProfileGraphicDetailPanel.this); LOGGER.error(e1.getMessage()); } } } }); b.setToolTipText("Import"); return b; }
From source file:edu.gcsc.vrl.jfreechart.JFExport.java
/** * Show dialog for exporting JFreechart object. *//* w ww . j a va 2s . c om*/ public void openExportDialog(JFreeChart jfreechart) { JFileChooser chooser = new JFileChooser(); String path0; File file; chooser.addChoosableFileFilter(new FileNameExtensionFilter("PDF Files", "pdf")); chooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG Files", "jpg")); chooser.addChoosableFileFilter(new FileNameExtensionFilter("PNG Files", "png")); chooser.addChoosableFileFilter(new FileNameExtensionFilter("EPS Files", "eps")); chooser.addChoosableFileFilter(new FileNameExtensionFilter("SVG Files", "svg")); chooser.setFileFilter(new FileNameExtensionFilter("PDF Files", "pdf")); int returnVal = chooser.showSaveDialog(null); String fd = chooser.getFileFilter().getDescription(); // Get selected FileFilter String filter_extension = null; if (fd.equals("PNG Files")) { filter_extension = "png"; } if (fd.equals("SVG Files")) { filter_extension = "svg"; } if (fd.equals("JPEG Files")) { filter_extension = "jpg"; } if (fd.equals("PDF Files")) { filter_extension = "pdf"; } if (fd.equals("EPS Files")) { filter_extension = "eps"; } // Cancel if (returnVal == JFileChooser.CANCEL_OPTION) { return; } // OK if (returnVal == JFileChooser.APPROVE_OPTION) { path0 = chooser.getSelectedFile().getAbsolutePath(); //System.out.println(path0); try { file = new File(path0); // Get extension (if any) String ext = JFUtils.getExtension(file); // No extension -> use selected Filter if (ext == null) { file = new File(path0 + "." + filter_extension); ext = filter_extension; } // File exists - overwrite ? if (file.exists()) { Object[] options = { "OK", "CANCEL" }; int answer = JOptionPane.showOptionDialog(null, "File exists - Overwrite ?", "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); if (answer != JOptionPane.YES_OPTION) { return; } //System.out.println(answer+""); } // Export file export(file, jfreechart); } catch (Exception f) { // I/O - Error } } }
From source file:com.sciaps.view.SpectrometerStackPanel.java
public void getRegionTextFile() { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileFilter(new FileNameExtensionFilter("Text files", "txt", "TXT")); int retval = fileChooser.showOpenDialog(Constants.MAIN_FRAME); if (retval == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); try {/*from w ww. j a va 2s .com*/ FileReader fr = new FileReader(file.getAbsoluteFile()); BufferedReader br = new BufferedReader(fr); StringBuilder text = new StringBuilder(); String line; while ((line = br.readLine()) != null) { text.append(line); } br.close(); createRegionItem(text.toString()); } catch (FileNotFoundException ex) { showErrorDialog(ex.getMessage()); } catch (IOException ex) { showErrorDialog(ex.getMessage()); } } }
From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java
/** * Displays a file chooser when clicking on the "Choose File" button The * chosen file is then used for a new gephi project * * @param evt//from w ww . ja v a2 s. c o m */ private void fileChooserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileChooserButtonActionPerformed FileNameExtensionFilter filter = new FileNameExtensionFilter("Graph Files", "gml"); JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(filter); int result = chooser.showOpenDialog(this); if (chooser.getSelectedFile() != null && result == JFileChooser.APPROVE_OPTION) { fileName = chooser.getSelectedFile().getAbsolutePath(); jTextArea1.setText(fileName); distributionFrame = new JFrame(); try { ProjectController pc = Lookup.getDefault().lookup(ProjectController.class); pc.newProject(); ImportController ic = Lookup.getDefault().lookup(ImportController.class); File file = new File(fileName); Container c = ic.importFile(file); ic.process(c, new DefaultProcessor(), pc.newWorkspace(pc.getCurrentProject())); propertyContentDisplay.setText(""); } catch (Exception exception) { messageFrame = new JFrame(); exception.printStackTrace(); JOptionPane.showMessageDialog(messageFrame, "Error while creating graph (" + exception.getCause() + "), please choose a valid .gml-File", "Signal/Collect Error", JOptionPane.ERROR_MESSAGE); } } }
From source file:keel.GraphInterKeel.datacf.visualizeData.VisualizePanelCharts2D.java
private void topngjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_topngjButtonActionPerformed // Save chart as a PNG image JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Save chart"); KeelFileFilter fileFilter = new KeelFileFilter(); fileFilter.addExtension("png"); fileFilter.setFilterName("PNG images (.png)"); chooser.setFileFilter(fileFilter); chooser.setCurrentDirectory(Path.getFilePath()); int opcion = chooser.showSaveDialog(this); Path.setFilePath(chooser.getCurrentDirectory()); if (opcion == JFileChooser.APPROVE_OPTION) { String nombre = chooser.getSelectedFile().getAbsolutePath(); if (!nombre.toLowerCase().endsWith(".png")) { // Add correct extension nombre += ".png"; }/* w w w. ja v a 2 s . co m*/ File tmp = new File(nombre); if (!tmp.exists() || JOptionPane.showConfirmDialog(this, "File " + nombre + " already exists. Do you want to replace it?", "Confirm", JOptionPane.YES_NO_OPTION, 3) == JOptionPane.YES_OPTION) { try { chart2.setBackgroundPaint(Color.white); ChartUtilities.saveChartAsPNG(new File(nombre), chart2, 1024, 768); } catch (Exception exc) { } } } }
From source file:dotaSoundEditor.Controls.EditorPanel.java
protected File promptUserForNewFile(String wavePath) { JFileChooser chooser = new JFileChooser(new File(UserPrefs.getInstance().getWorkingDirectory())); FileNameExtensionFilter filter = new FileNameExtensionFilter("MP3s and WAVs", "mp3", "wav"); chooser.setAcceptAllFileFilterUsed((false)); chooser.setFileFilter(filter); chooser.setMultiSelectionEnabled(false); int chooserRetVal = chooser.showOpenDialog(chooser); if (chooserRetVal == JFileChooser.APPROVE_OPTION) { DefaultMutableTreeNode selectedFile = (DefaultMutableTreeNode) getTreeNodeFromWavePath(wavePath); Path chosenFile = Paths.get(chooser.getSelectedFile().getAbsolutePath()); //Strip caps and spaces out of filenames. The item sound parser seems to have trouble with them. String destFileName = chosenFile.getFileName().toString().toLowerCase().replace(" ", "_"); Path destPath = Paths.get(installDir, "/dota/sound/" + getCustomSoundPathString() + destFileName); UserPrefs.getInstance().setWorkingDirectory(chosenFile.getParent().toString()); try {/*from w ww . ja va 2s . c om*/ new File(destPath.toString()).mkdirs(); Files.copy(chosenFile, destPath, StandardCopyOption.REPLACE_EXISTING); String waveString = selectedFile.getUserObject().toString(); int startIndex = -1; int endIndex = -1; if (waveString.contains("\"wave\"")) { startIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 2); endIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 3); } else //Some wavestrings don't have the "wave" at the beginning for some reason { startIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 0); endIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 1); } String waveStringFilePath = waveString.substring(startIndex, endIndex + 1); waveString = waveString.replace(waveStringFilePath, "\"" + getCustomSoundPathString() + destFileName + "\""); selectedFile.setUserObject(waveString); //Write out modified tree to scriptfile. ScriptParser parser = new ScriptParser(this.currentTreeModel); String scriptString = getCurrentScriptString(); Path scriptPath = Paths.get(scriptString); parser.writeModelToFile(scriptPath.toString()); //Update UI ((DefaultMutableTreeNode) currentTree.getLastSelectedPathComponent()).setUserObject(waveString); ((DefaultTreeModel) currentTree.getModel()) .nodeChanged((DefaultMutableTreeNode) currentTree.getLastSelectedPathComponent()); JOptionPane.showMessageDialog(this, "Sound file successfully replaced."); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Unable to replace sound.\nDetails: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } return null; }
From source file:keel.GraphInterKeel.datacf.visualizeData.VisualizePanelCharts2D.java
private void topdfjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_topdfjButtonActionPerformed // Save chart as a PDF file JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Save chart"); KeelFileFilter fileFilter = new KeelFileFilter(); fileFilter.addExtension("pdf"); fileFilter.setFilterName("PDF images (.pdf)"); chooser.setFileFilter(fileFilter); chooser.setCurrentDirectory(Path.getFilePath()); int opcion = chooser.showSaveDialog(this); Path.setFilePath(chooser.getCurrentDirectory()); if (opcion == JFileChooser.APPROVE_OPTION) { String nombre = chooser.getSelectedFile().getAbsolutePath(); if (!nombre.toLowerCase().endsWith(".pdf")) { // Add correct extension nombre += ".pdf"; }/*from w ww . j a v a 2 s. c o m*/ File tmp = new File(nombre); if (!tmp.exists() || JOptionPane.showConfirmDialog(this, "File " + nombre + " already exists. Do you want to replace it?", "Confirm", JOptionPane.YES_NO_OPTION, 3) == JOptionPane.YES_OPTION) { try { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(nombre)); document.addAuthor("KEEL"); document.addSubject("Attribute comparison"); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(550, 412); Graphics2D g2 = tp.createGraphics(550, 412, new DefaultFontMapper()); Rectangle2D r2D = new Rectangle2D.Double(0, 0, 550, 412); chart2.setBackgroundPaint(Color.white); chart2.draw(g2, r2D); g2.dispose(); cb.addTemplate(tp, 20, 350); document.close(); } catch (Exception exc) { } } } }
From source file:de.fionera.javamailer.gui.mainView.controllerMain.java
/** * Adds the Actionlisteners to the Mainview * * @param viewMain The Mainview/*from w w w . j a v a 2s . c om*/ */ private void addActionListener(viewMain viewMain) { /** * Changes the Amount in the AmountLabel when the slider is moved */ viewMain.getSetMailSettingsPanel().getSliderAmountMails().addChangeListener(e -> { Main.amountMails = ((JSlider) e.getSource()).getValue(); viewMain.getSetMailSettingsPanel().getLabelNumberAmountMails() .setText("" + ((JSlider) e.getSource()).getValue()); }); /** * Changes the Delay in the DelayLabel when the slider is moved */ viewMain.getSetMailSettingsPanel().getSliderDelayMails().addChangeListener(e -> { Main.delayMails = ((JSlider) e.getSource()).getValue(); viewMain.getSetMailSettingsPanel().getLabelNumberDelayMails() .setText("" + ((JSlider) e.getSource()).getValue()); }); /** * Closes the Program, when close is clicked */ viewMain.getCloseItem().addActionListener(e -> System.exit(0)); /** * Opens the Settings when the settingsbutton is clicked */ viewMain.getSettingsItem().addActionListener(e -> new controllerSettings()); /** * Save current Setup */ viewMain.getSaveSettings().addActionListener(e -> { JFileChooser jChooser = new JFileChooser(); JFrame parentFrame = new JFrame(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Setup file", "jms", "Blub"); jChooser.setFileFilter(filter); jChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); jChooser.setDialogTitle("Select Setup"); int userSelection = jChooser.showSaveDialog(parentFrame); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = new File(jChooser.getSelectedFile() + ".jms"); saveSetup(viewMain, fileToSave, new ObjectMapper()); } }); /** * Load Setup */ viewMain.getLoadSettings().addActionListener(e -> { JFileChooser jChooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Setup file", "jms", "Blub"); jChooser.setFileFilter(filter); jChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); jChooser.setDialogTitle("Select Setup"); jChooser.showOpenDialog(null); File file = jChooser.getSelectedFile(); if (file != null) { if (file.getName().endsWith("jms")) { try { loadSetup(viewMain, file, new ObjectMapper()); } catch (Exception error) { error.printStackTrace(); } } } }); /** * Opens the Open File dialog and start the Parsing of it */ viewMain.getSelectRecipientsPanel().getSelectExcelFileButton().addActionListener(e -> { DefaultTableModel model; JFileChooser jChooser = new JFileChooser(); jChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); jChooser.addChoosableFileFilter(new FileNameExtensionFilter("Microsoft Excel 97 - 2003 (.xls)", "xls")); jChooser.addChoosableFileFilter(new FileNameExtensionFilter("Microsoft Excel (.xlsx)", "xlsx")); jChooser.setDialogTitle("Select only Excel workbooks"); jChooser.showOpenDialog(null); File file = jChooser.getSelectedFile(); if (file != null) { parseFilesForImport parseFilesForImport = new parseFilesForImport(); if (file.getName().endsWith("xls")) { ArrayList returnedData = parseFilesForImport.parseXLSFile(file); model = new DefaultTableModel((String[][]) returnedData.get(0), (String[]) returnedData.get(1)); int tableWidth = model.getColumnCount() * 150; int tableHeight = model.getRowCount() * 25; viewMain.getSelectRecipientsPanel().getTable() .setPreferredSize(new Dimension(tableWidth, tableHeight)); } else if (file.getName().endsWith("xlsx")) { ArrayList returnedData = parseFilesForImport.parseXLSXFile(file); model = new DefaultTableModel((String[][]) returnedData.get(0), (String[]) returnedData.get(1)); int tableWidth = model.getColumnCount() * 150; int tableHeight = model.getRowCount() * 25; viewMain.getSelectRecipientsPanel().getTable() .setPreferredSize(new Dimension(tableWidth, tableHeight)); } else { JOptionPane.showMessageDialog(null, "Please select only Excel file.", "Error", JOptionPane.ERROR_MESSAGE); model = new DefaultTableModel(); } } else { model = new DefaultTableModel(); } viewMain.getSelectRecipientsPanel().getTable().setModel(model); int tableWidth = model.getColumnCount() * 150; int tableHeight = model.getRowCount() * 25; viewMain.getSelectRecipientsPanel().getTable().setPreferredSize(new Dimension(tableWidth, tableHeight)); viewMain.getCheckAllSettings().getLabelRecipientsAmount().setText("" + model.getRowCount()); viewMain.getCheckAllSettings().getLabelTimeAmount() .setText("" + viewMain.getSetMailSettingsPanel().getSliderDelayMails().getValue() * viewMain.getSelectRecipientsPanel().getTable().getRowCount() / viewMain.getSetMailSettingsPanel().getSliderAmountMails().getValue() + " Seconds"); }); /** * Starts the sending of th Mails, when the send button is clicked */ viewMain.getCheckAllSettings().getSendMails().addActionListener(e -> { String subject = viewMain.getSetMailSettingsPanel().getFieldSubject().getText(); Sender sender = (Sender) viewMain.getSetMailSettingsPanel().getSelectSender().getSelectedItem(); JTable table = viewMain.getSelectRecipientsPanel().getTable(); if (table != null && sender != null && !subject.equals("")) { new sendMails(viewMain); } }); /** * Clears the Table on buttonclick */ viewMain.getSelectRecipientsPanel().getClearTableButton().addActionListener(e -> { viewMain.getSelectRecipientsPanel().getTable().setModel(new DefaultTableModel()); viewMain.getSelectRecipientsPanel().getTable().setBackground(null); }); /** * Removes a single Row on menu click in the editMailPanel */ viewMain.getSelectRecipientsPanel().getDeleteRow().addActionListener(e -> { ((DefaultTableModel) viewMain.getSelectRecipientsPanel().getTable().getModel()) .removeRow(viewMain.getSelectRecipientsPanel().getTable().getSelectedRowCount()); viewMain.getSelectRecipientsPanel().getTable().setBackground(null); }); /** * The Changes the displayed Value when the Time in the Timespinner is getting changed. */ viewMain.getSetMailSettingsPanel().getTimeSpinner().addChangeListener(e -> { parseDate.parseDate(viewMain); viewMain.getSetMailSettingsPanel().getLabelSendingIn().setText(parseDate.getDays() + " Days, " + parseDate.getHours() + " hours and " + parseDate.getMinutes() + " minutes remaining"); viewMain.getSetMailSettingsPanel().getLabelSendingAt().setText(parseDate.getDate().toString()); viewMain.getSetMailSettingsPanel().setDate(parseDate.getDate()); }); viewMain.getSetMailSettingsPanel().getDatePicker().addActionListener(e -> { parseDate.parseDate(viewMain); viewMain.getSetMailSettingsPanel().getLabelSendingIn().setText(parseDate.getDays() + " Days, " + parseDate.getHours() + " hours and " + parseDate.getMinutes() + " minutes remaining"); viewMain.getSetMailSettingsPanel().getLabelSendingAt().setText(parseDate.getDate().toString()); viewMain.getSetMailSettingsPanel().setDate(parseDate.getDate()); }); /** * Actionevent for the Edit Sender Button */ viewMain.getSetMailSettingsPanel().getButtonEditSender() .addActionListener(e -> new controllerEditSender(controllerMain)); /** * Actionevent for the Import Button in the EditMail View */ viewMain.getEditMailPanel().getImportWord().addActionListener(e -> { JFileChooser jChooser = new JFileChooser(); jChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); jChooser.addChoosableFileFilter(new FileNameExtensionFilter("Microsoft Word 97 - 2003 (.doc)", "doc")); jChooser.addChoosableFileFilter(new FileNameExtensionFilter("HTML File (.html)", "html")); jChooser.setDialogTitle("Select only Word Documents"); jChooser.showOpenDialog(null); File file = jChooser.getSelectedFile(); if (file != null) { parseFilesForImport parseFilesForImport = new parseFilesForImport(); if (file.getName().endsWith("doc")) { String returnedData = parseFilesForImport.parseDOCFile(file); viewMain.getEditMailPanel().setEditorText(returnedData); } else if (file.getName().endsWith("html")) { String content = ""; try { content = Jsoup.parse(file, "UTF-8").toString(); } catch (IOException e1) { e1.printStackTrace(); } viewMain.getEditMailPanel().setEditorText(content); } else { JOptionPane.showMessageDialog(null, "Please select a Document file.", "Error", JOptionPane.ERROR_MESSAGE); } } }); /** * The Tab Changelistener * The first if Statement sets the Labels on the Checkallsettings Panel to the right Values */ viewMain.getTabbedPane().addChangeListener(e -> { if (viewMain.getTabbedPane().getSelectedComponent() == viewMain.getCheckAllSettings()) { viewMain.getCheckAllSettings().getLabelMailBelow() .setText(viewMain.getEditMailPanel().getEditorText()); //Displays the Mail viewMain.getCheckAllSettings().getLabelRecipientsAmount() .setText("" + viewMain.getSelectRecipientsPanel().getTable().getModel().getRowCount()); //Displays the Amount of Recipients if (viewMain.getSetMailSettingsPanel().getSelectSender().getSelectedItem() != null) { viewMain.getCheckAllSettings().getLabelFromInserted().setText( viewMain.getSetMailSettingsPanel().getSelectSender().getSelectedItem().toString()); } else { viewMain.getCheckAllSettings().getLabelFromInserted().setText("Select a Sender first"); } viewMain.getCheckAllSettings().getLabelSubjectInserted() .setText(viewMain.getSetMailSettingsPanel().getFieldSubject().getText()); //Displays the Subject if (viewMain.getSetMailSettingsPanel().getCheckBoxDelayMails().isSelected()) { viewMain.getCheckAllSettings().getLabelDelay().setVisible(true); viewMain.getCheckAllSettings().getLabelAmount().setVisible(true); viewMain.getCheckAllSettings().getLabelTime().setVisible(true); viewMain.getCheckAllSettings().getLabelDelayNumber().setVisible(true); viewMain.getCheckAllSettings().getLabelAmountNumber().setVisible(true); viewMain.getCheckAllSettings().getLabelTimeAmount().setVisible(true); viewMain.getCheckAllSettings().getLabelDelayNumber() .setText("" + viewMain.getSetMailSettingsPanel().getSliderDelayMails().getValue()); //The Delay Number viewMain.getCheckAllSettings().getLabelAmountNumber() .setText("" + viewMain.getSetMailSettingsPanel().getSliderAmountMails().getValue()); //The Amount of Mail in one package viewMain.getCheckAllSettings().getLabelTimeAmount() .setText("" + viewMain.getSetMailSettingsPanel().getSliderDelayMails().getValue() * viewMain.getSelectRecipientsPanel().getTable().getRowCount() / viewMain.getSetMailSettingsPanel().getSliderAmountMails().getValue() + " Seconds"); //The Time the Sending needs } else { viewMain.getCheckAllSettings().getLabelDelay().setVisible(false); viewMain.getCheckAllSettings().getLabelAmount().setVisible(false); viewMain.getCheckAllSettings().getLabelTime().setVisible(false); viewMain.getCheckAllSettings().getLabelDelayNumber().setVisible(false); viewMain.getCheckAllSettings().getLabelAmountNumber().setVisible(false); viewMain.getCheckAllSettings().getLabelTimeAmount().setVisible(false); } if (viewMain.getSetMailSettingsPanel().getCheckBoxSendLater().isSelected()) { viewMain.getCheckAllSettings().getLabelSendingAt().setVisible(true); viewMain.getCheckAllSettings().getLabelSendingWhen().setVisible(true); viewMain.getCheckAllSettings().getLabelSendingAt() .setText(viewMain.getSetMailSettingsPanel().getDate().toString()); } else { viewMain.getCheckAllSettings().getLabelSendingAt().setVisible(false); viewMain.getCheckAllSettings().getLabelSendingWhen().setVisible(false); } } }); }