• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple Gui

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic