Revision 31496 branches/v2_0_0_prep/libraries/libUIComponent/src/de/ios/framework/swing/DateComboBox.java

View differences:

DateComboBox.java
46 46
//////////////////////////////////////////////////////////////
47 47

  
48 48
public class DateComboBox extends JComboBox {
49
  private static final long serialVersionUID = 1L;
49
	private static final long serialVersionUID = 1L;
50 50

  
51
static java.util.ResourceBundle resource = java.util.ResourceBundle.getBundle("resources.Traduction")/*#BundleType=List*/;
51
	static java.util.ResourceBundle resource = java.util.ResourceBundle.getBundle("resources.Traduction")/*#BundleType=List*/;
52 52

  
53
    protected SimpleDateFormat dateFormat = new SimpleDateFormat("MMM d, yyyy");
54
    public void setDateFormat(SimpleDateFormat dateFormat) {
55
	this.dateFormat = dateFormat;
56
    }
57
    public void setSelectedItem(Object item) {
58
	// Could put extra logic here or in renderer when item is instanceof Date, Calendar, or String
59
	// Dont keep a list ... just the currently selected item
60
	removeAllItems(); // hides the popup if visible
61
	addItem(item);
62
	super.setSelectedItem(item);
63
    }
53
	protected SimpleDateFormat dateFormat = new SimpleDateFormat("MMM d, yyyy");
54
	public void setDateFormat(SimpleDateFormat dateFormat) {
55
		this.dateFormat = dateFormat;
56
	}
57
	public void setSelectedItem(Object item) {
58
		// Could put extra logic here or in renderer when item is instanceof Date, Calendar, or String
59
		// Dont keep a list ... just the currently selected item
60
		removeAllItems(); // hides the popup if visible
61
		addItem(item);
62
		super.setSelectedItem(item);
63
	}
64 64

  
65
    public void updateUI() {
66
	ComboBoxUI cui = (ComboBoxUI) UIManager.getUI(this);
67
	if (cui instanceof MetalComboBoxUI) {
68
	    cui = new MetalDateComboBoxUI();
69
	} else if (cui instanceof MotifComboBoxUI) {
70
	    cui = new MotifDateComboBoxUI();
71
	} else if (cui instanceof WindowsComboBoxUI) {
72
	    cui = new WindowsDateComboBoxUI();
65
	public void updateUI() {
66
		ComboBoxUI cui = (ComboBoxUI) UIManager.getUI(this);
67
		if (cui instanceof MetalComboBoxUI) {
68
			cui = new MetalDateComboBoxUI();
69
		} else if (cui instanceof MotifComboBoxUI) {
70
			cui = new MotifDateComboBoxUI();
71
		} else if (cui instanceof WindowsComboBoxUI) {
72
			cui = new WindowsDateComboBoxUI();
73
		}
74
		setUI(cui);
73 75
	}
74
        setUI(cui);
75
    }
76 76

  
77
    // Inner classes are used purely to keep DateComboBox component in one file
78
    //////////////////////////////////////////////////////////////
79
    // UI Inner classes -- one for each supported Look and Feel
80
    //////////////////////////////////////////////////////////////
77
	// Inner classes are used purely to keep DateComboBox component in one file
78
	//////////////////////////////////////////////////////////////
79
	// UI Inner classes -- one for each supported Look and Feel
80
	//////////////////////////////////////////////////////////////
81 81

  
82
    class MetalDateComboBoxUI extends MetalComboBoxUI {
83
	protected ComboPopup createPopup() {
84
	    return new DatePopup( comboBox );
82
	class MetalDateComboBoxUI extends MetalComboBoxUI {
83
		protected ComboPopup createPopup() {
84
			return new DatePopup( comboBox );
85
		}
85 86
	}
86
    }
87 87

  
88
    class WindowsDateComboBoxUI extends WindowsComboBoxUI {
89
	protected ComboPopup createPopup() {
90
	    return new DatePopup( comboBox );
88
	class WindowsDateComboBoxUI extends WindowsComboBoxUI {
89
		protected ComboPopup createPopup() {
90
			return new DatePopup( comboBox );
91
		}
91 92
	}
92
    }
93 93

  
94
    class MotifDateComboBoxUI extends MotifComboBoxUI {
95
      private static final long serialVersionUID = 5669807256653124411L;
94
	class MotifDateComboBoxUI extends MotifComboBoxUI {
95
		private static final long serialVersionUID = 5669807256653124411L;
96 96

  
97
	protected ComboPopup createPopup() {
98
	    return new DatePopup( comboBox );
97
		protected ComboPopup createPopup() {
98
			return new DatePopup( comboBox );
99
		}
99 100
	}
100
    }
101 101

  
102 102
    //////////////////////////////////////////////////////////////
103 103
    // DatePopup inner class

Also available in: Unified diff