Beispiel #1
1
 public Controller(Action toggleAction) {
   itemList.setModel(new DefaultComboBoxModel());
   itemList.setPrototypeDisplayValue("------------------------");
   enableEditor(false);
   this.toggleAction = toggleAction;
 }
  public SwingThreadFrame() {
    setTitle("SwingThreadTest");

    final JComboBox combo = new JComboBox();
    combo.insertItemAt(new Integer(Integer.MAX_VALUE), 0);
    combo.setPrototypeDisplayValue(combo.getItemAt(0));
    combo.setSelectedIndex(0);

    JPanel panel = new JPanel();

    JButton goodButton = new JButton("Good");
    goodButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            new Thread(new GoodWorkerRunnable(combo)).start();
          }
        });
    panel.add(goodButton);
    JButton badButton = new JButton("Bad");
    badButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            new Thread(new BadWorkerRunnable(combo)).start();
          }
        });
    panel.add(badButton);
    panel.add(combo);
    add(panel);
    pack();
  }