1 /*
2 * Scope: a generic MVC framework.
3 * Copyright (c) 2000-2002, The Scope team
4 * All rights reserved.
5 *
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * Neither the name "Scope" nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 *
36 * $Id: ComboDemoView.java,v 1.7 2002/09/05 15:41:47 ludovicc Exp $
37 */
38 package samples.swing.combobox;
39
40
41 import java.awt.GridBagConstraints;
42 import java.awt.GridBagLayout;
43 import java.awt.Insets;
44 import javax.swing.JButton;
45 import javax.swing.JLabel;
46 import org.scopemvc.core.Control;
47 import org.scopemvc.util.convertor.IntegerStringConvertor;
48 import org.scopemvc.view.swing.SActionListener;
49 import org.scopemvc.view.swing.SComboBox;
50 import org.scopemvc.view.swing.SComboBoxEditor;
51 import org.scopemvc.view.swing.SPanel;
52 import samples.util.GridBagHelper;
53
54 /***
55 * @author <A HREF="mailto:daniel.michalik@autel.cz">Daniel Michalik</A>
56 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net">Steve Meyfroidt</A>
57 * @created 05 September 2002
58 * @version $Revision: 1.7 $ $Date: 2002/09/05 15:41:47 $
59 */
60 public class ComboDemoView extends SPanel {
61
62 private SActionListener nextLaF = new SActionListener();
63
64
65 /***
66 * Constructor for the ComboDemoView object
67 */
68 public ComboDemoView() {
69 GridBagLayout gridbag = new GridBagLayout();
70 int comboWidth = 90;
71 gridbag.columnWidths = new int[]{12, comboWidth, 11, comboWidth, 11, comboWidth, 11, 0, 11, 0, 11};
72 gridbag.columnWeights = new double[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
73 gridbag.rowHeights = new int[]{12, 0, 0, 0, 11, 0, 0, 0, 11, 0, 0, 0, 11};
74 gridbag.rowWeights = new double[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
75 GridBagHelper hlp = new GridBagHelper();
76 setLayout(gridbag);
77
78 add(new JLabel("Look and Feel"), hlp.xy(1, 1, "w"));
79 SComboBox lookAndFeelCombo = new SComboBox();
80 add(lookAndFeelCombo, hlp.xy(1, 3, "we"));
81 lookAndFeelCombo.setSelectorString("lookAndFeelSelection.lookAndFeels");
82 lookAndFeelCombo.setSelectionSelectorString("lookAndFeelSelection.selectedLookAndFeel");
83
84 JButton b = new JButton("Next");
85 b.addActionListener(nextLaF);
86 nextLaF.setModelActionString("nextLookAndFeel");
87 add(b, hlp.xy(3, 3));
88
89 add(new JLabel("Font Size"), hlp.xy(1, 5, "w"));
90 SComboBox fontSizeCombo = new SComboBox();
91 fontSizeCombo.setEditable(true);
92 add(fontSizeCombo, hlp.xy(1, 7, "we"));
93 fontSizeCombo.setSelectorString("fontSizeSelection.sizeList");
94 fontSizeCombo.setSelectionSelectorString("fontSizeSelection.currentSize");
95 fontSizeCombo.setSizeSelectorString("fontSizeSelection.sizeListSize");
96
97 /*
98 * date part:
99 */
100 SComboBox yearCombo = new SComboBox();
101 yearCombo.setEditable(true);
102 add(new JLabel("Year"), hlp.xy(1, 9, "w"));
103 add(yearCombo, hlp.xy(1, 11, "we"));
104 yearCombo.setSelectorString("dateModel.years");
105 yearCombo.setSelectionSelectorString("dateModel.currentYear");
106
107 SComboBox monthCombo = new SComboBox();
108 monthCombo.setEditable(true);
109 add(new JLabel("Month"), hlp.xy(3, 9, "w"));
110 add(monthCombo, hlp.xy(3, 11, "we"));
111 monthCombo.setSelectorString("dateModel.months");
112 monthCombo.setSelectionSelectorString("dateModel.currentMonth");
113
114 SComboBox dayCombo = new SComboBox();
115 dayCombo.setEditable(true);
116 add(new JLabel("Day"), hlp.xy(5, 9, "w"));
117 add(dayCombo, hlp.xy(5, 11, "we"));
118 dayCombo.setSelectorString("dateModel.days");
119 dayCombo.setSelectionSelectorString("dateModel.currentDay");
120
121 /*
122 * static list for duplicate font combo
123 */
124 add(new JLabel("Duplicate Font Size"), new GridBagConstraints(
125 1, 13, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
126 GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0
127 ));
128 SComboBox duplicateFontSizeCombo = new SComboBox();
129 duplicateFontSizeCombo.setEditable(false);
130 duplicateFontSizeCombo.setEditable(true);
131 add(duplicateFontSizeCombo, new GridBagConstraints(
132 1, 15, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
133 GridBagConstraints.BOTH, new Insets(0, 0, 8, 0), 0, 0
134 ));
135 Integer[] staticSizes = {new Integer(9), new Integer(10), new Integer(11)};
136 duplicateFontSizeCombo.setListModel(staticSizes);
137 duplicateFontSizeCombo.setSelectionSelectorString("fontSizeSelection.currentSize");
138 }
139
140
141 /***
142 * Gets the close control
143 *
144 * @return The closeControl value
145 */
146 public Control getCloseControl() {
147 return new Control(ComboDemoController.EXIT_CONTROL_ID, this);
148 }
149
150
151 /***
152 * Sets the bound model
153 *
154 * @param inModel The new boundModel value
155 */
156 public void setBoundModel(Object inModel) {
157 super.setBoundModel(inModel);
158
159 ComboDemoModel m = (ComboDemoModel) inModel;
160 nextLaF.setBoundModel(m.getLookAndFeelSelection());
161 }
162 }
This page was automatically generated by Maven