コード例 #1
0
 private void buttonAddArticleActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_buttonAddArticleActionPerformed
   int amount;
   try {
     amount = Integer.parseInt(fieldAmount.getText());
     if (amount > 0) {
       int index = listArticles.getSelectedIndex();
       ReceiptArticle article = articles.get(index);
       article.setAmount(amount);
       parent.addArticle(article);
       dispose();
     } else labelError.setText("Antal måste vara ett positivt heltal.");
   } catch (NumberFormatException e) {
     labelError.setText("Antal får bara innehålla siffror.");
   }
 } // GEN-LAST:event_buttonAddArticleActionPerformed
コード例 #2
0
 private void populateList() {
   for (ReceiptArticle article : articles) {
     listArticles.addItem(article.getArticleName());
   }
 }