我有一个父类(super class) Car
,以及两个扩展 Car
的类( CarToRent
和 CarToSell
)
在类 CarCompany
我在构造函数中实现了一个 GUI。
我有一个按钮:
addCarToRentButton = new JButton("Add Car To Rent");
contentPane.add(addCarToRentButton);
addCarToRentButton.addActionListener(this);
我如何添加一个 Action 来监听这个,这样当按钮被点击时,它会将 3 个文本字段中的数据输入到
Car
的数组中。类(class)? (文本字段是 dailyRateTextField
、 descriptionTextField
和 downPaymentTextField
)。
最佳答案
关于Java 按钮 : adding an ActionListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10244105/