Print this page
    
4719 update gate build environment to [open]jdk7 4742 update manifests for javadoc7 4743 Fix deprecated /usr/j2se usage in slp and remove from filesystem(5) manpage 4744 remove traces of /var/sadm/system/admin/default_java Reviewed by: Dan McDonald <danmcd@omniti.com> Reviewed by: Richard Lowe <richlowe@richlowe.net>
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/cmd/krb5/kadmin/gui/dchanger/DateTimeDialog.java
          +++ new/usr/src/cmd/krb5/kadmin/gui/dchanger/DateTimeDialog.java
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License, Version 1.0 only
   6    6   * (the "License").  You may not use this file except in compliance
   7    7   * with the License.
   8    8   *
   9    9   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10   10   * or http://www.opensolaris.org/os/licensing.
  11   11   * See the License for the specific language governing permissions
  12   12   * and limitations under the License.
  
    | 
      ↓ open down ↓ | 
    12 lines elided | 
    
      ↑ open up ↑ | 
  
  13   13   *
  14   14   * When distributing Covered Code, include this CDDL HEADER in each
  15   15   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23      - * ident        "%Z%%M% %I%     %E% SMI"
  24      - *
  25   23   * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
  26   24   * All rights reserved.
  27   25   */
  28   26  
  29   27  import java.awt.*;
  30   28  import java.awt.event.*;
  31   29  import java.text.*;
  32   30  import java.util.*;
  33   31  
  34   32  /**
  35   33   * This class creates a dialog box that helps the user enter date and
  36   34   * time with mouse clicks.  The dialog box need only be created
  
    | 
      ↓ open down ↓ | 
    2 lines elided | 
    
      ↑ open up ↑ | 
  
  37   35   * once. The Ok and Cancel buttons merely call setVisible with an
  38   36   *  argument of false.
  39   37   */
  40   38  
  41   39  // The layout will consist of 3 panels: topPanel contains the
  42   40  // different labels and fields. middlePanel contains the buttons
  43   41  // midnight and now. bottomPanel contains the buttons ok, cancel and
  44   42  // help. The last two panels are separated by a LineSeparator.
  45   43  
  46   44  public class DateTimeDialog extends Dialog {
  47      -  
       45 +
  48   46      private boolean save;
  49   47  
  50   48      private Frame parent;
  51      -  
       49 +
  52   50      private DCPanel dateDCPanel;
  53   51      private DCPanel yearDCPanel;
  54   52      private DCPanel hourDCPanel;
  55   53      private DCPanel minuteDCPanel;
  56   54      private DCPanel secondDCPanel;
  57      -  
       55 +
  58   56      private Choice month;
  59      -  
       57 +
  60   58      private DCCircularTextField date;
  61   59      private DCCircularTextField hour;
  62   60      private DCCircularTextField second;
  63   61      private DCCircularTextField minute;
  64   62      private DCTextField year;
  65      -  
       63 +
  66   64      private Button ok;
  67   65      private Button cancel;
  68   66      private Button help;
  69   67      private Button now;
  70   68      private Button midnight;
  71   69  
  72   70      private HelpDialog hd = null;
  73      -  
       71 +
  74   72      private Panel topPanel;
  75   73      private Panel middlePanel;
  76   74      private Panel bottomPanel;
  77      -  
       75 +
  78   76      private GregorianCalendar calendar = null;
  79   77      private static int MONTH_LEN[] = {31, 28, 31, 30, 31, 30, 31,
  80      -                                      31, 30, 31, 30, 31};
       78 +                                    31, 30, 31, 30, 31};
  81   79      private static DateFormat df =
  82   80      DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
  83   81                                   DateFormat.MEDIUM);
  84   82      private static Toolkit toolkit = Toolkit.getDefaultToolkit();
  85      -  
       83 +
  86   84    // For I18N
  87   85      private static ResourceBundle rb =
  88      -    ResourceBundle.getBundle("GuiResource" /* NOI18N */); 
       86 +    ResourceBundle.getBundle("GuiResource" /* NOI18N */);
  89   87      private static ResourceBundle hrb =
  90      -    ResourceBundle.getBundle("HelpData" /* NOI18N */); 
       88 +    ResourceBundle.getBundle("HelpData" /* NOI18N */);
  91   89  
  92   90      /**
  93   91       * Constructor that lays out the componeents and sets the different
  94      -     * event handlers. 
       92 +     * event handlers.
  95   93       */
  96   94      public DateTimeDialog(Frame parent, Color background, Color foreground) {
  97   95      super(parent, getString("SEAM Date/Time Helper"), true);
  98      -    
       96 +
  99   97      this.parent = parent;
 100   98  
 101   99      setLayout(new GridBagLayout());
 102  100      addLabels();
 103  101      addFields(background, foreground);
 104  102      addDCPanels();
 105  103      addButtons();
 106  104      addFocusListeners();
 107  105      setCurrentTime();
 108  106      setSize(250, 300);
 109  107      setResizable(false);
 110      -    
      108 +
 111  109      addWindowListener(new DCWindowListener());
 112      -    //      initializeFocusOnTextField();
      110 +    //      initializeFocusOnTextField();
 113  111      }
 114  112  
 115  113      /**
 116  114       * Adds the labels only
 117  115       */
 118  116      private void addLabels() {
 119      -    
      117 +
 120  118      GridBagConstraints gbc = new GridBagConstraints();
 121  119      gbc.weighty = 1;
 122      -    
      120 +
 123  121      topPanel = new Panel();
 124  122      topPanel.setLayout(new GridBagLayout());
 125      -    gbc.gridwidth = GridBagConstraints.REMAINDER;    
      123 +    gbc.gridwidth = GridBagConstraints.REMAINDER;
 126  124      gbc.fill = GridBagConstraints.BOTH;
 127  125      gbc.anchor = GridBagConstraints.CENTER;
 128  126      gbc.gridx = 0;
 129  127      gbc.gridy = 0;
 130  128      add(topPanel, gbc);
 131      -    
      129 +
 132  130      gbc.fill = GridBagConstraints.NONE;
 133  131      gbc.anchor = GridBagConstraints.EAST;
 134  132      gbc.gridx = 0;
 135  133      gbc.gridwidth = 1;
 136      -    
      134 +
 137  135      gbc.gridy = 0;
 138  136      topPanel.add(new Label(getString("Month")), gbc);
 139      -    
      137 +
 140  138      gbc.gridy = 1;
 141  139      topPanel.add(new Label(getString("Date")), gbc);
 142      -    
      140 +
 143  141      gbc.gridy = 2;
 144  142      topPanel.add(new Label(getString("Year")), gbc);
 145      -    
      143 +
 146  144      gbc.gridy = 3;
 147  145      topPanel.add(new Label(getString("Hour")), gbc);
 148      -    
      146 +
 149  147      gbc.gridy = 4;
 150  148      topPanel.add(new Label(getString("Minute")), gbc);
 151      -    
      149 +
 152  150      gbc.gridy = 5;
 153  151      topPanel.add(new Label(getString("Second")), gbc);
 154  152      }
 155      -  
      153 +
 156  154      /**
 157  155       * Adds the fields that will store the month, year, date, hour,
 158  156       * minute and second.
 159  157       */
 160  158      private void addFields(Color background, Color foreground) {
 161      -    
      159 +
 162  160      GridBagConstraints gbc = new GridBagConstraints();
 163  161      gbc.weighty = 1;
 164      -    
      162 +
 165  163      month = new Choice();
 166  164      initializeMonth();
 167      -    
      165 +
 168  166      date = new DCCircularTextField("1", 2);
 169  167      date.setMinimum(1);
 170  168      date.setBackground(background);
 171  169      date.setForeground(foreground);
 172  170  
 173  171      hour = new DCCircularTextField("00", 2);
 174  172      hour.setMaximum(23);
 175  173      hour.setBackground(background);
 176  174      hour.setForeground(foreground);
 177  175      minute = new DCCircularTextField("00", 2);
 178  176      minute.setBackground(background);
 179  177      minute.setForeground(foreground);
 180  178      second = new DCCircularTextField("00", 2);
 181  179      second.setBackground(background);
 182  180      second.setForeground(foreground);
 183      -    
      181 +
 184  182      year  = new DCTextField("2000", 4);
 185  183      year.setBackground(background);
 186  184      year.setForeground(foreground);
 187      -    
      185 +
 188  186      Panel tempPanel = new Panel();
 189  187      tempPanel.add(month);
 190  188      gbc.gridwidth = GridBagConstraints.REMAINDER;
 191  189      gbc.fill = GridBagConstraints.HORIZONTAL;
 192  190      gbc.anchor = GridBagConstraints.WEST;
 193  191      gbc.gridx = 1;
 194  192      gbc.gridy = 0;
 195  193      topPanel.add(tempPanel, gbc);
 196      -    
 197      -    
      194 +
      195 +
 198  196      // Remaining fields are in topPanel
 199  197      gbc.gridwidth = 1;
 200  198      gbc.fill = GridBagConstraints.NONE;
 201  199      gbc.gridx = 1;
 202      -    
      200 +
 203  201      gbc.gridy = 1;
 204  202      topPanel.add(date, gbc);
 205      -    
      203 +
 206  204      gbc.gridy = 2;
 207  205      topPanel.add(year, gbc);
 208      -    
      206 +
 209  207      gbc.gridy = 3;
 210  208      topPanel.add(hour, gbc);
 211      -    
      209 +
 212  210      gbc.gridy = 4;
 213  211      topPanel.add(minute, gbc);
 214      -    
      212 +
 215  213      gbc.gridy = 5;
 216  214      topPanel.add(second, gbc);
 217      -    
      215 +
 218  216      }
 219  217  
 220  218    // Adds the panels with the +/- buttons for each DCField
 221  219      private void addDCPanels() {
 222      -    
      220 +
 223  221      GridBagConstraints gbc = new GridBagConstraints();
 224  222      gbc.weighty = 1;
 225      -    
      223 +
 226  224      gbc.gridx = 2;
 227  225      gbc.gridwidth = GridBagConstraints.REMAINDER;
 228  226      gbc.gridheight = 1;
 229  227      gbc.fill = GridBagConstraints.NONE;
 230      -    
      228 +
 231  229      dateDCPanel = new DCPanel();
 232  230      yearDCPanel = new DCPanel();
 233  231      hourDCPanel = new DCPanel();
 234  232      minuteDCPanel = new DCPanel();
 235  233      secondDCPanel = new DCPanel();
 236      -    
      234 +
 237  235      gbc.gridy = 1;
 238  236      topPanel.add(dateDCPanel, gbc);
 239      -    
      237 +
 240  238      gbc.gridy = GridBagConstraints.RELATIVE;
 241  239      topPanel.add(yearDCPanel, gbc);
 242  240      topPanel.add(hourDCPanel, gbc);
 243  241      topPanel.add(minuteDCPanel, gbc);
 244  242      topPanel.add(secondDCPanel, gbc);
 245      -    
      243 +
 246  244      dateDCPanel.setListener(date);
 247  245      yearDCPanel.setListener(year);
 248  246      hourDCPanel.setListener(hour);
 249  247      minuteDCPanel.setListener(minute);
 250  248      secondDCPanel.setListener(second);
 251      -    
      249 +
 252  250      }
 253  251  
 254  252  
 255  253      /**
 256  254       * Sets the strings in the month pull-down menu. Also adds a listener
 257  255       * that will modify the maximum date allowed depending on the month.
 258  256       */
 259  257      private void initializeMonth() {
 260  258      DateFormatSymbols dfSymbols = new DateFormatSymbols();
 261  259      String[] monthStrings = dfSymbols.getMonths();
 262      -    
 263      -        month.removeAll();
 264      -    
 265      -        for (int i = 0; i < monthStrings.length; i++) {
      260 +
      261 +        month.removeAll();
      262 +
      263 +        for (int i = 0; i < monthStrings.length; i++) {
 266  264          month.add(monthStrings[i]);
 267      -        }
      265 +        }
 268  266  
 269      -        month.addItemListener(new DCMonthChangeListener());
      267 +        month.addItemListener(new DCMonthChangeListener());
 270  268      }
 271  269  
 272  270    // Adds all the buttons
 273  271      private void addButtons() {
 274  272  
 275      -        GridBagConstraints gbc = new GridBagConstraints();
 276      -        gbc.weighty = 1;
      273 +        GridBagConstraints gbc = new GridBagConstraints();
      274 +        gbc.weighty = 1;
 277  275  
 278  276  
 279      -        middlePanel = new Panel();
 280      -        now  = new Button(getString("Now"));
 281      -        midnight        = new Button(getString("Midnight"));
 282      -        middlePanel.add(midnight);
 283      -        middlePanel.add(now);
 284      -        gbc.fill = GridBagConstraints.HORIZONTAL;
 285      -        gbc.gridwidth = GridBagConstraints.REMAINDER;
 286      -        gbc.gridx = 0;
 287      -        gbc.gridy = 1;
 288      -        add(middlePanel, gbc);
      277 +        middlePanel = new Panel();
      278 +        now  = new Button(getString("Now"));
      279 +        midnight        = new Button(getString("Midnight"));
      280 +        middlePanel.add(midnight);
      281 +        middlePanel.add(now);
      282 +        gbc.fill = GridBagConstraints.HORIZONTAL;
      283 +        gbc.gridwidth = GridBagConstraints.REMAINDER;
      284 +        gbc.gridx = 0;
      285 +        gbc.gridy = 1;
      286 +        add(middlePanel, gbc);
 289  287  
 290      -        gbc.gridwidth = GridBagConstraints.REMAINDER;
 291      -        gbc.gridheight = 1;
 292      -        gbc.fill = GridBagConstraints.BOTH;
 293      -        gbc.gridx = 0;
 294      -        gbc.gridy = 2;
 295      -        add(new LineSeparator(), gbc);
      288 +        gbc.gridwidth = GridBagConstraints.REMAINDER;
      289 +        gbc.gridheight = 1;
      290 +        gbc.fill = GridBagConstraints.BOTH;
      291 +        gbc.gridx = 0;
      292 +        gbc.gridy = 2;
      293 +        add(new LineSeparator(), gbc);
 296  294  
 297      -        bottomPanel = new Panel();
 298      -        ok = new Button(getString("OK"));
 299      -        cancel =        new Button(getString("Cancel"));
 300      -        help = new Button(getString("Help"));
 301      -        bottomPanel.add(ok);
 302      -        bottomPanel.add(cancel);
 303      -        bottomPanel.add(help);
 304      -        gbc.fill = GridBagConstraints.HORIZONTAL;
 305      -        gbc.gridwidth = GridBagConstraints.REMAINDER;
 306      -        gbc.gridx = 0;
 307      -        gbc.gridy = 3;
 308      -        add(bottomPanel, gbc);
      295 +        bottomPanel = new Panel();
      296 +        ok = new Button(getString("OK"));
      297 +        cancel =        new Button(getString("Cancel"));
      298 +        help = new Button(getString("Help"));
      299 +        bottomPanel.add(ok);
      300 +        bottomPanel.add(cancel);
      301 +        bottomPanel.add(help);
      302 +        gbc.fill = GridBagConstraints.HORIZONTAL;
      303 +        gbc.gridwidth = GridBagConstraints.REMAINDER;
      304 +        gbc.gridx = 0;
      305 +        gbc.gridy = 3;
      306 +        add(bottomPanel, gbc);
 309  307  
 310      -        DCButtonListener bl = new DCButtonListener();
 311      -        ok.addActionListener(bl);
 312      -        cancel.addActionListener(bl);
 313      -        help.addActionListener(bl);
 314      -        now.addActionListener(bl);
 315      -        midnight.addActionListener(bl);
      308 +        DCButtonListener bl = new DCButtonListener();
      309 +        ok.addActionListener(bl);
      310 +        cancel.addActionListener(bl);
      311 +        help.addActionListener(bl);
      312 +        now.addActionListener(bl);
      313 +        midnight.addActionListener(bl);
 316  314  
 317  315      }
 318  316  
 319  317      /**
 320  318       * Adds a listener to all the text fields so that when they go out
 321  319       * of focus (by tab or clicking), their values are checked for
 322  320       * errors.
 323  321       */
 324  322      private void addFocusListeners() {
 325  323      FocusListener fl = new DCFocusListener();
 326  324      date.addFocusListener(fl);
  
    | 
      ↓ open down ↓ | 
    1 lines elided | 
    
      ↑ open up ↑ | 
  
 327  325      year.addFocusListener(fl);
 328  326      hour.addFocusListener(fl);
 329  327      minute.addFocusListener(fl);
 330  328      second.addFocusListener(fl);
 331  329      }
 332  330  
 333  331      /**
 334  332       * Closes (hides) the dialog box when the user is done
 335  333       * @param save true if the box is being dismissed by clicking on
 336  334       * "ok" and the user wants to retain the modified value, false
 337      -     * otherwise. 
      335 +     * otherwise.
 338  336       */
 339  337      private void dateTimeDialogClose(boolean save) {
 340      -        if (save == true) {
      338 +        if (save == true) {
 341  339          if (!updateFromGui())
 342  340             return;
 343  341      }
 344  342      this.save = save;
 345  343      setVisible(false);
 346  344      }
 347  345  
 348  346      /**
 349  347       * Checks to see is all text fields contain valid values.
 350  348       * @return true if all are valid, false otherwise.
 351  349       */
 352  350      private boolean updateFromGui() {
 353      -        return (checkErrorAndSet(date) && checkErrorAndSet(year) &&
 354      -                checkErrorAndSet(hour) && checkErrorAndSet(minute) &&
 355      -                checkErrorAndSet(second));
      351 +        return (checkErrorAndSet(date) && checkErrorAndSet(year) &&
      352 +                checkErrorAndSet(hour) && checkErrorAndSet(minute) &&
      353 +                checkErrorAndSet(second));
 356  354      }
 357  355  
 358  356      /**
 359  357       * Checks the value stored as text in the field and sets its numeric
 360  358       * value to that if it is legitimate.
 361  359       * @return true if the value was legitimate and got set, false
 362  360       * otherwise.
 363  361       */
 364  362      private boolean checkErrorAndSet(DCTextField tf) {
 365      -        int i = 0;
 366      -        boolean errorState = false;
 367      -        try {
      363 +        int i = 0;
      364 +        boolean errorState = false;
      365 +        try {
 368  366          i = new Integer(tf.getText().trim()).intValue();
 369  367          errorState = !tf.checkValue(i);
 370      -        } catch (NumberFormatException e2) {
      368 +        } catch (NumberFormatException e2) {
 371  369          errorState =  true;
 372      -        }       
 373      -        if (errorState) {
      370 +        }
      371 +        if (errorState) {
 374  372          tf.selectAll();
 375  373          toolkit.beep();
 376      -        }
 377      -        else
      374 +        }
      375 +        else
 378  376          tf.setValue(i);
 379      -        return !errorState;
      377 +        return !errorState;
 380  378      }
 381  379  
 382  380      /**
 383  381       * Checks if the user requested that the value in this
 384  382       * DateTimeDialog be used e.g., by clicking on "Ok" instead of
 385  383       * "Cancel."
 386  384       * @return true if the user wants to save the value in the
 387  385       * DateTimeDialog, false otherwise.
 388  386       */
 389  387  
 390  388      public boolean isSaved() {
 391      -        return save;
      389 +        return save;
 392  390      }
 393  391  
 394  392      /**
 395  393       * Sets the date and time in fields to the current date and time.
 396  394       */
 397  395      public void setCurrentTime() {
 398      -        setDate(new Date());
      396 +        setDate(new Date());
 399  397      }
 400  398  
 401  399      /**
 402  400       * Sets the current date of the DateTimeDialog and updates the gui
 403      -     *   components to reflect that.
      401 +     *   components to reflect that.
 404  402       * @param date the Date to set it to.
 405  403       */
 406  404      public void setDate(Date newDate) {
 407      -        calendar = new GregorianCalendar();
 408      -        calendar.setTime(newDate);
      405 +        calendar = new GregorianCalendar();
      406 +        calendar.setTime(newDate);
 409  407  
 410  408      // update gui components now
 411  409  
 412  410      year.setValue(calendar.get(Calendar.YEAR));
 413  411      month.select(calendar.get(Calendar.MONTH));
 414  412      date.setValue(calendar.get(Calendar.DATE));
 415      -    
      413 +
 416  414      // Make sure the date is in the valid range for the given month
 417  415      fixDateField();
 418      -    
      416 +
 419  417      hour.setValue(calendar.get(Calendar.HOUR_OF_DAY));
 420  418      minute.setValue(calendar.get(Calendar.MINUTE));
 421  419      second.setValue(calendar.get(Calendar.SECOND));
 422  420  
 423  421      }
 424  422  
 425  423      /**
 426  424       * Set the time fields to midnight, i.e., clears them.
 427  425       */
 428  426      private void setMidnight() {
 429  427              hour.setValue(0);
 430  428              minute.setValue(0);
 431  429              second.setValue(0);
 432  430      }
 433  431  
 434  432      /**
 435  433       * Make sure the date does not exceed the maximum allowable value
 436  434       * for the currently selected month.
 437  435       */
 438  436      private void fixDateField() {
 439      -        int monthIndex = month.getSelectedIndex();
 440      -        int max = MONTH_LEN[monthIndex];
 441      -        date.setMaximum(calendar.isLeapYear(year.getValue()) &&
 442      -                monthIndex == 1 ? max + 1 : max);
      437 +        int monthIndex = month.getSelectedIndex();
      438 +        int max = MONTH_LEN[monthIndex];
      439 +        date.setMaximum(calendar.isLeapYear(year.getValue()) &&
      440 +                monthIndex == 1 ? max + 1 : max);
 443  441      }
 444      -    
      442 +
 445  443    // * **********************************************
 446      -  //     I N N E R    C L A S S E S   F O L L O W
      444 +  //     I N N E R    C L A S S E S   F O L L O W
 447  445    // ***********************************************
 448      -    
      446 +
 449  447      /**
 450  448       * Listener for closing the dialog box through the window close
 451  449       * menu.
 452  450       */
 453  451      private class DCWindowListener extends WindowAdapter {
 454  452      public  void windowClosing(WindowEvent e) {
 455      -        dateTimeDialogClose(false);
 456      -        }
      453 +        dateTimeDialogClose(false);
      454 +        }
 457  455      }
 458      -  
      456 +
 459  457      /**
 460  458       * Listener for any change in the month selected through the
 461  459       * pull down menu
 462  460       */
 463  461      private class DCMonthChangeListener implements ItemListener {
 464  462      public void itemStateChanged(ItemEvent e) {
 465      -        fixDateField();
      463 +        fixDateField();
 466  464      }
 467  465      }
 468  466  
 469  467      /**
 470  468       * Listener for all the buttons. The listener is shared for the sake
 471  469       * of reducing the number of overall listeners.
 472  470       * TBD: I18N the help
 473  471       */
 474  472      private class DCButtonListener implements ActionListener {
 475  473      public void actionPerformed(ActionEvent e) {
 476      -        if (e.getSource() == ok) {
      474 +        if (e.getSource() == ok) {
 477  475          DateTimeDialog.this.dateTimeDialogClose(true);
 478      -        }
 479      -        else
      476 +        }
      477 +        else
 480  478          if (e.getSource() == cancel) {
 481      -          DateTimeDialog.this.dateTimeDialogClose(false);
      479 +          DateTimeDialog.this.dateTimeDialogClose(false);
 482  480          }
 483  481          else
 484  482            if (e.getSource() == now) {
 485  483              DateTimeDialog.this.setCurrentTime();
 486  484            }
 487  485            else
 488  486              if (e.getSource() == midnight) {
 489  487                  DateTimeDialog.this.setMidnight();
 490  488              }
 491  489              else
 492      -               if (e.getSource() == help) {
 493      -                if (hd != null)
 494      -                  hd.show();
      490 +                if (e.getSource() == help) {
      491 +                    if (hd != null)
      492 +                        hd.setVisible(true);
 495  493                  else {
 496      -                  hd = new
      494 +                    hd = new
 497  495                      HelpDialog(DateTimeDialog.this.parent,
 498  496                          getString("Help for Date and Time Dialog"), false);
 499      -                  hd.setVisible(true);
 500      -                  hd.setText(getString(hrb, "DateTimeDialogHelp"));
 501      -                   }
 502      -                }
 503      -        } // actionPerformed
      497 +                    hd.setVisible(true);
      498 +                    hd.setText(getString(hrb, "DateTimeDialogHelp"));
      499 +                }
      500 +            }
      501 +        } // actionPerformed
 504  502      }
 505  503  
 506  504      /**
 507  505       * Listener for any change in focus with respect to the text
 508  506       * fields. When a text field is going out of focus, it detemines if the
 509  507       * text value in it is valid. If not, it returns focus to that text
 510  508       * field.
 511  509       */
 512  510      private class DCFocusListener extends FocusAdapter {
 513  511  
 514      -        public void focusLost(FocusEvent e) {
      512 +        public void focusLost(FocusEvent e) {
 515  513          if (!checkErrorAndSet((DCTextField)e.getSource()))
 516  514            ((DCTextField)e.getSource()).requestFocus();
 517      -        }
      515 +        }
 518  516      }
 519  517  
 520  518      /**
 521  519       * The string representation of the dialog box.
 522  520       * @return a String which contians the date and time in locale
 523  521       * default format, but to MEDIUM length formatting style.
 524  522       */
 525  523      public String toString() {
 526      -        calendar = new GregorianCalendar(year.getValue(),
 527      -                                       month.getSelectedIndex(),
 528      -                                       date.getValue(),
 529      -                                       hour.getValue(),
 530      -                                       minute.getValue(),
 531      -                                       second.getValue());
 532      -        return df.format(calendar.getTime());
      524 +        calendar = new GregorianCalendar(year.getValue(),
      525 +                                        month.getSelectedIndex(),
      526 +                                        date.getValue(),
      527 +                                        hour.getValue(),
      528 +                                        minute.getValue(),
      529 +                                        second.getValue());
      530 +        return df.format(calendar.getTime());
 533  531      }
 534  532  
 535  533      /**
 536  534       * Call rb.getString(), but catch exception and return English
 537  535       * key so that small spelling errors don't cripple the GUI
 538  536       *
 539  537       */
 540  538      private static final String getString(String key) {
 541  539      return (getString(rb, key));
 542  540      }
 543  541  
 544  542      private static final String getString(ResourceBundle rb, String key) {
 545  543      try {
 546  544          String res = rb.getString(key);
 547  545          return res;
 548  546      } catch (MissingResourceException e) {
 549  547          System.out.println("Missing resource "+key+", using English.");
 550  548          return key;
 551      -        }
      549 +        }
 552  550      }
 553  551  
      552 +    /* BEGIN JSTYLED */
 554  553      /*
 555  554      public static final void main(String args[]) {
 556  555      Frame f = new Frame();
 557      -    //  while (true){
 558      -        DateTimeDialog d = new DateTimeDialog(f, Color.white, Color.black);
 559      -        d.setVisible(true);
 560      -        System.out.println(d.toString());
      556 +    //  while (true){
      557 +        DateTimeDialog d = new DateTimeDialog(f, Color.white, Color.black);
      558 +        d.setVisible(true);
      559 +        System.out.println(d.toString());
 561  560        //    }
 562  561      }
 563  562      */
      563 +    /* END JSTYLED */
 564  564  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX