Line | |
---|
1 | package org.expeditee.items.widgets;
|
---|
2 |
|
---|
3 | import javax.swing.JComboBox;
|
---|
4 |
|
---|
5 | import org.expeditee.gui.Frame;
|
---|
6 | import org.expeditee.items.Text;
|
---|
7 |
|
---|
8 | public class DataFrameWidget1 extends DataFrameWidget {
|
---|
9 |
|
---|
10 | static String testItems[] = new String[] { "dog", "fish", "cat", "pig" };
|
---|
11 |
|
---|
12 | private JComboBox _combo;
|
---|
13 |
|
---|
14 | public DataFrameWidget1(Text source, String[] args) {
|
---|
15 | super(source, new JComboBox(testItems), 200, 200, 50, 50);
|
---|
16 | _combo = (JComboBox) super._swingComponent;
|
---|
17 |
|
---|
18 | refresh();
|
---|
19 | }
|
---|
20 |
|
---|
21 | @Override
|
---|
22 | protected String[] getArgs() {
|
---|
23 | String[] stateArgs = new String[1];
|
---|
24 | stateArgs[0] = Integer.toString(_combo.getSelectedIndex());
|
---|
25 | return stateArgs;
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public void refresh() {
|
---|
30 | super.refresh();
|
---|
31 | Frame frame = getDataFrame();
|
---|
32 | if(frame != null) {
|
---|
33 | _combo.removeAllItems();
|
---|
34 | for(Text text: frame.getBodyTextItems(false)) {
|
---|
35 | _combo.addItem(text.getText());
|
---|
36 | }
|
---|
37 | _combo.setSelectedIndex(0);
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public float getMinimumBorderThickness() {
|
---|
43 | return 0.0F;
|
---|
44 | }
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.