Next and Previous Buttons
Help.....I am new to java and trying to add first, next, previous and last buttons to my gui. I have all my code working but whenever I try and I have tried a lot of things, everything gets screwed up. Here is a section of my code:
Code:
public void actionPerformed(ActionEvent e)
{
//add button functions
if (e.getActionCommand() == "First") // First is the caption (label) on my button. If the button I click is First, the following statements will execute.
{
prodnameField.setText(software[0].getprodname()); // get the name of the first person in my array and display it in the name text box.
itemnumField.setText(String.valueOf(software[0].getitemnum())); // get the age of the first person in my array and display it in the age text box.
prodpriceField.setText(String.valueOf(software[0].getprodprice())); // get the weight of the first person in my array and display it in the weight text box.
} // end if
if (e.getActionCommand() == "Next") // First is the caption (label) on my button. If the button I click is First, the following statements will execute.
{
prodnameField.setText(software[1].getprodname()); // get the name of the first person in my array and display it in the name text box.
itemnumField.setText(String.valueOf(software[2].getitemnum())); // get the age of the first person in my array and display it in the age text box.
prodpriceField.setText(String.valueOf(software[2].getprodprice())); // get the weight of the first person in my array and display it in the weight text box.
} // end if
if (e.getActionCommand() == "Last") // Last is the caption (label) on my button. If the button I click is labeled Last, the following statements will execute.
prodnameField.setText(software[4].getprodname()); // get the name of the last person in my array and display it in the name text box.
itemnumField.setText(String.valueOf(software[4].getitemnum())); // get the age of the last person in my array and display it in the age text box.
prodpriceField.setText(String.valueOf(software[4].getprodprice())); // get the weight of the last person in my array and display it in the weight text box.
} // end if