Results 1 to 3 of 3
Thread: Next and Previous Buttons
- 08-12-2009, 02:46 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 1
- Rep Power
- 0
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:
Java 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
- 08-12-2009, 08:33 AM #2
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
i think you missing {} for "Last" button
and you just hard code "Next" to get xxx[2], not really do "Next"
- 08-12-2009, 02:08 PM #3
Similar Threads
-
Java next and previous button
By florentp in forum Java TipReplies: 0Last Post: 03-18-2009, 05:10 AM -
add previous jar library to new one
By Farzaneh in forum EclipseReplies: 1Last Post: 08-23-2008, 02:31 PM -
help..on Next n Previous Button
By norazanita in forum New To JavaReplies: 0Last Post: 06-12-2008, 05:58 AM -
Next and Previous Buttons
By JavaNewb in forum New To JavaReplies: 1Last Post: 05-09-2008, 01:23 AM -
Using previous with CardLayout
By uncopywritable in forum New To JavaReplies: 2Last Post: 08-05-2007, 09:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks