1
2
3
4
5
6
7
8
9
10
11
12
13 package org.gscg.common.gui.components.interactivespinner;
14
15 import javax.swing.JComponent;
16 import javax.swing.JSpinner;
17 import javax.swing.SpinnerDateModel;
18 import javax.swing.SpinnerListModel;
19 import javax.swing.SpinnerModel;
20
21 /***
22 * The JInteractiveSpinner is used to override the interactivity settings of the
23 * underlying editors. To do so we override the createEditor method. In this
24 * method we implement our own editors, and as such are able to provide a user
25 * with more information when for example an exception occurs. The main reason
26 * for doing this is that we would like to override the default choice of
27 * chosing the previous value when an exception occurs. We would like to notify
28 * a user of this event and than break out of the method instead of continuing
29 * its execution. Currently we are only overrideing the NumberEditor.
30 * <p>
31 * (c) copyright 2005 <a href="http://www.simulation.tudelft.nl">Delft
32 * University of Technology </a>, the Netherlands. <br>
33 * See for project information <a
34 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
35 *
36 * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
37 * Delft, the Netherlands. All rights reserved.
38 *
39 * See for project information <a href="http://www.simulation.tudelft.nl/">
40 * www.simulation.tudelft.nl </a>.
41 *
42 * The source code and binary code of this software are proprietary information
43 * of Delft University of Technology.
44 *
45 * @author <a
46 * href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
47 * van Houten </a>
48 * @version $Revision: 1.1 $ $Date: 2005/06/16 12:33:57 $
49 * @since 1.1.3
50 */
51 public class JInteractiveSpinner extends JSpinner
52 {
53
54 /***
55 * constructs a new JInteractiveSpinner
56 */
57 public JInteractiveSpinner()
58 {
59 super();
60 }
61
62 /***
63 * constructs a new JInteractiveSpinner
64 *
65 * @param model the spinner model
66 */
67 public JInteractiveSpinner(final SpinnerModel model)
68 {
69 super(model);
70 }
71
72 /***
73 * @see javax.swing.JSpinner#createEditor(javax.swing.SpinnerModel)
74 */
75 protected JComponent createEditor(final SpinnerModel model)
76 {
77 if (model instanceof SpinnerDateModel)
78 {
79 return super.createEditor(model);
80 } else if (model instanceof SpinnerListModel)
81 {
82 return super.createEditor(model);
83
84 } else if (model instanceof SpinnerNumberModel)
85 {
86 return new org.gscg.common.gui.components.interactivespinner.NumberEditor(
87 this);
88 } else
89 {
90 return super.createEditor(model);
91 }
92 }
93 }