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

JAVA GUI - Actions for Buttons/ActionListener/Event Handling  RSS feed

 
ashlan cooper
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there, I'm trying on Gui exercises. One of them requires a simple GUI class for Vehicle.
The GUI should have buttons for creating new SportsCar and new Van objects. and then should display the values of the instance variables of these variables.
The GUI should also calculate and display the fuel consumption and acceleration of the vehicle objects that have been added by the user.

For Vehicle class this is the code

Basically in this code there are methods to calculate Acceleration and Consumption

For the GUI,


I am confused how do I insert the new SCButtonlistener
and new VanButtonlistener without causing anything to crash. I somehow missed those 2 listeners

My problems are:

I want to create a main frame which displays 2 buttons: Add New SportsCar and Add New Van
which I have already created.

And then when the user clicks Add New Sports Car, a new frame will appear with another button : Set New Sports Car and when the user clicks that, another frame will appear which will display several text fields.

These are for the user to input the horsepower, toppeed and weight of their desired new sports car ; which I have written but somehow doesn't appear like I thought it would. It comes out with several frames when I click add Set Sports Car

How do I link the new sports cars/vans created with the Vehicle class and then implement the formulas(consumption and acceleration) I have written in the class?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseAMeaningfulSubjectLine. 90% of this forum is about Java GUIs. You can edit your post to change it.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!