Example #1
0
    public TimeOkJPanel() {

      /* set up the controls */
      // checkbox for Java default/non-default format
      useJavaDefaultFormatChk.setSelected(useJavaDefaultFormat);
      useJavaDefaultFormatChk.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              dateFormatTypeDrop.setEnabled(!useJavaDefaultFormatChk.isSelected());
              dateFormatTypeDropLabel.setEnabled(!useJavaDefaultFormatChk.isSelected());
              lenientChk.setEnabled(!useJavaDefaultFormatChk.isSelected());
            }
          });

      // Combo box for read-all/read-part of blob
      dateFormatTypeDrop = new DateFormatTypeCombo();
      dateFormatTypeDrop.setSelectedIndex(localeFormat);

      // lenient checkbox
      lenientChk.setSelected(lenient);

      // handle cross-connection between fields
      dateFormatTypeDrop.setEnabled(!useJavaDefaultFormatChk.isSelected());
      dateFormatTypeDropLabel.setEnabled(!useJavaDefaultFormatChk.isSelected());
      lenientChk.setEnabled(!useJavaDefaultFormatChk.isSelected());

      /*
       * Create the panel and add the GUI items to it
       */

      setLayout(new GridBagLayout());

      // i18n[dataTypeTime.typeTime=Time   (SQL type 92)]
      setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("dataTypeTime.typeTime")));
      final GridBagConstraints gbc = new GridBagConstraints();
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets = new Insets(4, 4, 4, 4);
      gbc.anchor = GridBagConstraints.WEST;

      gbc.gridx = 0;
      gbc.gridy = 0;

      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(useJavaDefaultFormatChk, gbc);

      gbc.gridwidth = 1;
      gbc.gridx = 0;
      ++gbc.gridy;
      add(dateFormatTypeDropLabel, gbc);

      ++gbc.gridx;
      add(dateFormatTypeDrop, gbc);

      gbc.gridx = 0;
      ++gbc.gridy;
      add(lenientChk, gbc);
    } // end of constructor for inner class
Example #2
0
    /** User has clicked OK in the surrounding JPanel, so save the current state of all variables */
    public void ok() {
      // get the values from the controls and set them in the static properties
      useJavaDefaultFormat = useJavaDefaultFormatChk.isSelected();
      DTProperties.put(
          thisClassName, "useJavaDefaultFormat", Boolean.valueOf(useJavaDefaultFormat).toString());

      localeFormat = dateFormatTypeDrop.getValue();
      dateFormat = new ThreadSafeDateFormat(localeFormat, true); // lenient is set next
      DTProperties.put(thisClassName, "localeFormat", Integer.toString(localeFormat));

      lenient = lenientChk.isSelected();
      dateFormat.setLenient(lenient);
      DTProperties.put(thisClassName, "lenient", Boolean.valueOf(lenient).toString());

      initDateFormat(localeFormat, lenient);
    }