Ignore:
Timestamp:
03/24/2019 07:19:23 PM (7 years ago)
Author:
jdalbey
Message:

Modify GotoTimeIndexDialog?.java to use TimeSelector? widget.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/simulationmanager/dialogs/GotoTimeIndexDialog.java

    r2 r346  
    1313import javax.swing.JDialog; 
    1414import javax.swing.JLabel; 
    15 import javax.swing.JSpinner; 
     15import javax.swing.UIManager; 
    1616 
    1717import tmcsim.simulationmanager.SimulationManagerView; 
    18 import tmcsim.simulationmanager.model.IncidentTimeSpinnerModel; 
    19  
     18import timeselector.*; 
    2019 
    2120/** 
     
    2625 * 
    2726 * @author Matthew Cechini 
    28  * @version 
     27 * Modifed to use timeselector by jdalbey 3/24/2019 
    2928 */ 
    3029@SuppressWarnings("serial") 
     
    4746         
    4847        initComponents();    
    49          
    50         timeSpinner.setValue(initialValue);      
    5148 
    5249        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
     
    9794        }); 
    9895         
    99         incidentTimeModel = new IncidentTimeSpinnerModel(); 
    100         timeSpinner = new JSpinner(incidentTimeModel); 
    101         timeSpinner.setMaximumSize(new Dimension(70,20)); 
    102         timeSpinner.setAlignmentX(Box.CENTER_ALIGNMENT); 
     96        fldTimeSelection = new TimeSelectionField(false); 
    10397         
    10498        buttonBox = new Box(BoxLayout.X_AXIS); 
     
    117111        gotoIndexBox.add(gotoLabel); 
    118112        gotoIndexBox.add(Box.createVerticalStrut(10)); 
    119         gotoIndexBox.add(timeSpinner); 
     113        gotoIndexBox.add(fldTimeSelection); 
    120114        gotoIndexBox.add(Box.createVerticalStrut(10)); 
    121115        gotoIndexBox.add(buttonBox);     
     
    128122     
    129123    /** 
    130      * Gets a string representation of the time set by the time 
    131      * spinner in the dialog.  Format:  H:MM:SS 
    132      * @return String representation of spinner time. 
     124     * Accessor to the String representation of user selected time. The text 
     125     * field contains a String representation of the time in a format produced 
     126     * by SimpleDateFormat pattern "h:mm:ss", e.g., "3:26:00" 
     127     * 
     128     * @return String containing the selected time. 
    133129     */ 
    134     public String getGotoTime() { 
    135         return (String)timeSpinner.getValue(); 
     130    public String getGotoTime()  
     131    { 
     132        String result = fldTimeSelection.getText(); 
     133        return result.substring(1, result.length()); 
    136134    }    
    137135     
     136    /** Local main for unit testing */ 
     137    public static void main(String[] args) 
     138    { 
     139        try 
     140        { 
     141            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     142        } catch (Exception ex) 
     143        { 
     144            ex.printStackTrace(); 
     145        } 
     146 
     147        GotoTimeIndexDialog dlg = new GotoTimeIndexDialog(null,0); 
     148        System.out.println(dlg.getGotoTime()); 
     149    } 
    138150     
    139151    private JLabel gotoLabel; 
    140     private JSpinner timeSpinner; 
    141      
    142     private IncidentTimeSpinnerModel incidentTimeModel; 
    143152     
    144153    private JButton cancelButton;; 
     
    148157    private Box buttonBox;   
    149158     
     159    private TimeSelectionField fldTimeSelection; 
    150160} 
Note: See TracChangeset for help on using the changeset viewer.