List of usage examples for javax.swing JFileChooser showOpenDialog
public int showOpenDialog(Component parent) throws HeadlessException
From source file:de.codesourcery.jasm16.ide.ui.views.WorkspaceExplorer.java
protected JPopupMenu createPopupMenu(final WorkspaceTreeNode selectedNode) { final JPopupMenu popup = new JPopupMenu(); int openProjects = 0; int closedProjects = 0; for (IAssemblyProject p : workspace.getAllProjects()) { if (p.isOpen()) { openProjects++;// w w w .ja v a 2s . c o m } else { closedProjects++; } } // open debugger final IAssemblyProject project = getProject(selectedNode); if (project != null) { if (project.isOpen()) { addMenuEntry(popup, "Close project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { workspace.closeProject(project); } }); } else { addMenuEntry(popup, "Open project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { workspace.openProject(project); } }); } addMenuEntry(popup, "Build project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { project.getProjectBuilder().build(); } catch (Exception ex) { LOG.error("Failed to build " + project, ex); UIUtils.showErrorDialog(null, "Building project '" + project.getName() + "' failed", "Building the project failed: " + ex.getMessage(), ex); } } }); if (project.getProjectBuilder() == null) { throw new RuntimeException("Internal error, project " + project.getName() + " has no builder ??"); } final IResource executable = project.getProjectBuilder().getExecutable(); if (executable != null) { addMenuEntry(popup, "Open in debugger", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { openDebugPerspective(project, executable, perspectivesManager); } catch (IOException e1) { LOG.error( "Failed to open debug perspective for " + project + " , resource " + executable, e1); } } }); } } if (canCreateFileIn(selectedNode)) { addMenuEntry(popup, "New source file...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { createNewSourceFile(selectedNode); } catch (IOException e1) { LOG.error("actionPerformed(): ", e1); } } }); } addMenuEntry(popup, "New project...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { createNewProject(); } catch (Exception e1) { LOG.error("actionPerformed(): ", e1); UIUtils.showErrorDialog(panel, "Failed to create project", "Project creation failed: " + e1.getMessage()); } } }); if (selectedNode != null) { addMenuEntry(popup, "Delete...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteResource(selectedNode); } }); } addMenuEntry(popup, "Refresh", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshWorkspace(project); } }); addMenuEntry(popup, "Import existing project...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser fc = new JFileChooser(workspace.getBaseDirectory()); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); final int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { final File directory = fc.getSelectedFile(); try { workspace.importProject(directory); } catch (Exception e1) { UIUtils.showErrorDialog(null, "Failed to import project", "Error while importing project: " + e1.getMessage()); } } } }); if (project != null) { addMenuEntry(popup, "Project properties...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProjectConfigurationView view = (ProjectConfigurationView) getViewContainer() .getViewByID(ProjectConfigurationView.ID); if (view == null) { view = new ProjectConfigurationView() { @Override protected void onSave() { apply(project.getConfiguration()); try { project.getConfiguration().save(); } catch (IOException e) { UIUtils.showErrorDialog(null, "Error", "Failed to save project options", e); } finally { getViewContainer().disposeView(this); } } @Override protected void onCancel() { getViewContainer().disposeView(this); } }; getViewContainer().addView(view); } view.setProject(project); view.getViewContainer().toFront(view); } }); } if (closedProjects > 0) { addMenuEntry(popup, "Open ALL projects", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openAllProjects(); } }); } if (openProjects > 0) { addMenuEntry(popup, "Close ALL projects", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeAllProjects(); } }); } return popup; }
From source file:com.nbt.TreeFrame.java
private void createActions() { newAction = new NBTAction("New", "New", "New", KeyEvent.VK_N) { {/*from w w w.j av a2 s . c o m*/ putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { updateTreeTable(new CompoundTag("")); } }; browseAction = new NBTAction("Browse...", "Open", "Browse...", KeyEvent.VK_O) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('O', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showOpenDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doImport(file); break; } } }; saveAction = new NBTAction("Save", "Save", "Save", KeyEvent.VK_S) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canWrite()) { doExport(file); } else { saveAsAction.actionPerformed(e); } } }; saveAsAction = new NBTAction("Save As...", "SaveAs", "Save As...", KeyEvent.VK_UNDEFINED) { public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showSaveDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doExport(file); break; } } }; refreshAction = new NBTAction("Refresh", "Refresh", "Refresh", KeyEvent.VK_F5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F5")); } public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canRead()) doImport(file); else showErrorDialog("The file could not be read."); } }; exitAction = new NBTAction("Exit", "Exit", KeyEvent.VK_ESCAPE) { @Override public void actionPerformed(ActionEvent e) { // TODO: this should check to see if any changes have been made // before exiting System.exit(0); } }; cutAction = new DefaultEditorKit.CutAction() { { String name = "Cut"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_X); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('X', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; copyAction = new DefaultEditorKit.CopyAction() { { String name = "Copy"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_C); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('C', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; pasteAction = new DefaultEditorKit.CutAction() { { String name = "Paste"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_V); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('V', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; deleteAction = new NBTAction("Delete", "Delete", "Delete", KeyEvent.VK_DELETE) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE")); } public void actionPerformed(ActionEvent e) { int row = treeTable.getSelectedRow(); TreePath path = treeTable.getPathForRow(row); Object last = path.getLastPathComponent(); if (last instanceof NBTFileBranch) { NBTFileBranch branch = (NBTFileBranch) last; File file = branch.getFile(); String name = file.getName(); String message = "Are you sure you want to delete " + name + "?"; String title = "Continue?"; int option = JOptionPane.showConfirmDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION); switch (option) { case JOptionPane.CANCEL_OPTION: return; } if (!FileUtils.deleteQuietly(file)) { showErrorDialog(name + " could not be deleted."); return; } } TreePath parentPath = path.getParentPath(); Object parentLast = parentPath.getLastPathComponent(); NBTTreeTableModel model = treeTable.getTreeTableModel(); int index = model.getIndexOfChild(parentLast, last); if (parentLast instanceof Mutable<?>) { Mutable<?> mutable = (Mutable<?>) parentLast; if (last instanceof ByteWrapper) { ByteWrapper wrapper = (ByteWrapper) last; index = wrapper.getIndex(); } mutable.remove(index); } else { System.err.println(last.getClass()); return; } updateTreeTable(); treeTable.expandPath(parentPath); scrollTo(parentLast); treeTable.setRowSelectionInterval(row, row); } }; openAction = new NBTAction("Open...", "Open...", KeyEvent.VK_T) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('T', Event.CTRL_MASK)); final int diamondPickaxe = 278; SpriteRecord record = NBTTreeTable.register.getRecord(diamondPickaxe); BufferedImage image = record.getImage(); setSmallIcon(image); int width = 24, height = 24; Dimension size = new Dimension(width, height); Map<RenderingHints.Key, ?> hints = Thumbnail.createRenderingHints(Thumbnail.QUALITY); BufferedImage largeImage = Thumbnail.createThumbnail(image, size, hints); setLargeIcon(largeImage); } public void actionPerformed(ActionEvent e) { TreePath path = treeTable.getPath(); if (path == null) return; Object last = path.getLastPathComponent(); if (last instanceof Region) { Region region = (Region) last; createAndShowTileCanvas(new TileCanvas.TileWorld(region)); return; } else if (last instanceof World) { World world = (World) last; createAndShowTileCanvas(world); return; } if (last instanceof NBTFileBranch) { NBTFileBranch fileBranch = (NBTFileBranch) last; File file = fileBranch.getFile(); try { open(file); } catch (IOException ex) { ex.printStackTrace(); showErrorDialog(ex.getMessage()); } } } private void open(File file) throws IOException { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(file); } } } }; addByteAction = new NBTAction("Add Byte", NBTConstants.TYPE_BYTE, "Add Byte", KeyEvent.VK_1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('1', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteTag("new byte", (byte) 0)); } }; addShortAction = new NBTAction("Add Short", NBTConstants.TYPE_SHORT, "Add Short", KeyEvent.VK_2) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('2', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ShortTag("new short", (short) 0)); } }; addIntAction = new NBTAction("Add Integer", NBTConstants.TYPE_INT, "Add Integer", KeyEvent.VK_3) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('3', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new IntTag("new int", 0)); } }; addLongAction = new NBTAction("Add Long", NBTConstants.TYPE_LONG, "Add Long", KeyEvent.VK_4) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('4', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new LongTag("new long", 0)); } }; addFloatAction = new NBTAction("Add Float", NBTConstants.TYPE_FLOAT, "Add Float", KeyEvent.VK_5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('5', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new FloatTag("new float", 0)); } }; addDoubleAction = new NBTAction("Add Double", NBTConstants.TYPE_DOUBLE, "Add Double", KeyEvent.VK_6) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('6', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new DoubleTag("new double", 0)); } }; addByteArrayAction = new NBTAction("Add Byte Array", NBTConstants.TYPE_BYTE_ARRAY, "Add Byte Array", KeyEvent.VK_7) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('7', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteArrayTag("new byte array")); } }; addStringAction = new NBTAction("Add String", NBTConstants.TYPE_STRING, "Add String", KeyEvent.VK_8) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('8', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new StringTag("new string", "...")); } }; addListAction = new NBTAction("Add List Tag", NBTConstants.TYPE_LIST, "Add List Tag", KeyEvent.VK_9) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('9', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { Class<? extends Tag> type = queryType(); if (type != null) addTag(new ListTag("new list", null, type)); } private Class<? extends Tag> queryType() { Object[] items = { NBTConstants.TYPE_BYTE, NBTConstants.TYPE_SHORT, NBTConstants.TYPE_INT, NBTConstants.TYPE_LONG, NBTConstants.TYPE_FLOAT, NBTConstants.TYPE_DOUBLE, NBTConstants.TYPE_BYTE_ARRAY, NBTConstants.TYPE_STRING, NBTConstants.TYPE_LIST, NBTConstants.TYPE_COMPOUND }; JComboBox comboBox = new JComboBox(new DefaultComboBoxModel(items)); comboBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Integer) { Integer i = (Integer) value; Class<? extends Tag> c = NBTUtils.getTypeClass(i); String name = NBTUtils.getTypeName(c); setText(name); } return this; } }); Object[] message = { new JLabel("Please select a type."), comboBox }; String title = "Title goes here"; int result = JOptionPane.showOptionDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); switch (result) { case JOptionPane.OK_OPTION: ComboBoxModel model = comboBox.getModel(); Object item = model.getSelectedItem(); if (item instanceof Integer) { Integer i = (Integer) item; return NBTUtils.getTypeClass(i); } } return null; } }; addCompoundAction = new NBTAction("Add Compound Tag", NBTConstants.TYPE_COMPOUND, "Add Compound Tag", KeyEvent.VK_0) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('0', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new CompoundTag()); } }; String name = "About " + TITLE; helpAction = new NBTAction(name, "Help", name, KeyEvent.VK_F1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F1")); } public void actionPerformed(ActionEvent e) { Object[] message = { new JLabel(TITLE + " " + VERSION), new JLabel("\u00A9 Copyright Taggart Spilman 2011. All rights reserved."), new Hyperlink("<html><a href=\"#\">NamedBinaryTag.com</a></html>", "http://www.namedbinarytag.com"), new Hyperlink("<html><a href=\"#\">Contact</a></html>", "mailto:tagadvance@gmail.com"), new JLabel(" "), new Hyperlink("<html><a href=\"#\">JNBT was written by Graham Edgecombe</a></html>", "http://jnbt.sf.net"), new Hyperlink("<html><a href=\"#\">Available open-source under the BSD license</a></html>", "http://jnbt.sourceforge.net/LICENSE.TXT"), new JLabel(" "), new JLabel("This product includes software developed by"), new Hyperlink("<html><a href=\"#\">The Apache Software Foundation</a>.</html>", "http://www.apache.org"), new JLabel(" "), new JLabel("Default texture pack:"), new Hyperlink("<html><a href=\"#\">SOLID COLOUR. SOLID STYLE.</a></html>", "http://www.minecraftforum.net/topic/72253-solid-colour-solid-style/"), new JLabel("Bundled with the permission of Trigger_Proximity."), }; String title = "About"; JOptionPane.showMessageDialog(TreeFrame.this, message, title, JOptionPane.INFORMATION_MESSAGE); } }; }
From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java
public void actionPerformed(ActionEvent arg0) { JMenuItem source = (JMenuItem) (arg0.getSource()); if (source.getText().equals(MENU_ABOUT)) { JOptionPane.showMessageDialog(this, WDBearManager.VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "\n" + "Supports any WDB version\n" + "\n" + "Thanks to:\n" + "DarkMan for testing,\n" + "John for the 1.10 specs, Annunaki for helping with the header,\n" + "Andrikos for the 1.6.x WDB specs, Pyro's WDBViewer, WDDG Forum,\n" + "blizzhackers, etc etc\n\n" + "This program uses: \n" + "JGoodies from http://www.jgoodies.com/\n" + "Hypersonic SQL database 1.7.3\n" + "Apache Log4J, Xerces\n" + "Jakarta Commons Logging and CLI\n" + "Castor from ExoLab\n" + "MySQL JDBC connector 3.1.7\n" + "HTTPUNIT from Russell Gold\n" + "Jython 2.1\n" + "Refer to directory 'licenses' for more details about the software used\n" + "PLEASE:\n" + "If you like this program and find it usefull:\n" + "Please donate money to a charity oranization of your choice.\n" + "I recommend any organization that fights cancer.\n\n" + "License:\n" + "WDBearMgr is placed under the GNU GPL. \n" + "For further information, see the page :\n" + "http://www.gnu.org/copyleft/gpl.html.\n" + "See licenses/GPL_license.html\n" + "\n" + "For a different license please contact the author.", "Info " + VERSION_INFO, JOptionPane.INFORMATION_MESSAGE); return;/* w ww.j av a 2 s.c o m*/ } else if (source.getText().equals(MENU_HELP)) { JFrame myFrame = new JFrame("doc/html/index.html"); //myFrame.setFont( ); URL urlHTML = null; try { JEditorPane htmlPane = new JEditorPane(); //htmlPane.setFont(sourceFont); // .out.println("/scripts/"+source.getName()+".py"); File scriptFile = new File("doc/html/index.html"); urlHTML = scriptFile.toURL();//this.getClass().getResource("/scripts/"+source.getName()+".py"); // .out.println( urlHTML ); // .out.println( urlHTML.toExternalForm() ); htmlPane.setPage(urlHTML); htmlPane.setEditable(false); JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane); htmlPane.addHyperlinkListener(myJEPHL); myFrame.getContentPane().add(new JScrollPane(htmlPane)); myFrame.pack(); myFrame.setSize(640, 480); myFrame.show(); } catch (Exception ex) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not open 'doc/html/index.html'", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); } } else if (source.getText().equals(MENU_JDOCS)) { JFrame myFrame = new JFrame("doc/javadoc/index.html"); //myFrame.setFont( ); URL urlHTML = null; try { JEditorPane htmlPane = new JEditorPane(); //htmlPane.setFont(sourceFont); // .out.println("/scripts/"+source.getName()+".py"); File scriptFile = new File("doc/javadoc/index.html"); urlHTML = scriptFile.toURL(); htmlPane.setPage(urlHTML); htmlPane.setEditable(false); JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane); htmlPane.addHyperlinkListener(myJEPHL); myFrame.getContentPane().add(new JScrollPane(htmlPane)); myFrame.pack(); myFrame.setSize(640, 480); myFrame.show(); } catch (Exception ex) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not open 'doc/javadoc/index.html'", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); } } else if (source.getText().equals(MENU_CHECKUPDATE)) { Properties dbProps = null; String filName = PROPS_CHECK_UPDATE; try { dbProps = ReadPropertiesFile.readProperties(filName); String updFile = dbProps.getProperty(KEY_UPD_FILE); if (updFile == null) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not find update information", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); return; } String updSite = dbProps.getProperty(KEY_WDBMGR_SITE); if (updFile == null) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "Could not find SITE information", "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE); return; } URL urlUpdScript = new URL(updFile); BufferedReader in = new BufferedReader(new InputStreamReader(urlUpdScript.openStream())); String versionTXT = in.readLine(); String downloadName = in.readLine(); in.close(); if (versionTXT.equals(WDBearManager.VERSION_INFO)) { JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n" + "You are using the latest version, no updates available", "Info " + VERSION_INFO, JOptionPane.INFORMATION_MESSAGE); return; } else { // Read version.txt String versionInfo = (String) dbProps.getProperty(KEY_VERSION_INFO); URL urlversionInfo = new URL(versionInfo); BufferedReader brVInfo = new BufferedReader(new InputStreamReader(urlversionInfo.openStream())); StringBuffer sbuVInfo = new StringBuffer(); String strLine = ""; boolean foundStart = false; while ((strLine = brVInfo.readLine()) != null) { if (strLine.startsWith("---")) { break; } if (foundStart == true) { sbuVInfo.append(strLine); sbuVInfo.append("\n"); continue; } if (strLine.startsWith(versionTXT)) { foundStart = true; continue; } } brVInfo.close(); int n = JOptionPane.showConfirmDialog(this, "New version available - Please visit " + updSite + "\n\n" + versionTXT + "\n" + "\n" + "You are using version:\n" + WDBearManager.VERSION_INFO + "\n" + "\n" + "Do you want to download this version?\n\n" + "Version information:\n" + sbuVInfo.toString(), VERSION_INFO + "by kizura", JOptionPane.YES_NO_OPTION); // JOptionPane.showMessageDialog(this, VERSION_INFO + "\n" // + "by kizura\n" + WDBManager.EMAIL + "\n\n" // + "New version available - Please visit " + updSite, // "Warning " // + VERSION_INFO, JOptionPane.WARNING_MESSAGE); if (n == 0) { JFileChooser chooser = new JFileChooser(new File(".")); chooser.setDialogTitle("Please select download location"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try { URL urlUpd = new URL(downloadName); BufferedInputStream bin = new BufferedInputStream(urlUpd.openStream()); System.out.println( new File(chooser.getSelectedFile(), urlUpd.getFile()).getAbsolutePath()); File thisFile = new File(chooser.getSelectedFile(), urlUpd.getFile()); BufferedOutputStream bout = new BufferedOutputStream( new FileOutputStream(thisFile)); byte[] bufFile = new byte[102400]; int bytesRead = 0; while ((bytesRead = bin.read(bufFile)) != -1) { bout.write(bufFile, 0, bytesRead); } bin.close(); bout.close(); JOptionPane.showMessageDialog(this, "Update downloaded successfully" + "\n" + "Please check '" + thisFile.getAbsolutePath() + "'", "Success " + WDBearManager.VERSION_INFO, JOptionPane.INFORMATION_MESSAGE); //String msg = WriteCSV.writeCSV(chooser.getSelectedFile(), this.items); } catch (Exception ex) { String msg = ex.getMessage(); JOptionPane.showMessageDialog(this, msg + "\n" + "Error downloading update", "Error " + WDBearManager.VERSION_INFO, JOptionPane.ERROR_MESSAGE); } } } // user selected "download" return; } } catch (Exception ex) { ex.printStackTrace(); } } else { System.exit(0); } }
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Show open file dialog so the user may choose a file to edit. * /* ww w . j a va 2 s . c o m*/ * @return the chosen file if okay was pressed, null if cancel was pressed */ private File loadFromOpenFileDialog() { String lastVisitedFolder = App.prefs.getPref(PrefKey.PREF_LAST_READ_FOLDER, null); JFileChooser fc; if (lastVisitedFolder != null) fc = new JFileChooser(lastVisitedFolder); else fc = new JFileChooser(); fc.setDialogTitle("Select a FHX2 file for sample size analysis"); fc.setFileFilter(new FHXFileFilter()); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(true); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { App.prefs.setPref(PrefKey.PREF_LAST_READ_FOLDER, fc.getSelectedFile().getPath()); return fc.getSelectedFile(); } return null; }
From source file:cis_690_report.DynamicReporter.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed JFileChooser chooser = new JFileChooser(); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { File3 = chooser.getSelectedFile().getAbsolutePath(); }// w w w.j a v a2 s.c om try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); Font bfBold25 = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(File3)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold25); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); DynamicReporter re; re = new DynamicReporter(); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; for (int i = 0; i < dlm2.getSize(); i++) for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } } // TODO add your handling code here: }
From source file:forge.gui.ImportDialog.java
@SuppressWarnings("serial") public ImportDialog(final String forcedSrcDir, final Runnable onDialogClose) { this.forcedSrcDir = forcedSrcDir; _topPanel = new FPanel(new MigLayout("insets dialog, gap 0, center, wrap, fill")); _topPanel.setOpaque(false);//from w ww. java 2 s.c o m _topPanel.setBackgroundTexture(FSkin.getIcon(FSkinProp.BG_TEXTURE)); isMigration = !StringUtils.isEmpty(forcedSrcDir); // header _topPanel.add(new FLabel.Builder().text((isMigration ? "Migrate" : "Import") + " profile data").fontSize(15) .build(), "center"); // add some help text if this is for the initial data migration if (isMigration) { final FPanel blurbPanel = new FPanel(new MigLayout("insets panel, gap 10, fill")); blurbPanel.setOpaque(false); final JPanel blurbPanelInterior = new JPanel( new MigLayout("insets dialog, gap 10, center, wrap, fill")); blurbPanelInterior.setOpaque(false); blurbPanelInterior.add(new FLabel.Builder().text("<html><b>What's this?</b></html>").build(), "growx, w 50:50:"); blurbPanelInterior.add(new FLabel.Builder() .text("<html>Over the last several years, people have had to jump through a lot of hoops to" + " update to the most recent version. We hope to reduce this workload to a point where a new" + " user will find that it is fairly painless to update. In order to make this happen, Forge" + " has changed where it stores your data so that it is outside of the program installation directory." + " This way, when you upgrade, you will no longer need to import your data every time to get things" + " working. There are other benefits to having user data separate from program data, too, and it" + " lays the groundwork for some cool new features.</html>") .build(), "growx, w 50:50:"); blurbPanelInterior.add( new FLabel.Builder().text("<html><b>So where's my data going?</b></html>").build(), "growx, w 50:50:"); blurbPanelInterior.add(new FLabel.Builder().text( "<html>Forge will now store your data in the same place as other applications on your system." + " Specifically, your personal data, like decks, quest progress, and program preferences will be" + " stored in <b>" + ForgeConstants.USER_DIR + "</b> and all downloaded content, such as card pictures," + " skins, and quest world prices will be under <b>" + ForgeConstants.CACHE_DIR + "</b>. If, for whatever" + " reason, you need to set different paths, cancel out of this dialog, exit Forge, and find the <b>" + ForgeConstants.PROFILE_TEMPLATE_FILE + "</b> file in the program installation directory. Copy or rename" + " it to <b>" + ForgeConstants.PROFILE_FILE + "</b> and edit the paths inside it. Then restart Forge and use" + " this dialog to move your data to the paths that you set. Keep in mind that if you install a future" + " version of Forge into a different directory, you'll need to copy this file over so Forge will know" + " where to find your data.</html>") .build(), "growx, w 50:50:"); blurbPanelInterior.add(new FLabel.Builder().text( "<html><b>Remember, your data won't be available until you complete this step!</b></html>") .build(), "growx, w 50:50:"); final FScrollPane blurbScroller = new FScrollPane(blurbPanelInterior, true, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); blurbPanel.add(blurbScroller, "hmin 150, growy, growx, center, gap 0 0 5 5"); _topPanel.add(blurbPanel, "gap 10 10 20 0, growy, growx, w 50:50:"); } // import source widgets final JPanel importSourcePanel = new JPanel(new MigLayout("insets 0, gap 10")); importSourcePanel.setOpaque(false); importSourcePanel.add(new FLabel.Builder().text("Import from:").build()); _txfSrc = new FTextField.Builder().readonly().build(); importSourcePanel.add(_txfSrc, "pushx, growx"); _btnChooseDir = new FLabel.ButtonBuilder().text("Choose directory...").enabled(!isMigration).build(); final JFileChooser _fileChooser = new JFileChooser(); _fileChooser.setMultiSelectionEnabled(false); _fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); _btnChooseDir.setCommand(new UiCommand() { @Override public void run() { // bring up a file open dialog and, if the OK button is selected, apply the filename // to the import source text field if (JFileChooser.APPROVE_OPTION == _fileChooser.showOpenDialog(JOptionPane.getRootFrame())) { final File f = _fileChooser.getSelectedFile(); if (!f.canRead()) { FOptionPane.showErrorDialog("Cannot access selected directory (Permission denied)."); } else { _txfSrc.setText(f.getAbsolutePath()); } } } }); importSourcePanel.add(_btnChooseDir, "h pref+8!, w pref+12!"); // add change handler to the import source text field that starts up a // new analyzer. it also interacts with the current active analyzer, // if any, to make sure it cancels out before the new one is initiated _txfSrc.getDocument().addDocumentListener(new DocumentListener() { boolean _analyzerActive; // access synchronized on _onAnalyzerDone String prevText; private final Runnable _onAnalyzerDone = new Runnable() { @Override public synchronized void run() { _analyzerActive = false; notify(); } }; @Override public void removeUpdate(final DocumentEvent e) { } @Override public void changedUpdate(final DocumentEvent e) { } @Override public void insertUpdate(final DocumentEvent e) { // text field is read-only, so the only time this will get updated // is when _btnChooseDir does it final String text = _txfSrc.getText(); if (text.equals(prevText)) { // only restart the analyzer if the directory has changed return; } prevText = text; // cancel any active analyzer _cancel = true; if (!text.isEmpty()) { // ensure we don't get two instances of this function running at the same time _btnChooseDir.setEnabled(false); // re-disable the start button. it will be enabled if the previous analyzer has // already successfully finished _btnStart.setEnabled(false); // we have to wait in a background thread since we can't block in the GUI thread final SwingWorker<Void, Void> analyzerStarter = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { // wait for active analyzer (if any) to quit synchronized (_onAnalyzerDone) { while (_analyzerActive) { _onAnalyzerDone.wait(); } } return null; } // executes in gui event loop thread @Override protected void done() { _cancel = false; synchronized (_onAnalyzerDone) { // this will populate the panel with data selection widgets final _AnalyzerUpdater analyzer = new _AnalyzerUpdater(text, _onAnalyzerDone, isMigration); analyzer.run(); _analyzerActive = true; } if (!isMigration) { // only enable the directory choosing button if this is not a migration dialog // since in that case we're permanently locked to the starting directory _btnChooseDir.setEnabled(true); } } }; analyzerStarter.execute(); } } }); _topPanel.add(importSourcePanel, "gaptop 20, pushx, growx"); // prepare import selection panel (will be cleared and filled in later by an analyzer) _selectionPanel = new JPanel(); _selectionPanel.setOpaque(false); _topPanel.add(_selectionPanel, "growx, growy, gaptop 10"); // action button widgets final Runnable cleanup = new Runnable() { @Override public void run() { SOverlayUtils.hideOverlay(); } }; _btnStart = new FButton("Start import"); _btnStart.setEnabled(false); _btnCancel = new FButton("Cancel"); _btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { _cancel = true; cleanup.run(); if (null != onDialogClose) { onDialogClose.run(); } } }); final JPanel southPanel = new JPanel(new MigLayout("ax center")); southPanel.setOpaque(false); southPanel.add(_btnStart, "center, w pref+144!, h pref+12!"); southPanel.add(_btnCancel, "center, w pref+144!, h pref+12!, gap 72"); _topPanel.add(southPanel, "growx"); }
From source file:it.isislab.dmason.tools.batch.BatchWizard.java
public File showFileChooser() { JFileChooser fileChooser = new JFileChooser(); // fileChooser.setCurrentDirectory(new File(FTP_HOME)); int n = fileChooser.showOpenDialog(BatchWizard.this); if (n == JFileChooser.APPROVE_OPTION) { return fileChooser.getSelectedFile(); } else/* w ww . j av a 2 s . c o m*/ return null; }
From source file:cl.uai.webcursos.emarking.desktop.OptionsDialog.java
/** * Create the dialog./*ww w . j a va2 s . co m*/ */ public OptionsDialog(Moodle _moodle) { addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { cancelled = true; } }); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setIconImage(Toolkit.getDefaultToolkit().getImage(OptionsDialog.class .getResource("/cl/uai/webcursos/emarking/desktop/resources/glyphicons_439_wrench.png"))); setTitle(EmarkingDesktop.lang.getString("emarkingoptions")); setModal(true); setBounds(100, 100, 707, 444); this.moodle = _moodle; this.moodle.loadProperties(); getContentPane().setLayout(new BorderLayout()); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { okButton = new JButton(EmarkingDesktop.lang.getString("ok")); okButton.setEnabled(false); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); if (!validator.isValid(moodleurl.getText())) { throw new Exception(EmarkingDesktop.lang.getString("invalidmoodleurl") + " " + moodleurl.getText()); } File f = new File(filename.getText()); if (!f.exists() || f.isDirectory() || (!f.getPath().endsWith(".pdf") && !f.getPath().endsWith(".zip"))) { throw new Exception(EmarkingDesktop.lang.getString("invalidpdffile") + " " + filename.getText()); } if (omrtemplate.getText().trim().length() > 0) { File omrf = new File(omrtemplate.getText()); if (!omrf.exists() || omrf.isDirectory() || (!omrf.getPath().endsWith(".xtmpl"))) { throw new Exception(EmarkingDesktop.lang.getString("invalidomrfile") + " " + omrtemplate.getText()); } } moodle.setLastfile(filename.getText()); moodle.getQrExtractor().setDoubleside(chckbxDoubleSide.isSelected()); moodle.setMaxthreads(Integer.parseInt(getMaxThreads().getSelectedItem().toString())); moodle.setResolution(Integer.parseInt(getResolution().getSelectedItem().toString())); moodle.setMaxzipsize(getMaxZipSize().getSelectedItem().toString()); moodle.setOMRTemplate(omrtemplate.getText()); moodle.setThreshold(Integer.parseInt(spinnerOMRthreshold.getValue().toString())); moodle.setDensity(Integer.parseInt(spinnerOMRdensity.getValue().toString())); moodle.setShapeSize(Integer.parseInt(spinnerOMRshapeSize.getValue().toString())); moodle.setAnonymousPercentage( Integer.parseInt(spinnerAnonymousPercentage.getValue().toString())); moodle.setAnonymousPercentageCustomPage( Integer.parseInt(spinnerAnonymousPercentageCustomPage.getValue().toString())); moodle.setFakeStudents(chckbxMarkersTraining.isSelected()); moodle.saveProperties(); cancelled = false; setVisible(false); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(panel, EmarkingDesktop.lang.getString("invaliddatainform")); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton(EmarkingDesktop.lang.getString("cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelled = true; setVisible(false); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); panel = new JPanel(); tabbedPane.addTab(EmarkingDesktop.lang.getString("general"), null, panel, null); panel.setLayout(null); JPanel panel_2 = new JPanel(); panel_2.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_2.setBounds(10, 11, 665, 131); panel.add(panel_2); panel_2.setLayout(null); JLabel lblPassword = new JLabel(EmarkingDesktop.lang.getString("password")); lblPassword.setBounds(10, 99, 109, 14); panel_2.add(lblPassword); lblPassword.setHorizontalAlignment(SwingConstants.RIGHT); password = new JPasswordField(); password.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(); } }); password.setBounds(129, 96, 329, 20); panel_2.add(password); this.password.setText(this.moodle.getPassword()); btnTestConnection = new JButton(EmarkingDesktop.lang.getString("connect")); btnTestConnection.setEnabled(false); btnTestConnection.setBounds(468, 93, 172, 27); panel_2.add(btnTestConnection); username = new JTextField(); username.setBounds(129, 65, 329, 20); panel_2.add(username); username.setColumns(10); this.username.setText(this.moodle.getUsername()); moodleurl = new JTextField(); moodleurl.setBounds(129, 34, 329, 20); panel_2.add(moodleurl); moodleurl.setColumns(10); moodleurl.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { warn(); } @Override public void insertUpdate(DocumentEvent e) { warn(); } @Override public void changedUpdate(DocumentEvent e) { warn(); } private void warn() { UrlValidator validator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); if (!validator.isValid(moodleurl.getText()) || !moodleurl.getText().endsWith("/")) { moodleurl.setForeground(Color.RED); btnTestConnection.setEnabled(false); } else { moodleurl.setForeground(Color.BLACK); btnTestConnection.setEnabled(true); } } }); // Initializing values from moodle configuration this.moodleurl.setText(this.moodle.getUrl()); JLabel lblMoodleUrl = new JLabel(EmarkingDesktop.lang.getString("moodleurl")); lblMoodleUrl.setBounds(10, 37, 109, 14); panel_2.add(lblMoodleUrl); lblMoodleUrl.setHorizontalAlignment(SwingConstants.RIGHT); JLabel lblUsername = new JLabel(EmarkingDesktop.lang.getString("username")); lblUsername.setBounds(10, 68, 109, 14); panel_2.add(lblUsername); lblUsername.setHorizontalAlignment(SwingConstants.RIGHT); JLabel lblMoodleSettings = new JLabel(EmarkingDesktop.lang.getString("moodlesettings")); lblMoodleSettings.setBounds(10, 11, 230, 14); panel_2.add(lblMoodleSettings); btnTestConnection.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(); } }); JPanel panel_3 = new JPanel(); panel_3.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_3.setBounds(10, 159, 666, 174); panel.add(panel_3); panel_3.setLayout(null); JLabel lblPdfFile = new JLabel(EmarkingDesktop.lang.getString("pdffile")); lblPdfFile.setBounds(0, 39, 119, 14); panel_3.add(lblPdfFile); lblPdfFile.setHorizontalAlignment(SwingConstants.RIGHT); JLabel lblScanned = new JLabel(EmarkingDesktop.lang.getString("scanned")); lblScanned.setBounds(0, 64, 119, 14); panel_3.add(lblScanned); lblScanned.setHorizontalAlignment(SwingConstants.RIGHT); chckbxDoubleSide = new JCheckBox(EmarkingDesktop.lang.getString("doubleside")); chckbxDoubleSide.setEnabled(false); chckbxDoubleSide.setBounds(125, 60, 333, 23); panel_3.add(chckbxDoubleSide); chckbxDoubleSide.setToolTipText(EmarkingDesktop.lang.getString("doublesidetooltip")); this.chckbxDoubleSide.setSelected(this.moodle.getQrExtractor().isDoubleside()); filename = new JTextField(); filename.setEnabled(false); filename.setBounds(129, 36, 329, 20); panel_3.add(filename); filename.setColumns(10); filename.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { warn(); } @Override public void insertUpdate(DocumentEvent e) { warn(); } @Override public void changedUpdate(DocumentEvent e) { warn(); } private void warn() { validateFileForProcessing(!btnTestConnection.isEnabled()); } }); this.filename.setText(this.moodle.getLastfile()); btnOpenPdfFile = new JButton(EmarkingDesktop.lang.getString("openfile")); btnOpenPdfFile.setEnabled(false); btnOpenPdfFile.setBounds(468, 33, 172, 27); panel_3.add(btnOpenPdfFile); JLabel lblPdfFileSettings = new JLabel(EmarkingDesktop.lang.getString("filesettings")); lblPdfFileSettings.setBounds(10, 11, 230, 14); panel_3.add(lblPdfFileSettings); JLabel lblOMRtemplate = new JLabel(EmarkingDesktop.lang.getString("omrfile")); lblOMRtemplate.setHorizontalAlignment(SwingConstants.RIGHT); lblOMRtemplate.setBounds(0, 142, 119, 14); panel_3.add(lblOMRtemplate); omrtemplate = new JTextField(); omrtemplate.setEnabled(false); omrtemplate.setText((String) null); omrtemplate.setColumns(10); omrtemplate.setBounds(129, 139, 329, 20); panel_3.add(omrtemplate); omrtemplate.setText(this.moodle.getOMRTemplate()); btnOpenOMRTemplate = new JButton(EmarkingDesktop.lang.getString("openomrfile")); btnOpenOMRTemplate.setEnabled(false); btnOpenOMRTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle(EmarkingDesktop.lang.getString("openfiletitle")); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setFileFilter(new FileFilter() { @Override public String getDescription() { return "*.xtmpl"; } @Override public boolean accept(File arg0) { if (arg0.getName().endsWith(".xtmpl") || arg0.isDirectory()) return true; return false; } }); int retval = chooser.showOpenDialog(panel); if (retval == JFileChooser.APPROVE_OPTION) { omrtemplate.setText(chooser.getSelectedFile().getAbsolutePath()); } else { return; } } }); btnOpenOMRTemplate.setBounds(468, 136, 172, 27); panel_3.add(btnOpenOMRTemplate); lblMarkersTraining = new JLabel((String) EmarkingDesktop.lang.getString("markerstraining")); lblMarkersTraining.setHorizontalAlignment(SwingConstants.RIGHT); lblMarkersTraining.setBounds(0, 89, 119, 14); panel_3.add(lblMarkersTraining); chckbxMarkersTraining = new JCheckBox(EmarkingDesktop.lang.getString("markerstrainingfakestudents")); chckbxMarkersTraining.setBounds(125, 87, 333, 23); panel_3.add(chckbxMarkersTraining); btnOpenPdfFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton.setEnabled(false); JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle(EmarkingDesktop.lang.getString("openfiletitle")); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setFileFilter(new FileFilter() { @Override public String getDescription() { return "*.pdf, *.zip"; } @Override public boolean accept(File arg0) { if (arg0.getName().endsWith(".zip") || arg0.getName().endsWith(".pdf") || arg0.isDirectory()) return true; return false; } }); int retval = chooser.showOpenDialog(panel); if (retval == JFileChooser.APPROVE_OPTION) { filename.setText(chooser.getSelectedFile().getAbsolutePath()); okButton.setEnabled(true); } else { return; } } }); JPanel panel_1 = new JPanel(); tabbedPane.addTab(EmarkingDesktop.lang.getString("advanced"), null, panel_1, null); panel_1.setLayout(null); JPanel panel_4 = new JPanel(); panel_4.setLayout(null); panel_4.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_4.setBounds(10, 11, 665, 131); panel_1.add(panel_4); JLabel lblAdvancedOptions = new JLabel(EmarkingDesktop.lang.getString("advancedoptions")); lblAdvancedOptions.setBounds(10, 11, 233, 14); panel_4.add(lblAdvancedOptions); JLabel lblThreads = new JLabel(EmarkingDesktop.lang.getString("maxthreads")); lblThreads.setBounds(10, 38, 130, 14); panel_4.add(lblThreads); lblThreads.setHorizontalAlignment(SwingConstants.RIGHT); JLabel lblSomething = new JLabel(EmarkingDesktop.lang.getString("separatezipfiles")); lblSomething.setBounds(10, 73, 130, 14); panel_4.add(lblSomething); lblSomething.setHorizontalAlignment(SwingConstants.RIGHT); JLabel label = new JLabel(EmarkingDesktop.lang.getString("resolution")); label.setBounds(10, 105, 130, 14); panel_4.add(label); label.setHorizontalAlignment(SwingConstants.RIGHT); resolution = new JComboBox<Integer>(); resolution.setBounds(150, 99, 169, 27); panel_4.add(resolution); resolution.setModel(new DefaultComboBoxModel<Integer>(new Integer[] { 75, 100, 150, 300, 400, 500, 600 })); resolution.setSelectedIndex(2); this.resolution.setSelectedItem(this.moodle.getQrExtractor().getResolution()); maxZipSize = new JComboBox<String>(); maxZipSize.setBounds(150, 67, 169, 27); panel_4.add(maxZipSize); maxZipSize.setModel(new DefaultComboBoxModel<String>(new String[] { "<dynamic>", "2Mb", "4Mb", "8Mb", "16Mb", "32Mb", "64Mb", "128Mb", "256Mb", "512Mb", "1024Mb" })); maxZipSize.setSelectedIndex(6); this.maxZipSize.setSelectedItem(this.moodle.getMaxZipSizeString()); maxThreads = new JComboBox<Integer>(); maxThreads.setBounds(150, 32, 169, 27); panel_4.add(maxThreads); maxThreads.setModel(new DefaultComboBoxModel<Integer>(new Integer[] { 2, 4, 8, 16 })); maxThreads.setSelectedIndex(1); this.maxThreads.setSelectedItem(this.moodle.getQrExtractor().getMaxThreads()); JPanel panel_5 = new JPanel(); panel_5.setLayout(null); panel_5.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_5.setBounds(10, 153, 665, 131); panel_1.add(panel_5); JLabel lblOMRoptions = new JLabel(EmarkingDesktop.lang.getString("omroptions")); lblOMRoptions.setBounds(10, 11, 233, 14); panel_5.add(lblOMRoptions); JLabel lblOMRthreshold = new JLabel(EmarkingDesktop.lang.getString("omrthreshold")); lblOMRthreshold.setHorizontalAlignment(SwingConstants.RIGHT); lblOMRthreshold.setBounds(10, 32, 130, 14); panel_5.add(lblOMRthreshold); JLabel lblShapeSize = new JLabel(EmarkingDesktop.lang.getString("omrshapesize")); lblShapeSize.setHorizontalAlignment(SwingConstants.RIGHT); lblShapeSize.setBounds(10, 99, 130, 14); panel_5.add(lblShapeSize); JLabel lblDensity = new JLabel(EmarkingDesktop.lang.getString("omrdensity")); lblDensity.setHorizontalAlignment(SwingConstants.RIGHT); lblDensity.setBounds(10, 70, 130, 14); panel_5.add(lblDensity); spinnerOMRthreshold = new JSpinner(); spinnerOMRthreshold.setBounds(150, 32, 169, 20); panel_5.add(spinnerOMRthreshold); spinnerOMRthreshold.setValue(this.moodle.getOMRthreshold()); spinnerOMRdensity = new JSpinner(); spinnerOMRdensity.setBounds(150, 67, 169, 20); panel_5.add(spinnerOMRdensity); spinnerOMRdensity.setValue(this.moodle.getOMRdensity()); spinnerOMRshapeSize = new JSpinner(); spinnerOMRshapeSize.setBounds(150, 99, 169, 20); panel_5.add(spinnerOMRshapeSize); spinnerOMRshapeSize.setValue(this.moodle.getOMRshapeSize()); JLabel lblAnonymousPercentage = new JLabel( "<html>" + EmarkingDesktop.lang.getString("anonymouspercentage") + "</html>"); lblAnonymousPercentage.setHorizontalAlignment(SwingConstants.RIGHT); lblAnonymousPercentage.setBounds(329, 32, 130, 27); panel_5.add(lblAnonymousPercentage); spinnerAnonymousPercentage = new JSpinner(); spinnerAnonymousPercentage.setBounds(469, 32, 169, 20); panel_5.add(spinnerAnonymousPercentage); spinnerAnonymousPercentage.setValue(this.moodle.getAnonymousPercentage()); JLabel lblAnonymousPercentageCustomPage = new JLabel( "<html>" + EmarkingDesktop.lang.getString("anonymouspercentagecustompage") + "</html>"); lblAnonymousPercentageCustomPage.setHorizontalAlignment(SwingConstants.RIGHT); lblAnonymousPercentageCustomPage.setBounds(329, 70, 130, 27); panel_5.add(lblAnonymousPercentageCustomPage); spinnerAnonymousPercentageCustomPage = new JSpinner(); spinnerAnonymousPercentageCustomPage.setBounds(469, 70, 169, 20); panel_5.add(spinnerAnonymousPercentageCustomPage); spinnerAnonymousPercentageCustomPage.setValue(this.moodle.getAnonymousPercentageCustomPage()); JLabel lblCustomPage = new JLabel( "<html>" + EmarkingDesktop.lang.getString("anonymouscustompage") + "</html>"); lblCustomPage.setHorizontalAlignment(SwingConstants.RIGHT); lblCustomPage.setBounds(329, 99, 130, 27); panel_5.add(lblCustomPage); spinnerCustomPage = new JSpinner(); spinnerCustomPage.setBounds(469, 99, 169, 20); panel_5.add(spinnerCustomPage); spinnerCustomPage.setValue(this.moodle.getAnonymousCustomPage()); }
From source file:configuration.Util.java
public static String[] simpleSearchBox(String type, boolean multi, boolean hide) { JFrame f = createSearchFrame(); JFileChooser jf; jf = new JFileChooser(config.getExplorerPath()); if (type.contains("d") || type.contains("D")) jf.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); else if (type.contains("f") || type.contains("F")) jf.setFileSelectionMode(JFileChooser.FILES_ONLY); else/* ww w. j a v a 2 s . c o m*/ jf.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); jf.setAcceptAllFileFilterUsed(false); jf.setMultiSelectionEnabled(multi); jf.setFileHidingEnabled(hide); int result = jf.showOpenDialog(f); f.dispose(); if (result == JFileChooser.APPROVE_OPTION) { if (multi) { //--Save new filepath and files File[] files = jf.getSelectedFiles(); String[] path = new String[files.length]; for (int i = 0; i < files.length; i++) { path[i] = getCanonicalPath(files[i].getPath()); } return path; } else { File file = jf.getSelectedFile(); String[] path = new String[1]; path[0] = getCanonicalPath(file.getPath()); return path; } } String[] empty = new String[0]; return empty; }
From source file:de.fionera.javamailer.gui.mainView.controllerMain.java
/** * Adds the Actionlisteners to the Mainview * * @param viewMain The Mainview/* w ww . ja v a2 s. 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); } } }); }