Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Gui  RSS feed

 
Angelos Naoumis
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
i am creating a simple gui for a TollMachine and i run in a problem.
While java code works fine[i mean a problem without gui just java code] (when i try to imp-lent the code into the gui actionlistener it doesnt set/get what i wanna do [it does nothing actually].)
Here is a fast example of what i wanna do ,
When the jButton is pressed i want it to load motorcycle tickets

Ticket.java



TollMachine.java



Assume i have set price and initial quantity for all tickets (i just didnt paste here to avoid huge codes)

GuiMenu.java

Launcher.java
 
Carey Brown
Saloon Keeper
Posts: 2536
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Seems to be doing everything you designed it to do. What makes you think it's not working? What outcome do you expect from clicking the button?
 
Carey Brown
Saloon Keeper
Posts: 2536
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
Seems to be doing everything you designed it to do. What makes you think it's not working? What outcome do you expect from clicking the button?

Perhaps I spoke too soon.

To override the actionPerformed() method you have to have the correct method signature.


You can't pass in "TollMachine machine".
 
Fred Kleinschmidt
Bartender
Posts: 507
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not? That method is not an actionPerformed method, but rather one that is called from the actionPerformed method.
 
Carey Brown
Saloon Keeper
Posts: 2536
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred Kleinschmidt wrote:Why not? That method is not an actionPerformed method, but rather one that is called from the actionPerformed method.

Thanks for the correction. I've got to stop speed reading.
 
Fred Kleinschmidt
Bartender
Posts: 507
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know it "does nothing" ? All the loadTicket() methoid does is set aq=iq.

Note that your jButton1_actionPerformed() method should first determine that the array returned by machine.getTickets() is not empty before you try to reference one of the array members.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!