Esempio n. 1
0
 /**
  * A change in the text fields.
  *
  * @param e the document event.
  */
 private void documentChanged(DocumentEvent e) {
   if (e.getDocument().equals(fileCountField.getDocument())) {
     // set file count only if its un integer
     try {
       int newFileCount = Integer.valueOf(fileCountField.getText());
       fileCountField.setForeground(Color.black);
       LoggingUtilsActivator.getPacketLoggingService()
           .getConfiguration()
           .setLogfileCount(newFileCount);
     } catch (Throwable t) {
       fileCountField.setForeground(Color.red);
     }
   } else if (e.getDocument().equals(fileSizeField.getDocument())) {
     // set file size only if its un integer
     try {
       int newFileSize = Integer.valueOf(fileSizeField.getText());
       fileSizeField.setForeground(Color.black);
       LoggingUtilsActivator.getPacketLoggingService()
           .getConfiguration()
           .setLimit(newFileSize * 1000);
     } catch (Throwable t) {
       fileSizeField.setForeground(Color.red);
     }
   }
 }
Esempio n. 2
0
 public void insertUpdate(DocumentEvent e) {
   Document doc = e.getDocument();
   try {
     prop.set(doc.getText(0, doc.getLength()));
   } catch (BadLocationException b) {
     // Once again, no idea what this is supposed to be.
     // I don't think I like this interface much :-(.
     System.out.println(b);
   }
 }
 void updateTheLabel(DocumentEvent e) {
   Document doc = (Document) e.getDocument();
   String text = null;
   try {
     text = doc.getText(0, doc.getLength());
     doc = null;
   } catch (BadLocationException ex) {
     text = null;
   }
   if (text != null) {
     try {
       double number = Double.parseDouble(text);
       if (number > 1) {
         label.setText(labelPair.getPlural());
       } else {
         label.setText(labelPair.getSingular());
       }
     } catch (NumberFormatException ex) {
       // Do nothing
     } finally {
       text = null;
     }
   }
 }