public void initialize(Instrument instrument) {
    ExpireTimeSpinnerModel model = new ExpireTimeSpinnerModel(instrument);
    this.setModel(model);

    JFormattedTextField textField = ((DateEditor) this.getEditor()).getTextField();
    textField.setValue(model._value);
    textField.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {}

          public void focusLost(FocusEvent e) {
            ExpireTimeSpinnerModel model = (ExpireTimeSpinnerModel) getModel();
            JFormattedTextField textField = ((DateEditor) getEditor()).getTextField();
            try {
              DateTime newTime = DateTime.fromDate((Date) getValue());
              if (newTime.compareTo(model.getEndTime()) > 0) {
                textField.setValue(model.getEndTime());
              } else if (newTime.compareTo(model.getBeginTime()) < 0) {
                textField.setValue(model.getBeginTime());
              } else if (DeliveryHoliday.instance.isHoliday(newTime)) {
                textField.setValue(model.getNextAvaliableTime(newTime));
              }
            } catch (IllegalArgumentException exception) // the input maybe out of datetime range
            {
              textField.setValue(model.getEndTime());
            }
          }
        });
  }
Esempio n. 2
0
    /** Constructs cell editor. */
    public CellEditor() {
      super(new JFormattedTextField());
      final JFormattedTextField ftf = (JFormattedTextField) getComponent();

      // Set GUI behaviour of text field
      ftf.setValue(null);
      ftf.setHorizontalAlignment(JTextField.LEADING);
      ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

      // Set that one click on cell is enough for editing
      setClickCountToStart(1);

      // Special handling code for ENTER
      ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
      ftf.getActionMap()
          .put(
              "check",
              new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                  if (!ftf.isEditValid()) {
                    if (askEditOrRevert(ftf, null)) {
                      ftf.setValue(ftf.getValue());
                      ftf.postActionEvent();
                    }
                  } else
                    try {
                      ftf.commitEdit();
                      ftf.postActionEvent();
                    } catch (java.text.ParseException exc) {
                      // nothing to do
                    }
                }
              });
    }
Esempio n. 3
0
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   JFormattedTextField ftf = (JFormattedTextField) getComponent();
   ftf.setFormatterFactory(null);
   ftf.setValue(value);
   ftf.setFormatterFactory(formatterFactory);
   return super.getTableCellEditorComponent(table, value, isSelected, row, column);
 }
Esempio n. 4
0
  /** Create the frame */
  public DateTimer() {
    super();
    setTitle("v14 CountDown");
    getContentPane().setLayout(null);
    setBounds(100, 100, 500, 375);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JLabel finishtimeLabel = new JLabel();
    finishtimeLabel.setText("CountDown Time");
    finishtimeLabel.setBounds(10, 36, 119, 15);
    getContentPane().add(finishtimeLabel);
    finishtime =
        new JFormattedTextField(
            new DateFormatter(new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa", Locale.ENGLISH)));
    finishtime.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {}
        });

    finishtime.setValue(new Date());
    finishtime.setBounds(135, 34, 187, 19);
    getContentPane().add(finishtime);

    final JButton startButton = new JButton();
    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            startCount();
          }
        });
    startButton.setText("Start!!!");
    startButton.setBounds(334, 31, 111, 25);
    getContentPane().add(startButton);

    countLabel = new JLabel();
    countLabel.setHorizontalAlignment(SwingConstants.CENTER);
    countLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    countLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 14));
    countLabel.setBorder(new LineBorder(Color.black, 1, false));
    countLabel.setText("Countdown not Started");
    countLabel.setBounds(10, 162, 435, 47);
    getContentPane().add(countLabel);

    final JLabel credits = new JLabel();
    credits.setHorizontalAlignment(SwingConstants.RIGHT);
    credits.setText("");
    credits.setBounds(253, 328, 237, 15);
    getContentPane().add(credits);
  }
  public void init() {
    // 添加按钮
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);

    mainPanel.setLayout(new GridLayout(0, 3));
    mainWin.add(mainPanel, BorderLayout.CENTER);

    JFormattedTextField intField0 =
        new JFormattedTextField(
            new InternationalFormatter(NumberFormat.getIntegerInstance()) {
              protected DocumentFilter getDocumentFilter() {
                return new NumberFilter();
              }
            });
    intField0.setValue(100);
    addRow("只接受数字的文本框", intField0);

    JFormattedTextField intField1 = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField1.setValue(new Integer(100));
    // 添加输入校验器
    intField1.setInputVerifier(new FormattedTextFieldVerifier());
    addRow("带输入校验器的文本框", intField1);

    // 创建自定义格式器对象
    IPAddressFormatter ipFormatter = new IPAddressFormatter();
    ipFormatter.setOverwriteMode(false);
    // 以自定义格式器对象创建格式化文本框
    JFormattedTextField ipField = new JFormattedTextField(ipFormatter);
    ipField.setValue(new byte[] {(byte) 192, (byte) 168, 4, 1});
    addRow("IP地址格式", ipField);

    mainWin.add(buttonPanel, BorderLayout.SOUTH);
    mainWin.pack();
    mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainWin.setVisible(true);
  }
Esempio n. 6
0
  /**
   * Affiche les cases de la grille grâce à des JTextField pour les cases à remplir et des JLabel
   * pour les indices de somme dans le JPanel pan
   *
   * @param pan
   * @throws NumberFormatException
   */
  public void affichCase(JPanel pan) throws NumberFormatException {
    if (this.n != 0) {
      bloc.setValue(null);
      try {
        MaskFormatter format = new MaskFormatter("#");
        bloc = new JFormattedTextField(format);
      } catch (ParseException e2) {

      }
      pan.add(bloc);
      bloc.setHorizontalAlignment(SwingConstants.CENTER);
      bloc.addKeyListener(
          new KeyAdapter() {
            public void keyReleased(KeyEvent e) {
              try {
                if (Integer.valueOf(bloc.getText()) == n) {
                  Utilitaire.score -= juste;
                  juste = 1;
                  Utilitaire.score += juste;
                } else {
                  Utilitaire.score -= juste;
                  juste = 0;
                  Utilitaire.score += juste;
                }
              } catch (NumberFormatException e1) {

              }
            }
          });
    } else {
      Utilitaire.score -= juste;
      juste = 1;
      Utilitaire.score += juste;
      if (sX != 0)
        if (sY != 0) block.setText(String.format("%2d\\%2d", sX, sY));
        else block.setText(String.format("%2d\\  ", sX));
      else if (sY != 0) block.setText(String.format("  \\%2d", sY));

      block.setHorizontalAlignment(SwingConstants.CENTER);
      block.setBorder(null);
      block.setOpaque(true);
      block.setBackground(Color.BLACK);
      block.setForeground(Color.WHITE);
      pan.add(block);
    }
  }
Esempio n. 7
0
 @Override
 public boolean stopCellEditing() {
   JFormattedTextField ftf = (JFormattedTextField) getComponent();
   if (ftf.isEditValid()) {
     try {
       ftf.commitEdit();
     } catch (java.text.ParseException exc) {
       // nothing to do
     }
   } else {
     if (!askEditOrRevert(ftf, null)) {
       return false;
     } else {
       ftf.setValue(ftf.getValue());
     }
   }
   return super.stopCellEditing();
 }
Esempio n. 8
0
  public NewTaskFrame() throws SQLException {

    this.setModal(true);
    this.setTitle("Create Task"); // title of frame
    this.setSize(400, 350);
    this.setLayout(new BorderLayout()); // layout of frame

    JLabel task_id = new JLabel("ID:");
    JLabel task_name = new JLabel("Name:");
    JLabel task_desc = new JLabel("Description:");

    JLabel priority = new JLabel("Level of Priority:");
    JLabel duedate = new JLabel("Due Date (yyyy-mm-dd)");
    JLabel numberofdays = new JLabel("Number of days required:");
    JLabel skills_required = new JLabel("Skills Required:");

    Object[] id_possibilities = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
    StringBuffer generated_name = new StringBuffer("t");

    for (int i = 0; i < 6; ++i) {
      generated_name.append(
          id_possibilities[new java.util.Random().nextInt(id_possibilities.length)]);
    }

    task_idfield = new JTextField(generated_name.toString());
    taskname_field = new JTextField();
    taskdesc_field = new JTextArea();

    priority_checkbox = new JCheckBox("High", false);
    numberofdays_field = new JTextField();

    format = new SimpleDateFormat("dd-MM-yyyy"); // set format
    duedate_field = new JFormattedTextField(format);

    // set the duedatefield to tomorrow (since minimum task length = 1)
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.setTime(new Date()); // get current date
    cal.add(Calendar.DAY_OF_MONTH, 1); // add 1 to current date
    Date date = cal.getTime(); // get this date
    duedate_field.setValue(date); // set this date to the field

    // panel to hold labels and text fields
    JPanel labeltextpanel = new JPanel();
    labeltextpanel.setLayout(new GridLayout(7, 2));
    labeltextpanel.add(task_id);
    labeltextpanel.add(task_idfield);
    labeltextpanel.add(task_name);
    labeltextpanel.add(taskname_field);
    labeltextpanel.add(task_desc);
    labeltextpanel.add(taskdesc_field);
    labeltextpanel.add(priority);
    labeltextpanel.add(priority_checkbox);
    labeltextpanel.add(numberofdays);
    labeltextpanel.add(numberofdays_field);
    labeltextpanel.add(duedate);
    labeltextpanel.add(duedate_field);
    labeltextpanel.add(skills_required);

    this.getSkills();

    // main panel for frame including its layout
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(labeltextpanel, BorderLayout.CENTER);

    // buttons
    clear_button = new JButton("Clear");
    submit_button = new JButton("Submit");

    // add listeners to buttons
    clear_button.addActionListener(this);
    submit_button.addActionListener(this);

    // create panel for buttons and add buttons
    JPanel buttonpanel = new JPanel();
    buttonpanel.setLayout(new FlowLayout());
    buttonpanel.add(clear_button);
    buttonpanel.add(submit_button);

    JPanel checkbox_panel = new JPanel();
    checkbox_panel.setLayout(new FlowLayout());

    for (int i = 0; i < skill_list.size(); i++) {
      checkbox_panel.add(skill_list.get(i)); // make this panel flowlayout
    }

    scrollpane = new JScrollPane(checkbox_panel);
    scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(mainPanel, BorderLayout.CENTER);
    panel.add(scrollpane, BorderLayout.SOUTH);
    // add the main panel to main frame

    add(panel, BorderLayout.CENTER);
    add(buttonpanel, BorderLayout.SOUTH);

    this.setVisible(true);
  }
Esempio n. 9
0
  public MakeReservation() {
    new BorderLayout();

    standardRoom.setMnemonic(KeyEvent.VK_K);
    standardRoom.setActionCommand("Standard Room");
    standardRoom.setSelected(true);

    familyRoom.setMnemonic(KeyEvent.VK_F);
    familyRoom.setActionCommand("Family Room");

    suiteRoom.setMnemonic(KeyEvent.VK_S);
    suiteRoom.setActionCommand("Suite");

    // Add Booking Button
    ImageIcon bookRoomIcon = createImageIcon("images/book.png");
    bookRoom = new JButton("Book Room", bookRoomIcon);
    bookRoom.setVerticalTextPosition(AbstractButton.BOTTOM);
    bookRoom.setHorizontalTextPosition(AbstractButton.CENTER);
    bookRoom.setMnemonic(KeyEvent.VK_M);
    bookRoom.addActionListener(this);
    bookRoom.setActionCommand("book");

    // Group the radio buttons.
    group.add(standardRoom);
    group.add(familyRoom);
    group.add(suiteRoom);

    // Create the labels.
    nameLabel = new JLabel("Name: ");
    amountroomsLabel = new JLabel("How many rooms? ");
    checkoutdateLabel = new JLabel("Check-Out Date: ");
    checkindateLabel = new JLabel("Check-In Date: ");

    // Create the text fields and set them up.
    nameField = new JFormattedTextField();
    nameField.setColumns(10);

    amountroomsField = new JFormattedTextField(new Integer(1));
    amountroomsField.setValue(new Integer(1));
    amountroomsField.setColumns(10);

    // java.util.Date dt_checkin = new java.util.Date();
    LocalDate today = LocalDate.now();
    // java.text.SimpleDateFormat sdf_checkin = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkin = today.toString();
    checkindateField = new JFormattedTextField(currentDate_checkin);
    checkindateField.setColumns(10);

    // java.util.Date dt_checkout = new java.util.Date();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    // java.text.SimpleDateFormat sdf_checkout = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkout = tomorrow.toString();
    checkoutdateField = new JFormattedTextField(currentDate_checkout);
    checkoutdateField.setColumns(10);

    // Tell accessibility tools about label/textfield pairs.
    nameLabel.setLabelFor(nameField);
    amountroomsLabel.setLabelFor(amountroomsField);
    checkoutdateLabel.setLabelFor(checkoutdateField);
    checkindateLabel.setLabelFor(checkindateField);

    // Lay out the labels in a panel.
    JPanel labelPane1 = new JPanel(new GridLayout(0, 1));

    labelPane1.add(amountroomsLabel);

    JPanel labelPane3 = new JPanel(new GridLayout(0, 1));
    labelPane3.add(checkindateLabel);

    JPanel labelPane2 = new JPanel(new GridLayout(0, 1));
    labelPane2.add(checkoutdateLabel);

    JPanel labelPane4 = new JPanel(new GridLayout(0, 1));
    labelPane4.add(nameLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane1 = new JPanel(new GridLayout(0, 1));
    fieldPane1.add(amountroomsField);

    JPanel fieldPane3 = new JPanel(new GridLayout(0, 1));
    fieldPane3.add(checkindateField);

    JPanel fieldPane2 = new JPanel(new GridLayout(0, 1));
    fieldPane2.add(checkoutdateField);

    JPanel fieldPane4 = new JPanel(new GridLayout(0, 1));
    fieldPane4.add(nameField);

    // Put the radio buttons in a column in a panel.
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(standardRoom);
    radioPanel.add(familyRoom);
    radioPanel.add(suiteRoom);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane1, BorderLayout.LINE_START);
    add(fieldPane1, BorderLayout.LINE_END);
    add(labelPane3, BorderLayout.LINE_START);
    add(fieldPane3, BorderLayout.LINE_END);
    add(labelPane2, BorderLayout.LINE_START);
    add(fieldPane2, BorderLayout.LINE_END);
    add(labelPane4, BorderLayout.LINE_START);
    add(fieldPane4, BorderLayout.LINE_END);

    add(radioPanel, BorderLayout.LINE_END);
    add(bookRoom);
  }
  public FormatTestFrame() {
    JPanel buttonPanel = new JPanel();
    okButton = new JButton("Ok");
    buttonPanel.add(okButton);
    add(buttonPanel, BorderLayout.SOUTH);

    mainPanel = new JPanel();
    mainPanel.setLayout(new GridLayout(0, 3));
    add(mainPanel, BorderLayout.CENTER);

    JFormattedTextField intField = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField.setValue(new Integer(100));
    addRow("Number:", intField);

    JFormattedTextField intField2 = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField2.setValue(new Integer(100));
    intField2.setFocusLostBehavior(JFormattedTextField.COMMIT);
    addRow("Number (Commit behavior):", intField2);

    JFormattedTextField intField3 =
        new JFormattedTextField(
            new InternationalFormatter(NumberFormat.getIntegerInstance()) {
              protected DocumentFilter getDocumentFilter() {
                return filter;
              }
            });
    intField3.setValue(new Integer(100));
    addRow("Filtered Number", intField3);

    JFormattedTextField intField4 = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField4.setValue(new Integer(100));
    intField4.setInputVerifier(
        new InputVerifier() {
          public boolean verify(JComponent component) {
            JFormattedTextField field = (JFormattedTextField) component;
            return field.isEditValid();
          }
        });
    addRow("Verified Number:", intField4);

    JFormattedTextField currencyField = new JFormattedTextField(NumberFormat.getCurrencyInstance());
    currencyField.setValue(new Double(10));
    addRow("Currency:", currencyField);

    JFormattedTextField dateField = new JFormattedTextField(DateFormat.getDateInstance());
    dateField.setValue(new Date());
    addRow("Date (default):", dateField);

    DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT);
    format.setLenient(false);
    JFormattedTextField dateField2 = new JFormattedTextField(format);
    dateField2.setValue(new Date());
    addRow("Date (short, not lenient):", dateField2);

    try {
      DefaultFormatter formatter = new DefaultFormatter();
      formatter.setOverwriteMode(false);
      JFormattedTextField urlField = new JFormattedTextField(formatter);
      urlField.setValue(new URL("http://java.sun.com"));
      addRow("URL:", urlField);
    } catch (MalformedURLException ex) {
      ex.printStackTrace();
    }

    try {
      MaskFormatter formatter = new MaskFormatter("###-##-####");
      formatter.setPlaceholderCharacter('0');
      JFormattedTextField ssnField = new JFormattedTextField(formatter);
      ssnField.setValue("078-05-1120");
      addRow("SSN Mask:", ssnField);
    } catch (ParseException ex) {
      ex.printStackTrace();
    }

    JFormattedTextField ipField = new JFormattedTextField(new IPAddressFormatter());
    ipField.setValue(new byte[] {(byte) 130, 65, 86, 66});
    addRow("IP Address:", ipField);
    pack();
  }
Esempio n. 11
0
  public fileBackupProgram(JFrame frame) {
    super(new BorderLayout());
    this.frame = frame;

    errorDialog = new CustomDialog(frame, "Please enter a new name for the error log", this);
    errorDialog.pack();

    moveDialog = new CustomDialog(frame, "Please enter a new name for the move log", this);
    moveDialog.pack();

    printer = new FilePrinter();
    timers = new ArrayList<>();
    log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    JScrollPane logScrollPane = new JScrollPane(log);
    Object obj;
    copy = true;
    listModel = new DefaultListModel();
    // destListModel = new DefaultListModel();
    directoryList = new directoryStorage();

    // Create a file chooser
    fc = new JFileChooser();

    // Create the menu bar.
    menuBar = new JMenuBar();

    // Build the first menu.
    menu = new JMenu("File");
    menu.getAccessibleContext()
        .setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    editError = new JMenuItem("Save Error Log As...");
    editError
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the error log file");
    editError.addActionListener(new ErrorListener());
    menu.add(editError);

    editMove = new JMenuItem("Save Move Log As...");
    editMove
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the move log file");
    editMove.addActionListener(new MoveListener());
    menu.add(editMove);

    exit = new JMenuItem("Exit");
    exit.getAccessibleContext().setAccessibleDescription("Exit the Program");
    exit.addActionListener(new CloseListener());
    menu.add(exit);
    frame.setJMenuBar(menuBar);
    // Uncomment one of the following lines to try a different
    // file selection mode.  The first allows just directories
    // to be selected (and, at least in the Java look and feel,
    // shown).  The second allows both files and directories
    // to be selected.  If you leave these lines commented out,
    // then the default mode (FILES_ONLY) will be used.
    //
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    openButton = new JButton(openString);
    openButton.setActionCommand(openString);
    openButton.addActionListener(new OpenListener());

    destButton = new JButton(destString);
    destButton.setActionCommand(destString);
    destButton.addActionListener(new DestListener());

    // Create the save button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    saveButton = new JButton(saveString);
    saveButton.setActionCommand(saveString);
    saveButton.addActionListener(new SaveListener());

    URL imageURL = getClass().getResource(greenButtonIcon);
    ImageIcon greenSquare = new ImageIcon(imageURL);
    startButton = new JButton("Start", greenSquare);
    startButton.setSize(60, 20);
    startButton.setHorizontalTextPosition(AbstractButton.LEADING);
    startButton.setActionCommand("Start");
    startButton.addActionListener(new StartListener());

    imageURL = getClass().getResource(redButtonIcon);
    ImageIcon redSquare = new ImageIcon(imageURL);
    stopButton = new JButton("Stop", redSquare);
    stopButton.setSize(60, 20);
    stopButton.setHorizontalTextPosition(AbstractButton.LEADING);
    stopButton.setActionCommand("Stop");
    stopButton.addActionListener(new StopListener());

    copyButton = new JRadioButton("Copy");
    copyButton.setActionCommand("Copy");
    copyButton.setSelected(true);
    copyButton.addActionListener(new RadioListener());

    moveButton = new JRadioButton("Move");
    moveButton.setActionCommand("Move");
    moveButton.addActionListener(new RadioListener());

    ButtonGroup group = new ButtonGroup();
    group.add(copyButton);
    group.add(moveButton);

    // For layout purposes, put the buttons in a separate panel

    JPanel optionPanel = new JPanel();

    GroupLayout layout = new GroupLayout(optionPanel);
    optionPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout.createSequentialGroup().addComponent(copyButton).addComponent(moveButton));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(copyButton)
                    .addComponent(moveButton)));

    JPanel buttonPanel = new JPanel(); // use FlowLayout

    layout = new GroupLayout(buttonPanel);
    buttonPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(openButton)
                    .addComponent(optionPanel))
            .addComponent(destButton)
            .addComponent(startButton)
            .addComponent(stopButton)
        // .addComponent(saveButton)
        );
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(openButton)
                    .addComponent(destButton)
                    .addComponent(startButton)
                    .addComponent(stopButton)
                // .addComponent(saveButton)
                )
            .addComponent(optionPanel));

    buttonPanel.add(optionPanel);
    /*
    buttonPanel.add(openButton);
    buttonPanel.add(destButton);
    buttonPanel.add(startButton);
    buttonPanel.add(stopButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(listLabel);
    buttonPanel.add(copyButton);
    buttonPanel.add(moveButton);
    */
    destButton.setEnabled(false);
    startButton.setEnabled(false);
    stopButton.setEnabled(false);

    // Add the buttons and the log to this panel.

    // add(logScrollPane, BorderLayout.CENTER);

    JLabel listLabel = new JLabel("Monitored Directory:");
    listLabel.setLabelFor(list);

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(8);
    JScrollPane listScrollPane = new JScrollPane(list);
    JPanel listPane = new JPanel();
    listPane.setLayout(new BorderLayout());

    listPane.add(listLabel, BorderLayout.PAGE_START);
    listPane.add(listScrollPane, BorderLayout.CENTER);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    // monitored, destination, waitInt, check

    destination = new JLabel("Destination Directory: ");

    waitField = new JFormattedTextField();
    // waitField.setValue(240);
    waitField.setEditable(false);
    waitField.addPropertyChangeListener(new FormattedTextListener());

    waitInt = new JLabel("Wait Interval (in minutes)");
    // waitInt.setLabelFor(waitField);

    checkField = new JFormattedTextField();
    checkField.setSize(1, 10);
    // checkField.setValue(60);
    checkField.setEditable(false);
    checkField.addPropertyChangeListener(new FormattedTextListener());

    check = new JLabel("Check Interval (in minutes)");
    // check.setLabelFor(checkField);

    fireButton = new JButton(fireString);
    fireButton.setActionCommand(fireString);
    fireButton.addActionListener(new FireListener());

    JPanel fieldPane = new JPanel();
    // fieldPane.add(destField);
    layout = new GroupLayout(fieldPane);
    fieldPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitInt)
                    .addComponent(check))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitField, 60, 60, 60)
                    .addComponent(checkField, 60, 60, 60)));

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(waitInt)
                    .addComponent(waitField))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(check)
                    .addComponent(checkField)));

    JPanel labelPane = new JPanel();

    labelPane.setLayout(new BorderLayout());

    labelPane.add(destination, BorderLayout.PAGE_START);
    labelPane.add(fieldPane, BorderLayout.CENTER);

    layout = new GroupLayout(labelPane);
    labelPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(destination)
                    .addComponent(fieldPane)));

    layout.setVerticalGroup(
        layout.createSequentialGroup().addComponent(destination).addComponent(fieldPane));
    // labelPane.add(destination);
    // labelPane.add(fieldPane);

    try {
      // Read from disk using FileInputStream
      FileInputStream f_in = new FileInputStream(LOG_DIRECTORY + "\\save.data");

      // Read object using ObjectInputStream
      ObjectInputStream obj_in = new ObjectInputStream(f_in);

      // Read an object
      directoryList = (directoryStorage) obj_in.readObject();
      ERROR_LOG_NAME = (String) obj_in.readObject();
      MOVE_LOG_NAME = (String) obj_in.readObject();

      if (ERROR_LOG_NAME instanceof String) {
        printer.changeErrorLogName(ERROR_LOG_NAME);
      }

      if (MOVE_LOG_NAME instanceof String) {
        printer.changeMoveLogName(MOVE_LOG_NAME);
      }

      if (directoryList instanceof directoryStorage) {
        System.out.println("found object");
        // directoryList = (directoryStorage) obj;

        Iterator<Directory> directories = directoryList.getDirectories();
        Directory d;
        while (directories.hasNext()) {
          d = directories.next();

          try {
            listModel.addElement(d.getDirectory().toRealPath());
          } catch (IOException x) {
            printer.printError(x.toString());
          }

          int index = list.getSelectedIndex();
          if (index == -1) {
            list.setSelectedIndex(0);
          }

          index = list.getSelectedIndex();
          Directory dir = directoryList.getDirectory(index);

          destButton.setEnabled(true);
          checkField.setValue(dir.getInterval());
          waitField.setValue(dir.getWaitInterval());
          checkField.setEditable(true);
          waitField.setEditable(true);

          // directoryList.addNewDirectory(d);
          // try {
          // listModel.addElement(d.getDirectory().toString());
          // } catch (IOException x) {
          // printer.printError(x.toString());
          // }

          // timer = new Timer();
          // timer.schedule(new CopyTask(d.directory, d.destination, d.getWaitInterval(), printer,
          // d.copy), 0, d.getInterval());
        }

      } else {
        System.out.println("did not find object");
      }
      obj_in.close();
    } catch (ClassNotFoundException x) {
      printer.printError(x.getLocalizedMessage());
      System.err.format("Unable to read");
    } catch (IOException y) {
      printer.printError(y.getLocalizedMessage());
    }

    // Layout the text fields in a panel.

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(buttonPanel, BorderLayout.PAGE_START);
    add(listPane, BorderLayout.LINE_START);
    // add(destListScrollPane, BorderLayout.CENTER);

    add(fieldPane, BorderLayout.LINE_END);
    add(labelPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
  }