• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

refresh gui java

Hi,
I need to write program which show items from database. I can now display item with a given id.

What I want to do is to add "next" button to show item with id+1. I've created jButton and added following code:
itemNumber++;
validate();
but the GUI is still the same. What I did wrong?

public class SaleAssistant extends javax.swing.JPanel {

Sale sale = SaleUtil.getNextSalesAfterNow().get(0);
List<Item> SaleList = new ArrayList();
Item item;
int itemNumber = 0;
    /** Creates new form SaleAssistant */
    public SaleAssistant() {
        initComponents();
        SaleList.addAll(sale.getItems());

        item = SaleList.get(itemNumber);
       
        curCatLabel.setText(item.getCategory().toString());
        itemName.setText(item.getName().toString());
        itemID.setText(item.getIdItem().toString());
}

Open in new window

0
static86
Asked:
static86
1 Solution
 
objectsCommented:
you also need to do

        item = SaleList.get(itemNumber);
       
        curCatLabel.setText(item.getCategory().toString());
        itemName.setText(item.getName().toString());
        itemID.setText(item.getIdItem().toString());

0
 
static86Author Commented:
thx!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now