public void actionPerformed(ActionEvent e) { int index = list.getSelectedIndex(); try { waitField.commitEdit(); checkField.commitEdit(); } catch (java.text.ParseException x) { printer.printError(x.toString()); return; } Directory task = directoryList.getDirectory(index); startButton.setEnabled(false); task.setWaitInterval(((Number) waitField.getValue()).intValue()); task.setInterval(((Number) checkField.getValue()).intValue()); Path destination = task.getDestination(); Path directory = task.getDirectory(); task.backupNumber = 1; timer = new Timer(); timer.schedule( new CopyTask(directory, destination, task.waitInterval, printer, copy), 0, task.interval); timers.add(timer); stopButton.setEnabled(true); log.setCaretPosition(log.getDocument().getLength()); }
public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); int index = list.getSelectedIndex(); if (index == -1) { return; } if (source.equals(waitField)) { try { waitField.commitEdit(); } catch (java.text.ParseException x) { printer.printError(x.toString()); } if (waitField.isEditable()) { int wait = ((Number) waitField.getValue()).intValue(); directoryList.getDirectory(index).setWaitInterval(wait); } } else if (source.equals(checkField)) { try { checkField.commitEdit(); } catch (java.text.ParseException x) { printer.printError(x.toString()); } if (checkField.isEditable()) { int check = ((Number) checkField.getValue()).intValue(); directoryList.getDirectory(index).setInterval(check); } } }
public void setValue(Object o) { try { setText(sfmt.valueToString(o)); } catch (java.text.ParseException e) { setText("x" + e.toString()); // Should not happen } }
/** See if edit value is valid, put error message in buff. */ protected boolean _validate(StringBuffer buff) { String editValue = tf.getText().trim(); if (editValue.length() == 0) return true; // empty ok try { new TimeDuration(tf.getText()); return true; } catch (java.text.ParseException e) { buff.append(label).append(": ").append(e.getMessage()); return false; } }
public UpdateAssetGUI() { try { PluginMgrClient.init(); mclient = new MasterMgrClient(); queue = new QueueMgrClient(); plug = PluginMgrClient.getInstance(); log = LogMgr.getInstance(); pAssetManager = new TreeMap<String, AssetInfo>(); project = "lr"; charList = new TreeMap<String, String>(); setsList = new TreeMap<String, String>(); propsList = new TreeMap<String, String>(); potentialUpdates = new TreeSet<String>(); pSubstituteFields = new TreeMap<String, LinkedList<JBooleanField>>(); /* load the look-and-feel */ { try { SynthLookAndFeel synth = new SynthLookAndFeel(); synth.load( LookAndFeelLoader.class.getResourceAsStream("synth.xml"), LookAndFeelLoader.class); UIManager.setLookAndFeel(synth); } catch (java.text.ParseException ex) { log.log( LogMgr.Kind.Ops, LogMgr.Level.Severe, "Unable to parse the look-and-feel XML file (synth.xml):\n" + " " + ex.getMessage()); System.exit(1); } catch (UnsupportedLookAndFeelException ex) { log.log( LogMgr.Kind.Ops, LogMgr.Level.Severe, "Unable to load the Pipeline look-and-feel:\n" + " " + ex.getMessage()); System.exit(1); } } /* application wide UI settings */ { JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); } } catch (PipelineException ex) { ex.printStackTrace(); } // end try/catch } // end constructor
/** * 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. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jPanel1 = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jPanel4 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); n1 = new javax.swing.JTextField(); a1 = new javax.swing.JTextField(); ht1 = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); he1 = new javax.swing.JTextField(); ced = new javax.swing.JFormattedTextField(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Bienvenido a la lista de trabajadores"); setIconImage(new ImageIcon(getClass().getResource("/icon/libre.png")).getImage()); jPanel1.setBackground(new java.awt.Color(0, 0, 204)); jPanel1.setBorder( javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 5)); jPanel1.setPreferredSize(new java.awt.Dimension(400, 70)); jLabel5.setFont(new java.awt.Font("Freestyle Script", 1, 36)); // NOI18N jLabel5.setForeground(new java.awt.Color(255, 255, 255)); jLabel5.setText("*BIENVENIDO*\n"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel1Layout .createSequentialGroup() .addGap(130, 130, 130) .addComponent(jLabel5) .addContainerGap(192, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel1Layout .createSequentialGroup() .addContainerGap() .addComponent(jLabel5) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START); jPanel3.setBackground(new java.awt.Color(51, 153, 255)); jPanel3.setBorder( javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 5)); jPanel3.setPreferredSize(new java.awt.Dimension(400, 93)); jButton1.setBackground(new java.awt.Color(0, 0, 0)); jButton1.setFont(new java.awt.Font("Arial Narrow", 1, 14)); // NOI18N jButton1.setForeground(new java.awt.Color(0, 102, 102)); jButton1.setText("Agregar"); jButton1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setBackground(new java.awt.Color(0, 0, 0)); jButton2.setFont(new java.awt.Font("Arial Narrow", 1, 14)); // NOI18N jButton2.setForeground(new java.awt.Color(0, 102, 102)); jButton2.setText("Eliminar"); jButton3.setBackground(new java.awt.Color(0, 0, 0)); jButton3.setFont(new java.awt.Font("Arial Narrow", 1, 14)); // NOI18N jButton3.setForeground(new java.awt.Color(0, 102, 102)); jButton3.setText("Modificar"); jButton4.setFont(new java.awt.Font("Arial Narrow", 1, 14)); // NOI18N jButton4.setForeground(new java.awt.Color(0, 102, 102)); jButton4.setText("Regresar"); jButton4.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout .createSequentialGroup() .addGap(21, 21, 21) .addGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent( jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(75, 75, 75) .addGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(255, Short.MAX_VALUE))); jPanel3Layout.setVerticalGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel3Layout .createSequentialGroup() .addGap(22, 22, 22) .addGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton3) .addComponent(jButton2)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton4) .addComponent(jButton1)) .addContainerGap())); getContentPane().add(jPanel3, java.awt.BorderLayout.PAGE_END); jPanel4.setBackground(new java.awt.Color(51, 51, 255)); jPanel4.setBorder( javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 5)); jPanel4.setPreferredSize(new java.awt.Dimension(400, 150)); jPanel4.setLayout(new java.awt.GridBagLayout()); jLabel4.setFont(new java.awt.Font("Arial Narrow", 1, 18)); // NOI18N jLabel4.setForeground(new java.awt.Color(255, 255, 255)); jLabel4.setText("Horas trabajadas:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; jPanel4.add(jLabel4, gridBagConstraints); jLabel3.setFont(new java.awt.Font("Arial Narrow", 1, 18)); // NOI18N jLabel3.setForeground(new java.awt.Color(255, 255, 255)); jLabel3.setText("Cedula:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; jPanel4.add(jLabel3, gridBagConstraints); jLabel2.setFont(new java.awt.Font("Arial Narrow", 1, 18)); // NOI18N jLabel2.setForeground(new java.awt.Color(255, 255, 255)); jLabel2.setText("Apellidos:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; jPanel4.add(jLabel2, gridBagConstraints); jLabel1.setFont(new java.awt.Font("Arial Narrow", 1, 18)); // NOI18N jLabel1.setForeground(new java.awt.Color(255, 255, 255)); jLabel1.setText("Nombres:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; jPanel4.add(jLabel1, gridBagConstraints); n1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { n1ActionPerformed(evt); } }); n1.addKeyListener( new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { n1KeyTyped(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.ipadx = 190; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; jPanel4.add(n1, gridBagConstraints); a1.addKeyListener( new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { a1KeyTyped(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 3; gridBagConstraints.ipadx = 190; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; jPanel4.add(a1, gridBagConstraints); ht1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ht1ActionPerformed(evt); } }); ht1.addKeyListener( new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { ht1KeyTyped(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 6; gridBagConstraints.ipadx = 65; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; jPanel4.add(ht1, gridBagConstraints); jLabel6.setFont(new java.awt.Font("Arial Narrow", 1, 18)); // NOI18N jLabel6.setForeground(new java.awt.Color(255, 255, 255)); jLabel6.setText("Horas Extras:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 8; jPanel4.add(jLabel6, gridBagConstraints); he1.addKeyListener( new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { he1KeyTyped(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 8; gridBagConstraints.ipadx = 65; jPanel4.add(he1, gridBagConstraints); try { ced.setFormatterFactory( new javax.swing.text.DefaultFormatterFactory( new javax.swing.text.MaskFormatter("###-######-####U"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } ced.addKeyListener( new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { cedKeyTyped(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel4.add(ced, gridBagConstraints); getContentPane().add(jPanel4, java.awt.BorderLayout.CENTER); setBounds(0, 0, 539, 449); } // </editor-fold>//GEN-END:initComponents