(String[] args)
| 222 | } |
| 223 | |
| 224 | public static void main(String[] args){ |
| 225 | final JChoice<String> fChoice = new JChoice<String>(new String[]{ |
| 226 | "Jan", |
| 227 | "Feb", |
| 228 | "Mar", |
| 229 | "Apr", |
| 230 | "May", |
| 231 | "Jun", |
| 232 | "Jul", |
| 233 | "Aug", |
| 234 | "Sep", |
| 235 | "Oct", |
| 236 | "Nov", |
| 237 | "Dec"}); |
| 238 | fChoice.setMaximumFastChoices(20); |
| 239 | fChoice.addActionListener(new ActionListener(){ |
| 240 | @Override |
| 241 | public void actionPerformed(ActionEvent e) { |
| 242 | System.out.println("Action (" + e.getActionCommand() + ") :" + fChoice.getSelectedItem() + " selected!"); |
| 243 | } |
| 244 | }); |
| 245 | fChoice.addItemListener(new ItemListener(){ |
| 246 | @Override |
| 247 | public void itemStateChanged(ItemEvent e) { |
| 248 | System.out.println("Item " + e.getItem().toString() + |
| 249 | (e.getStateChange() == ItemEvent.SELECTED ? " selected!" : |
| 250 | " deselected!")); |
| 251 | } |
| 252 | |
| 253 | }); |
| 254 | JFrame aFrame = new JFrame("Fast Chioce Test Frame"); |
| 255 | aFrame.getContentPane().add(fChoice); |
| 256 | |
| 257 | Box topBox = Box.createHorizontalBox(); |
| 258 | JButton aButn = new JButton("Clear"); |
| 259 | aButn.addActionListener(new ActionListener(){ |
| 260 | @Override |
| 261 | public void actionPerformed(ActionEvent e) { |
| 262 | System.out.println("Clearing"); |
| 263 | fChoice.setSelectedItem(null); |
| 264 | } |
| 265 | }); |
| 266 | topBox.add(Box.createHorizontalStrut(10)); |
| 267 | topBox.add(aButn); |
| 268 | topBox.add(Box.createHorizontalStrut(10)); |
| 269 | topBox.add(new JToggleButton("GAGA")); |
| 270 | |
| 271 | aFrame.add(topBox, BorderLayout.NORTH); |
| 272 | aFrame.pack(); |
| 273 | aFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
| 274 | aFrame.setVisible(true); |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * @param l |
nothing calls this directly
no test coverage detected