List of usage examples for javax.swing JFileChooser SAVE_DIALOG
int SAVE_DIALOG
To view the source code for javax.swing JFileChooser SAVE_DIALOG.
Click Source Link
JFileChooser
supports a "Save" file operation. From source file:net.sf.jabref.gui.journals.ManageJournalsPanel.java
public ManageJournalsPanel(final JabRefFrame frame) { this.frame = frame; personalFile.setEditable(false);//from w ww . ja va 2 s.co m ButtonGroup group = new ButtonGroup(); group.add(newFile); group.add(oldFile); addExtPan.setLayout(new BorderLayout()); JButton addExt = new JButton(IconTheme.JabRefIcon.ADD.getIcon()); addExtPan.add(addExt, BorderLayout.EAST); addExtPan.setToolTipText(Localization.lang("Add")); FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:200dlu:grow, 4dlu, fill:pref", "pref, pref, pref, 20dlu, 20dlu, fill:200dlu, 4dlu, pref"); FormBuilder builder = FormBuilder.create().layout(layout); builder.addSeparator(Localization.lang("Built-in journal list")).xyw(2, 1, 6); JLabel description = new JLabel( "<HTML>" + Localization.lang("JabRef includes a built-in list of journal abbreviations.") + "<br>" + Localization.lang( "You can add additional journal names by setting up a personal journal list,<br>as " + "well as linking to external journal lists.") + "</HTML>"); description.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); builder.add(description).xyw(2, 2, 6); JButton viewBuiltin = new JButton(Localization.lang("View")); builder.add(viewBuiltin).xy(7, 2); builder.addSeparator(Localization.lang("Personal journal list")).xyw(2, 3, 6); builder.add(newFile).xy(3, 4); builder.add(newNameTf).xy(5, 4); JButton browseNew = new JButton(Localization.lang("Browse")); builder.add(browseNew).xy(7, 4); builder.add(oldFile).xy(3, 5); builder.add(personalFile).xy(5, 5); JButton browseOld = new JButton(Localization.lang("Browse")); builder.add(browseOld).xy(7, 5); userPanel.setLayout(new BorderLayout()); builder.add(userPanel).xyw(2, 6, 4); ButtonStackBuilder butBul = new ButtonStackBuilder(); butBul.addButton(add); butBul.addButton(remove); butBul.addGlue(); builder.add(butBul.getPanel()).xy(7, 6); builder.addSeparator(Localization.lang("External files")).xyw(2, 8, 6); externalFilesPanel.setLayout(new BorderLayout()); setLayout(new BorderLayout()); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(builder.getPanel(), BorderLayout.NORTH); add(externalFilesPanel, BorderLayout.CENTER); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); JButton ok = new JButton(Localization.lang("OK")); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addUnrelatedGap(); JButton help = new HelpAction(HelpFile.JOURNAL_ABBREV).getHelpButton(); bb.addButton(help); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); dialog = new JDialog(frame, Localization.lang("Journal abbreviations"), false); dialog.getContentPane().add(this, BorderLayout.CENTER); dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); // Set up panel for editing a single journal, to be used in a dialog box: FormLayout layout2 = new FormLayout("right:pref, 4dlu, fill:180dlu", "p, 2dlu, p"); FormBuilder builder2 = FormBuilder.create().layout(layout2); builder2.add(Localization.lang("Journal name")).xy(1, 1); builder2.add(nameTf).xy(3, 1); builder2.add(Localization.lang("ISO abbreviation")).xy(1, 3); builder2.add(abbrTf).xy(3, 3); journalEditPanel = builder2.getPanel(); viewBuiltin.addActionListener(e -> { JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbreviationLoader .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)) .getAbbreviations())); JScrollPane pane = new JScrollPane(table); JOptionPane.showMessageDialog(null, pane, Localization.lang("Journal list preview"), JOptionPane.INFORMATION_MESSAGE); }); browseNew.addActionListener(e -> { Path old = null; if (!newNameTf.getText().isEmpty()) { old = Paths.get(newNameTf.getText()); } String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.SAVE_DIALOG, false); if (name != null) { newNameTf.setText(name); newFile.setSelected(true); } }); browseOld.addActionListener(e -> { Path old = null; if (!personalFile.getText().isEmpty()) { old = Paths.get(personalFile.getText()); } String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.OPEN_DIALOG, false); if (name != null) { personalFile.setText(name); oldFile.setSelected(true); oldFile.setEnabled(true); setupUserTable(); } }); ok.addActionListener(e -> { if (readyToClose()) { storeSettings(); dialog.dispose(); } }); Action cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); add.addActionListener(tableModel); remove.addActionListener(tableModel); addExt.addActionListener(e -> { externals.add(new ExternalFileEntry()); buildExternalsPanel(); }); // Key bindings: ActionMap am = getActionMap(); InputMap im = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); int xSize = getPreferredSize().width; dialog.setSize(xSize + 10, 700); }
From source file:filesscanner.MainWindow.java
private void saveToJSONBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveToJSONBtnActionPerformed JSONObject object = new JSONObject(); for (int i = 0; i < modelFiles.getSize(); i++) { object.put("filename" + i, modelFiles.get(i).toString()); }//from w w w.j av a 2 s . c o m File file = new File("C:"); JFileChooser chooser = ShowChooser(file); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setDialogType(JFileChooser.SAVE_DIALOG); int res = chooser.showDialog(this, " ? ??!!!"); if (res == JFileChooser.APPROVE_OPTION) { try { Writer writer = new FileWriter(chooser.getSelectedFile()); object.writeJSONString(writer); JOptionPane.showMessageDialog(rootPane, "SAVED SUCCESFULLY!!!"); writer.flush(); writer.close(); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(rootPane, "Something bad!!!"); } } }
From source file:org.spf4j.ui.TSDBViewJInternalFrame.java
@edu.umd.cs.findbugs.annotations.SuppressWarnings("UP_UNUSED_PARAMETER") private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed TreePath[] selectionPaths = measurementTree.getSelectionPaths(); List<String> selectedTables = getSelectedTables(selectionPaths); if (!selectedTables.isEmpty()) { JFileChooser chooser = new JFileChooser(); chooser.setDialogType(JFileChooser.SAVE_DIALOG); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); try { tsDb.writeCsvTables(selectedTables, file); } catch (IOException ex) { throw new RuntimeException(ex); }/*from www. j av a 2 s . c om*/ } } }
From source file:com.ejisto.event.listener.SessionRecorderManager.java
private File selectOutputDirectory(Component parent, String directoryPath, boolean saveLastSelectionPath, SettingsRepository settingsRepository) { String targetPath = null;/*from w ww. ja v a 2s . co m*/ Path savedPath = null; if (StringUtils.isNotBlank(directoryPath)) { savedPath = Paths.get(directoryPath); Path selectionPath = savedPath.getParent(); if (selectionPath != null) { targetPath = selectionPath.toString(); } } JFileChooser fileChooser = new JFileChooser(targetPath); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); fileChooser.setSelectedFile(savedPath != null ? savedPath.toFile() : null); fileChooser.setDialogTitle(getMessage("session.record.save.target")); return GuiUtils.openFileSelectionDialog(parent, saveLastSelectionPath, fileChooser, LAST_OUTPUT_PATH, settingsRepository); }
From source file:net.sf.jabref.exporter.SaveDatabaseAction.java
/** * Run the "Save as" operation. This method offloads the actual save operation to a background thread, but * still runs synchronously using Spin (the method returns only after completing the operation). *//*from w ww .j a v a 2 s .co m*/ public void saveAs() throws Throwable { String chosenFile; File f = null; while (f == null) { chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), ".bib", JFileChooser.SAVE_DIALOG, false, null); if (chosenFile == null) { canceled = true; return; // canceled } f = new File(chosenFile); // Check if the file already exists: if (f.exists() && (JOptionPane.showConfirmDialog(frame, Localization.lang("'%0' exists. Overwrite file?", f.getName()), Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)) { f = null; } } if (f != null) { File oldFile = panel.getBibDatabaseContext().getDatabaseFile(); panel.getBibDatabaseContext().setDatabaseFile(f); Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, f.getParent()); runCommand(); // If the operation failed, revert the file field and return: if (!success) { panel.getBibDatabaseContext().setDatabaseFile(oldFile); return; } // Register so we get notifications about outside changes to the file. try { panel.setFileMonitorHandle(Globals.fileUpdateMonitor.addUpdateListener(panel, panel.getBibDatabaseContext().getDatabaseFile())); } catch (IOException ex) { LOGGER.error("Problem registering file change notifications", ex); } frame.getFileHistory().newFile(panel.getBibDatabaseContext().getDatabaseFile().getPath()); } frame.updateEnabledState(); }
From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java
/** * Run the "Save as" operation. This method offloads the actual save operation to a background thread, but * still runs synchronously using Spin (the method returns only after completing the operation). *//*from w w w . j a va 2 s .co m*/ public void saveAs() throws Throwable { String chosenFile; File f = null; while (f == null) { chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Collections.singletonList(".bib"), JFileChooser.SAVE_DIALOG, false, null); if (chosenFile == null) { canceled = true; return; // canceled } f = new File(chosenFile); // Check if the file already exists: if (f.exists() && (JOptionPane.showConfirmDialog(frame, Localization.lang("'%0' exists. Overwrite file?", f.getName()), Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)) { f = null; } } File oldFile = panel.getBibDatabaseContext().getDatabaseFile(); panel.getBibDatabaseContext().setDatabaseFile(f); Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, f.getParent()); runCommand(); // If the operation failed, revert the file field and return: if (!success) { panel.getBibDatabaseContext().setDatabaseFile(oldFile); return; } // Register so we get notifications about outside changes to the file. try { panel.setFileMonitorHandle(Globals.getFileUpdateMonitor().addUpdateListener(panel, panel.getBibDatabaseContext().getDatabaseFile())); } catch (IOException ex) { LOGGER.error("Problem registering file change notifications", ex); } frame.getFileHistory().newFile(panel.getBibDatabaseContext().getDatabaseFile().getPath()); frame.updateEnabledState(); }
From source file:temp1.JFrame1.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//w w w. jav a 2 s . co m */ @SuppressWarnings("checked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jFileChooser1 = new javax.swing.JFileChooser(); jFileChooser2 = new javax.swing.JFileChooser(); jSeparator1 = new javax.swing.JSeparator(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jFormattedTextField1 = new javax.swing.JFormattedTextField(); jFormattedTextField2 = new javax.swing.JFormattedTextField(); jScrollPane4 = new javax.swing.JScrollPane(); jTextPane3 = new javax.swing.JTextPane(); jTextField1 = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); jButton5 = new javax.swing.JButton(); canvas1 = new java.awt.Canvas(); jPanel4 = new javax.swing.JPanel(); jSlider1 = new javax.swing.JSlider(); jLabel5 = new javax.swing.JLabel(); jProgressBar1 = new javax.swing.JProgressBar(); jButton4 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jScrollPane3 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel3 = new javax.swing.JPanel(); jToggleButton4 = new javax.swing.JToggleButton(); jToggleButton5 = new javax.swing.JToggleButton(); jToggleButton6 = new javax.swing.JToggleButton(); jToggleButton7 = new javax.swing.JToggleButton(); jPanel6 = new javax.swing.JPanel(); jPanel7 = new javax.swing.JPanel(); jPanel8 = new javax.swing.JPanel(); jPanel9 = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767)); jMenuBar1 = new javax.swing.JMenuBar(); jFileChooser1.setFileFilter(new ExtensionFileFilter("", new String[] { "txt" })); jFileChooser2.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG); jFileChooser2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFileChooser2ActionPerformed(evt); } }); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("?"); jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); jButton1.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jButton1.setText(""); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jLabel2.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jLabel2.setText(" (m)"); jLabel6.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jLabel6.setText("(ms)"); jLabel3.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jLabel3.setText(""); jLabel4.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jLabel4.setText("? ? (/h)"); jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory( new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0")))); jFormattedTextField1.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jFormattedTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFormattedTextField1ActionPerformed(evt); } }); jFormattedTextField2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory( new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("##0.###")))); jFormattedTextField2.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jFormattedTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFormattedTextField2ActionPerformed(evt); } }); jTextPane3.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jScrollPane4.setViewportView(jTextPane3); jTextField1.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jButton2.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jButton2.setText("Excel"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jScrollPane1.setViewportView(jTextPane1); jButton5.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jButton5.setText(""); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); canvas1.setBackground(new java.awt.Color(0, 0, 0)); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addGap(19, 19, 19) .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(32, 32, 32) .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jFormattedTextField1) .addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE) .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel4)) .addGap(18, 18, 18)) .addGroup(jPanel2Layout.createSequentialGroup().addGap(56, 56, 56) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(58, 58, 58).addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane4).addComponent(jTextField1).addComponent(jButton5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(239, 239, 239))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGap(53, 53, 53) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(62, 62, 62) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(18, 18, 18) .addGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jFormattedTextField2).addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24))); jSlider1.setMaximum(20); jSlider1.setMinimum(10); jSlider1.setValue(0); jLabel5.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jLabel5.setText(" "); jProgressBar1.setForeground(new java.awt.Color(153, 0, 153)); jProgressBar1.setMinimumSize(new java.awt.Dimension(10, 20)); jProgressBar1.setString("100"); jButton4.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jButton4.setText("?"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton3.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jButton3.setText(""); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton6.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jButton6.setText("??"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addGap(64, 64, 64) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(84, 84, 84) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(86, 86, 86) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(53, 53, 53) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 108, Short.MAX_VALUE) .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(58, 58, 58))); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSlider1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))); jTable1.setAutoCreateRowSorter(true); jTable1.setFont(new java.awt.Font("", 1, 12)); // NOI18N jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { }, new String[] { " ", " X", " Y", " Z1", " ?ms", " km/h" }) { Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class, java.lang.Object.class }; boolean[] canEdit = new boolean[] { false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); jTable1.setGridColor(new java.awt.Color(102, 102, 102)); jTable1.getTableHeader().setReorderingAllowed(false); jTable1.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { jTable1AncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); jScrollPane3.setViewportView(jTable1); if (jTable1.getColumnModel().getColumnCount() > 0) { jTable1.getColumnModel().getColumn(0).setResizable(false); jTable1.getColumnModel().getColumn(0).setPreferredWidth(7); jTable1.getColumnModel().getColumn(1).setResizable(false); jTable1.getColumnModel().getColumn(1).setPreferredWidth(110); jTable1.getColumnModel().getColumn(2).setResizable(false); jTable1.getColumnModel().getColumn(2).setPreferredWidth(110); jTable1.getColumnModel().getColumn(3).setResizable(false); jTable1.getColumnModel().getColumn(3).setPreferredWidth(110); jTable1.getColumnModel().getColumn(4).setResizable(false); jTable1.getColumnModel().getColumn(4).setPreferredWidth(60); jTable1.getColumnModel().getColumn(5).setResizable(false); jTable1.getColumnModel().getColumn(5).setPreferredWidth(25); } jToggleButton4.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jToggleButton4.setSelected(true); jToggleButton4.setText("X"); jToggleButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton4ActionPerformed(evt); } }); jToggleButton5.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jToggleButton5.setSelected(true); jToggleButton5.setText("Y"); jToggleButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton5ActionPerformed(evt); } }); jToggleButton6.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jToggleButton6.setSelected(true); jToggleButton6.setText("Z1"); jToggleButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton6ActionPerformed(evt); } }); jToggleButton7.setFont(new java.awt.Font(" Light", 1, 14)); // NOI18N jToggleButton7.setSelected(true); jToggleButton7.setText("Z2"); jToggleButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton7ActionPerformed(evt); } }); jPanel6.setBackground(new java.awt.Color(255, 51, 51)); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); jPanel7.setBackground(new java.awt.Color(0, 255, 255)); javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); jPanel8.setBackground(new java.awt.Color(255, 255, 0)); javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); jPanel8.setLayout(jPanel8Layout); jPanel8Layout.setHorizontalGroup(jPanel8Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 37, Short.MAX_VALUE)); jPanel9.setBackground(new java.awt.Color(51, 51, 255)); javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); jPanel9.setLayout(jPanel9Layout); jPanel9Layout.setHorizontalGroup(jPanel9Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 8, Short.MAX_VALUE)); jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1225, Short.MAX_VALUE)); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jToggleButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE) .addComponent(jToggleButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jToggleButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(8, 8, 8) .addGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(28, 28, 28) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jToggleButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE) .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(21, 21, 21) .addGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToggleButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(24, 24, 24) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jToggleButton7, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE) .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(26, Short.MAX_VALUE)) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(207, 207, 207) .addComponent(filler2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(94, 94, 94) .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup().addContainerGap() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(jScrollPane3))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) .addComponent(jSeparator1)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(filler1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(filler2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(14, 14, 14).addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))); pack(); }
From source file:cn.labthink.ReadAccess060.java
private void jButton_exportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_exportActionPerformed JFileChooser jfc = new JFileChooser(); ExtensionFileFilter filter;/* w ww.jav a 2 s. c om*/ if (jTable1.getSelectedRowCount() == 1) { // filter filter = new ExtensionFileFilter("xls", false, true); filter.setDescription("Save Export File"); jfc.setDialogTitle("Create the Export Excel file"); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); } else if (jTable1.getSelectedRowCount() > 1) { // filter filter = new ExtensionFileFilter("", false, true); filter.setDescription("Save Export Files"); jfc.setDialogTitle("Choose the Export Directory"); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } else { //? jLabel_info.setText("<html><font color='red'>No Record Selected</font></html>"); return; } //? FileSystemView fsv = FileSystemView.getFileSystemView(); //? jfc.setCurrentDirectory(fsv.getHomeDirectory()); jfc.setMultiSelectionEnabled(false); jfc.setDialogType(JFileChooser.SAVE_DIALOG); jfc.setFileFilter(filter); int result = jfc.showSaveDialog(this); // ""? if (result == JFileChooser.APPROVE_OPTION) { if (jTable1.getSelectedRowCount() == 1) { // String filesrc = jfc.getSelectedFile().getAbsolutePath(); if (!filesrc.toLowerCase().endsWith(".xls")) { filesrc = jfc.getSelectedFile().getAbsolutePath() + ".xls"; } outputfile = new File(filesrc); jLabel_info.setText("Exported File:" + outputfile.getAbsolutePath()); } else if (jTable1.getSelectedRowCount() > 1) { // outputfile = jfc.getSelectedFile().isDirectory() ? jfc.getSelectedFile() : jfc.getSelectedFile().getParentFile(); if (outputfile == null) { outputfile = fsv.getHomeDirectory(); } jLabel_info.setText("Exported to path:" + outputfile.getAbsolutePath()); } else { //? return; } } else { return; } if (inputfile == null) { return; } int[] rows = jTable1.getSelectedRows(); if (rows.length == 1) { //? book = null; ExportOneRecord(rows[0]); } else { File path = outputfile; for (int rowindex = 0; rowindex < rows.length; rowindex++) { int k = rows[rowindex]; book = null; outputfile = new File(path.getAbsolutePath() + "/" + jTable1.getValueAt(k, 0) + ".xls"); ExportOneRecord(k); } } // int k = jTable1.getSelectedRow(); // ExportOneRecord(k); }
From source file:GUI.GraphicalInterface.java
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { savesJFileChooser = new javax.swing.JFileChooser(); workdirJFileChooser = new javax.swing.JFileChooser(); jColorChooser1 = new javax.swing.JColorChooser(); jPanel3 = new javax.swing.JPanel(); clearJCheckBox = new javax.swing.JCheckBox(); saveJCheckBox = new javax.swing.JCheckBox(); historyJCheckBox = new javax.swing.JCheckBox(); maxtimeJSlider = new javax.swing.JSlider(); adminJLabel = new javax.swing.JLabel(); rootJCheckBox = new javax.swing.JCheckBox(); rootPasswordJLabel = new javax.swing.JLabel(); passwordJTextField = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); clearargJCheckBox = new javax.swing.JCheckBox(); jPanel4 = new javax.swing.JPanel(); manualJRadioButton = new javax.swing.JRadioButton(); commandJTextField = new javax.swing.JTextField(); executeManualJButton = new javax.swing.JButton(); optionJLabel = new javax.swing.JLabel(); optionJTextField = new javax.swing.JTextField(); argumentJLabel = new javax.swing.JLabel(); argumentJTextField = new javax.swing.JTextField(); commandJComboBox = new javax.swing.JComboBox(); listJRadioButton = new javax.swing.JRadioButton(); optionJComboBox = new javax.swing.JComboBox(); executeJButton = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); clearJButton = new javax.swing.JButton(); showHistoryJButton = new javax.swing.JButton(); clearHistoryJButton = new javax.swing.JButton(); saveButton = new javax.swing.JButton(); abortJButton = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); statusJLabel = new javax.swing.JLabel(); statusJProgressBar = new javax.swing.JProgressBar(); jTabbedPane1 = new javax.swing.JTabbedPane(); jScrollPane1 = new javax.swing.JScrollPane(); terminalJTextArea = new javax.swing.JTextArea(); jScrollPane2 = new javax.swing.JScrollPane(); descriptionJTextArea = new javax.swing.JTextArea(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem1 = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem7 = new javax.swing.JMenuItem(); jMenuItem6 = new javax.swing.JMenuItem(); jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem5 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); savesJFileChooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG); workdirJFileChooser.setDialogType(javax.swing.JFileChooser.CUSTOM_DIALOG); workdirJFileChooser.setApproveButtonText("Select directory"); workdirJFileChooser.setApproveButtonToolTipText("Choose working directory for command execution"); workdirJFileChooser.setDialogTitle("Choose working directory"); workdirJFileChooser.setFileFilter(null); workdirJFileChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Grafcom Graphical Commander"); setResizable(false);// www . ja v a2 s . c o m jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204))); clearJCheckBox.setText("Clear terminal before executing command"); clearJCheckBox.setFocusPainted(false); saveJCheckBox.setText("Open file after saving"); saveJCheckBox.setFocusPainted(false); historyJCheckBox.setText("Do not save command history"); historyJCheckBox.setFocusPainted(false); historyJCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { historyJCheckBoxActionPerformed(evt); } }); maxtimeJSlider.setMajorTickSpacing(3); maxtimeJSlider.setMaximum(21); maxtimeJSlider.setMinimum(3); maxtimeJSlider.setPaintLabels(true); maxtimeJSlider.setSnapToTicks(true); maxtimeJSlider.setValue(3); maxtimeJSlider.setFocusable(false); adminJLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N adminJLabel.setText("Superuser privileges (Linux-based systems only)"); rootJCheckBox.setText("Run command as root"); rootJCheckBox.setFocusPainted(false); rootJCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rootJCheckBoxActionPerformed(evt); } }); rootPasswordJLabel.setText("root password:"); passwordJTextField.setForeground(new java.awt.Color(254, 254, 254)); passwordJTextField .setToolTipText("Enter password here. Password not visible due to security considerations"); passwordJTextField.setEnabled(false); passwordJTextField.setSelectionColor(new java.awt.Color(254, 254, 254)); jLabel2.setText("Set command execution timeout (seconds)"); clearargJCheckBox.setText("Clear command arguments after execution"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(rootJCheckBox).addComponent(adminJLabel) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(clearargJCheckBox).addComponent(saveJCheckBox) .addComponent(historyJCheckBox).addComponent(clearJCheckBox)) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(rootPasswordJLabel).addGap(4, 4, 4).addComponent( passwordJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGroup(jPanel3Layout.createSequentialGroup().addGap(37, 37, 37).addComponent( maxtimeJSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addGap(76, 76, 76).addComponent(jLabel2))) .addGap(52, 52, 52))); jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { clearJCheckBox, historyJCheckBox, saveJCheckBox }); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addComponent(jLabel2) .addGap(2, 2, 2) .addComponent(maxtimeJSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(clearJCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(clearargJCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(saveJCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(historyJCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE) .addComponent(adminJLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(rootJCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(rootPasswordJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(passwordJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap())); jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204))); manualJRadioButton.setText("Type command manually"); manualJRadioButton.setFocusPainted(false); manualJRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { manualJRadioButtonActionPerformed(evt); } }); commandJTextField.setToolTipText("Enter command to execute"); executeManualJButton.setIcon( new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/utilities-terminal16x16.png"))); // NOI18N executeManualJButton.setText("Execute"); executeManualJButton.setFocusPainted(false); executeManualJButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { executeManualJButtonActionPerformed(evt); } }); optionJLabel.setText("option argument:"); optionJTextField.setToolTipText("Specify the argument for the selected option"); optionJTextField.setEnabled(false); argumentJLabel.setText("command argument:"); argumentJTextField.setToolTipText("Specify the argument for the selected command"); argumentJTextField.setEnabled(false); commandJComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "(Select command)" })); commandJComboBox.setToolTipText("Select command to execute"); commandJComboBox.setFocusable(false); commandJComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { commandJComboBoxActionPerformed(evt); } }); listJRadioButton.setSelected(true); listJRadioButton.setText("Select command from list"); listJRadioButton.setFocusPainted(false); listJRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { listJRadioButtonActionPerformed(evt); } }); optionJComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "(Select option)" })); optionJComboBox.setToolTipText("Choose option for the selected command"); optionJComboBox.setEnabled(false); optionJComboBox.setFocusable(false); executeJButton.setIcon( new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/utilities-terminal16x16.png"))); // NOI18N executeJButton.setText("Execute"); executeJButton.setToolTipText("Click to execute command with the given parameters"); executeJButton.setEnabled(false); executeJButton.setFocusPainted(false); executeJButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { executeJButtonActionPerformed(evt); } }); jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/folder.png"))); // NOI18N jButton1.setText("Set command execution path..."); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(argumentJLabel).addComponent(optionJLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(argumentJTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE) .addComponent(optionJTextField)) .addGap(113, 113, 113)) .addGroup(jPanel4Layout.createSequentialGroup().addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(listJRadioButton) .addGroup(jPanel4Layout.createSequentialGroup() .addComponent(commandJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(optionJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(executeJButton)) .addComponent(manualJRadioButton) .addGroup(jPanel4Layout.createSequentialGroup() .addComponent(commandJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(executeManualJButton)) .addGroup(jPanel4Layout.createSequentialGroup().addGap(79, 79, 79) .addComponent(jButton1))) .addContainerGap())))); jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { argumentJLabel, optionJLabel }); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addContainerGap().addComponent(listJRadioButton).addGap(4, 4, 4) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(commandJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(optionJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(executeJButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(argumentJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(argumentJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(optionJTextField).addComponent(optionJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(7, 7, 7).addComponent(manualJRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(commandJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(executeManualJButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton1) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] { argumentJTextField, optionJTextField }); clearJButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/edit-clear.png"))); // NOI18N clearJButton.setText("Clear Terminal"); clearJButton.setToolTipText("Click to clear terminal output"); clearJButton.setFocusPainted(false); clearJButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearJButtonActionPerformed(evt); } }); showHistoryJButton.setIcon( new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/format-justify-fill.png"))); // NOI18N showHistoryJButton.setText("Show history"); showHistoryJButton.setToolTipText("Click to display the list of commands executed"); showHistoryJButton.setFocusPainted(false); showHistoryJButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { showHistoryJButtonActionPerformed(evt); } }); clearHistoryJButton .setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/edit-clear.png"))); // NOI18N clearHistoryJButton.setText("Clear History"); clearHistoryJButton.setFocusPainted(false); clearHistoryJButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearHistoryJButtonActionPerformed(evt); } }); saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/media-floppy.png"))); // NOI18N saveButton.setText("Save to file..."); saveButton.setFocusPainted(false); saveButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveButtonActionPerformed(evt); } }); abortJButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/icon/process-stop.png"))); // NOI18N abortJButton.setText("Abort"); abortJButton.setToolTipText("Abort command execution"); abortJButton.setEnabled(false); abortJButton.setFocusPainted(false); abortJButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { abortJButtonActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addGap(13, 13, 13).addComponent(clearJButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(showHistoryJButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(clearHistoryJButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(saveButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(abortJButton) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(clearJButton).addComponent(showHistoryJButton) .addComponent(clearHistoryJButton).addComponent(saveButton).addComponent(abortJButton))); jPanel1.setBackground(new java.awt.Color(51, 51, 51)); statusJLabel.setForeground(new java.awt.Color(255, 255, 255)); statusJLabel.setText("Select command from drop-down list or type manually to execute."); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(statusJLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(statusJProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(statusJLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE) .addComponent(statusJProgressBar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); terminalJTextArea.setEditable(false); terminalJTextArea.setBackground(new java.awt.Color(51, 51, 51)); terminalJTextArea.setColumns(20); terminalJTextArea.setFont(new java.awt.Font("Consolas", 0, 13)); // NOI18N terminalJTextArea.setForeground(new java.awt.Color(204, 204, 204)); terminalJTextArea.setLineWrap(true); terminalJTextArea.setRows(5); terminalJTextArea.setTabSize(3); terminalJTextArea.setToolTipText("Displays output of command executed"); terminalJTextArea.setCaretColor(new java.awt.Color(204, 204, 204)); terminalJTextArea.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); terminalJTextArea.setMargin(new java.awt.Insets(8, 4, 4, 4)); terminalJTextArea.setSelectionColor(new java.awt.Color(153, 153, 153)); jScrollPane1.setViewportView(terminalJTextArea); jTabbedPane1.addTab("Terminal Emulator", jScrollPane1); jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); descriptionJTextArea.setEditable(false); descriptionJTextArea.setColumns(20); descriptionJTextArea.setFont(new java.awt.Font("Consolas", 0, 13)); // NOI18N descriptionJTextArea.setLineWrap(true); descriptionJTextArea.setRows(5); descriptionJTextArea.setTabSize(3); descriptionJTextArea.setToolTipText("Description of selected command and its options"); descriptionJTextArea.setWrapStyleWord(true); descriptionJTextArea.setCaretColor(new java.awt.Color(255, 255, 255)); descriptionJTextArea.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); descriptionJTextArea.setFocusable(false); descriptionJTextArea.setMargin(new java.awt.Insets(4, 4, 4, 4)); descriptionJTextArea.setSelectionColor(new java.awt.Color(51, 204, 255)); jScrollPane2.setViewportView(descriptionJTextArea); jTabbedPane1.addTab("Command Description", jScrollPane2); jMenu1.setText("File"); jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem2.setText("Save output to file..."); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu1.add(jMenuItem2); jMenuItem1.setText("Exit"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu1.add(jMenuItem1); jMenuBar1.add(jMenu1); jMenu3.setText("Settings"); jMenuItem7.setText("Terminal background color"); jMenuItem7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem7ActionPerformed(evt); } }); jMenu3.add(jMenuItem7); jMenuItem6.setText("Terminal text color"); jMenuItem6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem6ActionPerformed(evt); } }); jMenu3.add(jMenuItem6); jCheckBoxMenuItem1.setSelected(true); jCheckBoxMenuItem1.setText("Sounds"); jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBoxMenuItem1ActionPerformed(evt); } }); jMenu3.add(jCheckBoxMenuItem1); jMenuBar1.add(jMenu3); jMenu2.setText("Help"); jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0)); jMenuItem5.setText("Grafcom help contents"); jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } }); jMenu2.add(jMenuItem5); jMenuItem4.setText("Project Homepage"); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu2.add(jMenuItem4); jMenuItem3.setText("About"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu2.add(jMenuItem3); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jTabbedPane1)) .addGap(11, 11, 11)) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18).addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addComponent(jTabbedPane1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); pack(); setLocationRelativeTo(null); }
From source file:captureplugin.CapturePlugin.java
/** * Check the programs after data update. *//*from w w w .jav a 2s . com*/ public void handleTvDataUpdateFinished() { mNeedsUpdate = true; if (mAllowedToShowDialog) { mNeedsUpdate = false; DeviceIf[] devices = mConfig.getDeviceArray(); final DefaultTableModel model = new DefaultTableModel() { public boolean isCellEditable(int row, int column) { return false; } }; model.setColumnCount(5); model.setColumnIdentifiers(new String[] { mLocalizer.msg("device", "Device"), Localizer.getLocalization(Localizer.I18N_CHANNEL), mLocalizer.msg("date", "Date"), ProgramFieldType.START_TIME_TYPE.getLocalizedName(), ProgramFieldType.TITLE_TYPE.getLocalizedName() }); JTable table = new JTable(model); table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setResizingAllowed(false); table.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable renderTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(renderTable, value, isSelected, hasFocus, row, column); if (value instanceof DeviceIf) { if (((DeviceIf) value).getDeleteRemovedProgramsAutomatically() && !isSelected) { c.setForeground(Color.red); } } return c; } }); int[] columnWidth = new int[5]; for (int i = 0; i < columnWidth.length; i++) { columnWidth[i] = UiUtilities.getStringWidth(table.getFont(), model.getColumnName(i)) + 10; } for (DeviceIf device : devices) { Program[] deleted = device.checkProgramsAfterDataUpdateAndGetDeleted(); if (deleted != null && deleted.length > 0) { for (Program p : deleted) { if (device.getDeleteRemovedProgramsAutomatically() && !p.isExpired() && !p.isOnAir()) { device.remove(UiUtilities.getLastModalChildOf(getParentFrame()), p); } else { device.removeProgramWithoutExecution(p); } if (!p.isExpired()) { Object[] o = new Object[] { device, p.getChannel().getName(), p.getDateString(), p.getTimeString(), p.getTitle() }; for (int i = 0; i < columnWidth.length; i++) { columnWidth[i] = Math.max(columnWidth[i], UiUtilities.getStringWidth(table.getFont(), o[i].toString()) + 10); } model.addRow(o); } } } device.getProgramList(); } if (model.getRowCount() > 0) { int sum = 0; for (int i = 0; i < columnWidth.length; i++) { table.getColumnModel().getColumn(i).setPreferredWidth(columnWidth[i]); if (i < columnWidth.length - 1) { table.getColumnModel().getColumn(i).setMaxWidth(columnWidth[i]); } sum += columnWidth[i]; } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setPreferredSize(new Dimension(450, 250)); if (sum > 500) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.getViewport().setPreferredSize( new Dimension(sum, scrollPane.getViewport().getPreferredSize().height)); } JButton export = new JButton(mLocalizer.msg("exportList", "Export list")); export.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileFilter(new FileFilter() { public boolean accept(File f) { return f.isDirectory() || f.toString().toLowerCase().endsWith(".txt"); } public String getDescription() { return "*.txt"; } }); chooser.setSelectedFile(new File("RemovedPrograms.txt")); if (chooser.showSaveDialog( UiUtilities.getLastModalChildOf(getParentFrame())) == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { String file = chooser.getSelectedFile().getAbsolutePath(); if (!file.toLowerCase().endsWith(".txt") && file.indexOf('.') == -1) { file = file + ".txt"; } if (file.indexOf('.') != -1) { try { RandomAccessFile write = new RandomAccessFile(file, "rw"); write.setLength(0); String eolStyle = File.separator.equals("/") ? "\n" : "\r\n"; for (int i = 0; i < model.getRowCount(); i++) { StringBuilder line = new StringBuilder(); for (int j = 0; j < model.getColumnCount(); j++) { line.append(model.getValueAt(i, j)).append(' '); } line.append(eolStyle); write.writeBytes(line.toString()); } write.close(); } catch (Exception ee) { } } } } } }); Object[] message = { mLocalizer.msg("deletedText", "The data was changed and the following programs were deleted:"), scrollPane, export }; JOptionPane pane = new JOptionPane(); pane.setMessage(message); pane.setMessageType(JOptionPane.PLAIN_MESSAGE); final JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(getParentFrame()), mLocalizer.msg("CapturePlugin", "CapturePlugin") + " - " + mLocalizer.msg("deletedTitle", "Deleted programs")); d.setResizable(true); d.setModal(false); SwingUtilities.invokeLater(new Runnable() { public void run() { d.setVisible(true); } }); } } }