示例#1
0
文件: View2.java 项目: yang49/Jotto
 public void updateHelper() {
   if (model.GuessORHint == 0) {
     label1.setText("Entered:");
   }
   if (model.GuessORHint == 1) {
     label1.setText("Hints:");
   }
   DefaultListModel<String> listTemp = new DefaultListModel<String>();
   if (model.GuessORHint == 0) {
     for (String str : model.haveEntered) {
       listTemp.addElement(str);
     }
   } else {
     if (model.hintWords != null) {
       for (String MM : model.hintWords) {
         if (MM == null) {
           listTemp.addElement("APPLE");
         } else {
           listTemp.addElement(MM);
         }
       }
     }
   }
   list.setModel(listTemp);
   scroll.setViewportView(list);
 }
  /** Set the contents of the field selector list. */
  private void setupFieldSelector() {
    fieldListModel.clear();
    SortedSet<String> contents = new TreeSet<String>();
    for (String s : metaData) {
      if (s.startsWith(Globals.SELECTOR_META_PREFIX)) {
        contents.add(s.substring(Globals.SELECTOR_META_PREFIX.length()));
      }
    }
    if (contents.size() == 0) {
      // if nothing was added, put the default fields (as described in the help)
      fieldListModel.addElement("author");
      fieldListModel.addElement("journal");
      fieldListModel.addElement("keywords");
      fieldListModel.addElement("publisher");
    } else {
      for (String s : contents) {
        fieldListModel.addElement(s);
      }
    }

    if (currentField == null) {
      // if dialog is created for the whole database,
      // select the first field to avoid confusions in GUI usage
      fieldList.setSelectedIndex(0);
    } else {
      // a specific field has been chosen at the constructur
      // select this field
      int i = fieldListModel.indexOf(currentField);
      if (i != -1) {
        // field has been found in list, select it
        fieldList.setSelectedIndex(i);
      }
    }
  }
示例#3
0
 public void dbAddElement(Object testo, Object valore, Object valore2) {
   lm.addElement(testo);
   dbItems.add(testo);
   dbItemsK.add(valore);
   dbItemsK2.add(valore2);
   this.setModel(lm);
 }
示例#4
0
    public void updateClientList() {
      Iterator i = clients.iterator();
      DefaultListModel model = new DefaultListModel();

      EditorClient placebo =
          new EditorClient(self, 0, "                                            ", 0, 0, "");
      model.addElement(placebo);

      while (i.hasNext()) {
        EditorClient c = (EditorClient) i.next();
        model.addElement(c);
      }

      lstClients.setModel(model);
      lstClients.setSelectedValue(currClient, true);
    }
示例#5
0
 /** Fetch movie names from the database and display them in the name list. */
 private void fillNameList() {
   nameListModel.removeAllElements();
   ArrayList<String> list = db.getMovies();
   for (String s : list) {
     nameListModel.addElement(s);
   }
 }
示例#6
0
  protected DictionaryWindow(MainFrame parent) {
    super(parent, true);
    setTitle("Dictionary");
    setBounds(new Rectangle(0, 0, 330, 330));

    JPanel mainPanel = new JPanel(new BorderLayout());

    DefaultListModel<String> listModel = new DefaultListModel<String>();
    JList<String> list = new JList<String>(listModel);
    JScrollPane scroll = new JScrollPane(list);
    for (String word : parent.dictionary.getSortedDictionary()) listModel.addElement(word);

    JButton ok = new JButton("OK");
    ok.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });

    mainPanel.add(scroll, BorderLayout.CENTER);
    mainPanel.add(ok, BorderLayout.SOUTH);

    add(mainPanel);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);
    setVisible(true);
  }
示例#7
0
  protected void init() {
    super.init();

    java.util.List<Macro> macros = new ArrayList<Macro>(MacroManager.getInstance().getMacros());
    Collections.sort(
        macros,
        new Comparator<Macro>() {
          public int compare(Macro macro1, Macro macro2) {
            String name1 = macro1.getName();
            String name2 = macro2.getName();
            if (!StringUtil.startsWithChar(name1, '/')) {
              name1 = ZERO + name1;
            }
            if (!StringUtil.startsWithChar(name2, '/')) {
              name2 = ZERO + name2;
            }
            return name1.compareToIgnoreCase(name2);
          }

          private final String ZERO = new String(new char[] {0});
        });
    for (Macro macro : macros) {
      myMacrosModel.addElement(new MacroWrapper(macro));
    }

    addListeners();
    if (myMacrosModel.size() > 0) {
      myMacrosList.setSelectedIndex(0);
    } else {
      setOKActionEnabled(false);
    }
  }
示例#8
0
 public void dbAddElement(String testo, String valore) {
   lm.addElement(testo);
   dbItems.add((Object) testo);
   dbItemsK.add((Object) valore);
   dbItemsK2.add(null);
   this.setModel(lm);
 }
示例#9
0
  /**
   * Instantiates a new help search panel.
   *
   * @param root the root
   * @param dialog the dialog
   */
  public HelpSearchPanel(HelpIndexRoot root, HelpDialog dialog) {
    this.root = root;
    this.dialog = dialog;

    setLayout(new BorderLayout());

    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    queryField = new JTextField();
    queryField.setActionCommand(MenuUtils.SEARCH_BUTTON);
    queryField.addActionListener(this);
    queryPanel.add(queryField, BorderLayout.CENTER);
    searchButton = new JButton(MenuUtils.SEARCH_BUTTON);
    searchButton.setActionCommand(MenuUtils.SEARCH_BUTTON);
    searchButton.addActionListener(this);
    queryPanel.add(searchButton, BorderLayout.EAST);
    add(queryPanel, BorderLayout.NORTH);

    listModel = new DefaultListModel();
    listModel.addElement("[No search results]");
    resultList = new JList(listModel);
    resultList.addListSelectionListener(this);
    resultList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    resultsScrollPane = new JScrollPane(resultList);
    add(resultsScrollPane, BorderLayout.CENTER);
  }
示例#10
0
 private void fillList(final HighlightSeverity severity) {
   DefaultListModel model = new DefaultListModel();
   model.removeAllElements();
   final List<SeverityBasedTextAttributes> infoTypes =
       new ArrayList<SeverityBasedTextAttributes>();
   infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
   Collections.sort(
       infoTypes,
       new Comparator<SeverityBasedTextAttributes>() {
         @Override
         public int compare(
             SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) {
           return -mySeverityRegistrar.compare(
               attributes1.getSeverity(), attributes2.getSeverity());
         }
       });
   SeverityBasedTextAttributes preselection = null;
   for (SeverityBasedTextAttributes type : infoTypes) {
     model.addElement(type);
     if (type.getSeverity().equals(severity)) {
       preselection = type;
     }
   }
   myOptionsList.setModel(model);
   myOptionsList.setSelectedValue(preselection, true);
 }
 public void update(Observable o, Object arg) {
   if (arg != null && arg instanceof ISOMsg) {
     ISOMsg m = (ISOMsg) arg;
     log.addElement(m);
     if (log.getSize() > LOG_CAPACITY) log.remove(0);
   }
 }
 private void populateActiveKitList() {
   // populate the active kits list with the current kits available in the factory
   listModel.removeAllElements();
   for (Integer i : kits.keySet()) {
     Kits currentKit = kits.get(i);
     listModel.addElement(currentKit);
   }
 }
示例#13
0
 private void setupList() {
   ArrayList list = view.initor.mdb.getTypeProfile(type);
   int size = list.size();
   for (int i = 0; i < size; i++) {
     UniProfile profile = (UniProfile) list.get(i);
     model.addElement(profile);
   }
 }
示例#14
0
 /** List results by alphabetical name */
 private void listByProgramName() {
   int nresult = datasets.size();
   String res[] = new String[nresult];
   for (int i = 0; i < nresult; i++) res[i] = (String) datasets.getElementAt(i);
   Arrays.sort(res);
   datasets.removeAllElements();
   for (int i = 0; i < nresult; i++) datasets.addElement(res[i]);
 }
示例#15
0
 /** Called to populate the List of users */
 private void populateUsers() {
   listModel.clear();
   users = control.list_users();
   for (int i = 0; i < users.length; i++) {
     listModel.addElement(users[i]);
   }
   userList.setSelectedIndex(0);
 }
示例#16
0
 /**
  * Adds the given Bean to the collection of Beans with preferences editors. When the dialog box is
  * opened, the editor associated with the Bean will be included in the GUI.
  */
 public void addPrefsBean(BeanPreferences bean) {
   mPrefsBeans.add(bean);
   mTabbedViewPane.add(new JScrollPane(bean.getEditor()), bean.getEditorName());
   bean.initPrefsGUI();
   mTabbedViewPane.revalidate();
   DefaultListModel model = (DefaultListModel) mListViewBeans.getModel();
   model.addElement(bean.getEditorName());
 }
示例#17
0
  private void getNewDataModel() {
    if (listModel.size() != 0) listModel.removeAllElements();

    if (rssFeed != null) {
      for (Data row = rssFeed.resetCursor(); row != null; row = rssFeed.next())
        listModel.addElement(row.getTitle());
    }
  }
示例#18
0
 public void setPluginHosts(final List<String> pluginHosts) {
   final DefaultListModel model = (DefaultListModel) myUrlsList.getModel();
   model.clear();
   for (String host : pluginHosts) {
     //noinspection unchecked
     model.addElement(host);
   }
 }
示例#19
0
  public boolean dbOpenList(Connection connection, String sql) {
    dbClearList();
    this.oldSql = sql;
    this.oldConnection = connection;
    // apre il resultset da abbinare
    ResultSet resu = null;
    ResultSetMetaData meta;
    try {
      stat = connection.createStatement();
      resu = stat.executeQuery(sql);
      meta = resu.getMetaData();

      if (meta.getColumnCount() > 1) {
        this.contieneChiavi = true;
      }

      // righe
      while (resu.next()) {
        for (int i = 1; i <= meta.getColumnCount(); ++i) {
          if (i == 1) {
            dbItems.add((Object) resu.getString(i));
            lm.addElement((Object) resu.getString(i));
          } else if (i == 2) {
            dbItemsK.add((Object) resu.getString(i));

            // debug
            // System.out.println("list:" + String.valueOf(i) + ":" + resu.getString(i));
          } else if (i == 3) {
            dbItemsK2.add((Object) resu.getString(i));
          }
        }
      }
      this.setModel(lm);

      // vado al primo
      if (dbTextAbbinato != null) {
        // debug
        // javax.swing.JOptionPane.showMessageDialog(null,this.getKey(0).toString());
        dbTextAbbinato.setText(this.getKey(0).toString());
      }

      return (true);
    } catch (Exception e) {
      javax.swing.JOptionPane.showMessageDialog(null, e.toString());
      e.printStackTrace();
      return (false);
    } finally {
      try {
        stat.close();
      } catch (Exception e) {
      }
      try {
        resu.close();
      } catch (Exception e) {
      }
      meta = null;
    }
  }
 private void createNewConfiguration() {
   if (!saveSelectedConfiguration()) return;
   myList.setSelectedValue(null, false);
   CvsRootConfiguration newConfig =
       CvsApplicationLevelConfiguration.createNewConfiguration(
           CvsApplicationLevelConfiguration.getInstance());
   myModel.addElement(newConfig);
   myList.setSelectedValue(newConfig, true);
 }
示例#21
0
 public ViewLinksPanel(
     Set<DocumentToDocumentLink> pLinks,
     ActionListener pDownloadAction,
     ActionListener pOpenAction) {
   this(pDownloadAction, pOpenAction);
   for (DocumentToDocumentLink link : pLinks) {
     mLinksListModel.addElement(link);
   }
 }
示例#22
0
  /** Fetch performance dates from the database and display them in the date list. */
  private void fillDateList(String movieName) {
    dateListModel.removeAllElements();
    /* --- insert own code here --- */
    ArrayList<String> list = db.getShowdates(movieName);

    for (String s : list) {
      dateListModel.addElement(s);
    }
  }
示例#23
0
  private MainPanel() {
    super(new BorderLayout());

    DefaultListModel<String> model = new DefaultListModel<>();
    model.addElement("11\n1");
    model.addElement("222222222222222\n222222222222222");
    model.addElement("3333333333333333333\n33333333333333333333\n33333333333333333");
    model.addElement("444");

    JList<String> list = new JList<>(model);
    list.setFixedCellHeight(-1);
    CellButtonsMouseListener cbml = new CellButtonsMouseListener(list);
    list.addMouseListener(cbml);
    list.addMouseMotionListener(cbml);
    list.setCellRenderer(new ButtonsRenderer<String>(model));

    add(new JScrollPane(list));
    setPreferredSize(new Dimension(320, 240));
  }
  public void populate(List<String> items) {
    model.clear();

    Iterator<String> iterator = items.iterator();

    while (iterator.hasNext()) {
      String item = iterator.next();
      model.addElement(item);
    }
  }
示例#25
0
  private void laden(Path saveName) throws IOException {
    Properties prop = new Properties();

    FileInputStream in = new FileInputStream(saveName.toString());
    prop.load(in);

    for (int i = 0; prop.containsKey(String.format("quellMenu%d", i)); i++)
      quellListModel.addElement(
          new ListItem(
              Paths.get(prop.getProperty(String.format("quellMenu%d", i))),
              Paths.get(prop.getProperty(String.format("quellMenu%d", i)))));
    for (int i = 0; prop.containsKey(String.format("zielMenu%d", i)); i++)
      zielListModel.addElement(
          new ListItem(
              Paths.get(prop.getProperty(String.format("zielMenu%d", i))),
              Paths.get(prop.getProperty(String.format("zielMenu%d", i)))));

    in.close();
  }
示例#26
0
 /** This method loads the names of the state groups that have been defined so far */
 private static void populateStateGroupsList() {
   StateLabelManager.updateAvailableStateGroups();
   String[] stateGrpNames =
       StateLabelManager.getStateNames(StateLabelManager.availableStateGroups);
   DefaultListModel model = new DefaultListModel();
   for (String stateName : stateGrpNames) {
     model.addElement(stateName);
   }
   StateLabelManager.stateGroupsList.setModel(model);
 }
示例#27
0
文件: Applet.java 项目: Zmiecer/BSU
  @Override
  public void init() {

    JPanel pane = new JPanel();
    PointOnCircle point = new PointOnCircle();

    JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 15);
    Hashtable labelTable = new Hashtable();
    labelTable.put(new Integer(0), new JLabel("Stop"));
    labelTable.put(new Integer(15), new JLabel("Slow"));
    labelTable.put(new Integer(50), new JLabel("Fast"));
    slider.setLabelTable(labelTable);
    slider.setPaintLabels(true);
    slider.addChangeListener(
        e -> {
          int speed;
          JSlider source = (JSlider) e.getSource();
          speed = source.getValue();
          point.setSpeed(speed);
        });

    DefaultListModel<String> model = new DefaultListModel<>();
    model.addElement("Right");
    model.addElement("Left");
    JList list = new JList(model);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(
        e -> {
          if (list.getSelectedIndex() == 0) {
            point.setRight(true);
          } else {
            point.setRight(false);
          }
        });

    pane.add(slider);
    pane.add(list);

    add(point, BorderLayout.CENTER);
    add(pane, BorderLayout.NORTH);
  }
 /**
  * Methode, um die ausgewählten Objekte zu übergeben.
  *
  * @param objects die ausgewählten Objekte
  */
 private void setObjects(List<SystemObject> objects) {
   _objects.clear();
   _objects.addAll(objects);
   if (_objects.size() >= 1) {
     DefaultListModel defaultListModel = new DefaultListModel();
     for (Iterator iterator = _objects.iterator(); iterator.hasNext(); ) {
       defaultListModel.addElement(iterator.next());
     }
     _objList.setModel(defaultListModel);
   }
 }
示例#29
0
  private void listOfNamesValueChanged(javax.swing.event.ListSelectionEvent evt) {
    // TODO add your handling code here:
    int index = listOfNames.getSelectedIndex();
    // System.out.println(index);
    listModel3.clear();
    listModel4.clear();
    for (int i = 0; i < 5; i++) {
      listModel3.addElement((answers.get(index))[i]);
    }
    answerList.setModel(listModel3);

    for (int i = 0; i < 5; i++) {
      if ((answers.get(index))[i] == correct[i]) {
        listModel4.addElement("2/2");
      } else {
        listModel4.addElement("0/2");
      }
    }
    pointList.setModel(listModel4);
  }
示例#30
0
 void syncLists() {
   JList list = webPanels[1 - panelIndex].instanceList;
   DefaultListModel model1 = (DefaultListModel) instanceList.getModel();
   DefaultListModel model2 = (DefaultListModel) list.getModel();
   model2.clear();
   int n = model1.getSize();
   for (int i = 0; i < n; i++)
     model2.addElement(model1.get(i));
   list.setSelectedIndices(new int[] {});
   enableButtons(instanceList);
   webPanels[1 - panelIndex].enableButtons(list);
 }