Results 1 to 9 of 9
- 10-15-2010, 06:43 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 24
- Rep Power
- 0
refreshing my Buttons after executing an action
Hi,
I wonder what do I need to do to refresh my GUI scrollPanes everytime I execute an action. For example I have the code below:
Then execute the buyJourneyforUser() but going back to the menu the same selection still on. What do I need to do to reset that back to non-selection. Thanks for your help in advance.Java Code:purchaseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("PURCHASE") && user != null && stationFrom != null && stationTo != null && startTime != null && endTime != null) { else { text.setText("PURCHASE SELECTED"); new buyJourneyforUser(user, stationFrom, stationTo, startTime, endTime, n1); userList.setRequestFocusEnabled(false); stationListFrom.setRequestFocusEnabled(true); } } } });
- 10-15-2010, 10:03 AM #2
Member
- Join Date
- May 2010
- Posts
- 32
- Rep Power
- 0
perhaps some thing like:
<your container object>.repaint();
<your container object>.validate();
- 10-15-2010, 12:28 PM #3
To get better help sooner, post a SSCCE that clearly demonstrates where you have a problem.
db
- 10-18-2010, 12:12 AM #4
Member
- Join Date
- Aug 2010
- Posts
- 24
- Rep Power
- 0
ok thanks. Actually I tried the repaint and validate but didn't work for me. Also I was hoping that setting the setSelectedIndex(-1) would do the trick but is not working either.
-
- 10-18-2010, 01:44 AM #6
Member
- Join Date
- Aug 2010
- Posts
- 24
- Rep Power
- 0
Hi Again,
Here below is how I define the listeners :
Then after I pressed the purchase button:Java Code:stationListFrom.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { text.setText("" + stationListFrom.getSelectedValue()); stationFrom = text.getText(); } }); stationListTo.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { text.setText("" + stationListTo.getSelectedValue()); stationTo = text.getText(); } });
Java Code:purchaseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { while (e.getActionCommand().equals("PURCHASE")) { if (n1.Users.get(user).getMytiCredit() == 0) { text.setText("You need to recharge your Myti card first"); break; } if (e.getActionCommand().equals("PURCHASE") && user != null && stationListFrom.getSelectedIndex() != -1 && stationListTo.getSelectedIndex() != -1 && HoursListStart.getSelectedIndex() != -1 && MinutesListStart.getSelectedIndex() != -1 && HoursListEnd.getSelectedIndex() != -1 && HoursListEnd.getSelectedIndex() != -1) { text.setText("PURCHASE SELECTED"); text.setText(user + stationFrom + stationTo + startTimeHour + endTimeHour); n1.buyJourneyforUser(user, stationFrom, stationTo, startTimeHour, startTimeMinutes, startTimeHourNum, startTimeMinutesNum, endTimeHour, endTimeMinutes, endTimeHourNum, endTimeMinutesNum, n1); stationListFrom.setSelectedIndex(-1); stationListTo.setSelectedIndex(-1); HoursListStart.setSelectedIndex(-1); MinutesListStart.setSelectedIndex(-1); HoursListStart.setSelectedIndex(-1); HoursListEnd.setSelectedIndex(-1); break; // new buyJourneyforUser(user, stationFrom, stationTo, // startTime, endTime, n1); // userList.setRequestFocusEnabled(false); // stationListFrom.setRequestFocusEnabled(true); // cmd="Purchase"; } else { text.setText("Please select all the options"); break; } } } });
I was hoping to clear the previous selection otherwise the last sucessfull selection still there.
-
Two of us have recommended that you create and post an SSCCE, and yet, nothing. Have you read the link? You might wish to state why you've decided to ignore our advice.
Best of luck.
- 10-18-2010, 03:14 AM #8
Member
- Join Date
- Aug 2010
- Posts
- 24
- Rep Power
- 0
Sorry for the misunderstanding but I'm not ignoring your recommendations. I thought that part of the code would be good enough. Every recommendation on this forum has been so valuable to me. My Gui class is huge so that is one of the reason's I didn't want to post the whole thing. Thanks!!! :)
-
Similar Threads
-
HTTP Status 404 - There is no Action mapped for action name showmainframe...
By vaibhavspawar in forum Advanced JavaReplies: 3Last Post: 08-19-2010, 08:27 AM -
For some reason, my GUI is not recognizing multiple action listeners for buttons.
By JavaStudent1990 in forum New To JavaReplies: 8Last Post: 08-10-2010, 02:59 AM -
My buttons all perform their action like 100 times
By 711groove in forum New To JavaReplies: 0Last Post: 12-13-2009, 10:49 AM -
JTableHeader not refreshing
By aznboarder in forum AWT / SwingReplies: 4Last Post: 04-11-2009, 04:31 AM -
Bug in refreshing jsp
By anki1234 in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 12-31-2007, 07:09 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks