这个问题看起来很简单,但是我必须以一种特定的方式来实现我的代码,这导致了混乱。因此,在第 3 步中,我需要向事件处理程序注册源对象。ButtonHandler 类已经为我设置好了,但我不知道如何连接这些来注册按钮。我得到的资源似乎使用不同的逻辑来连接 javaFx 事件,我无法在此代码应该使用的逻辑与我得到的逻辑之间建立连接。
如果需要,我可以进一步详细说明并提供更多代码。
import java.util.ArrayList;
import javax.swing.plaf.basic.BasicButtonListener;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
//import all other necessary javafx classes here
//----
public class InputPane extends HBox
{
//GUI components
private ArrayList<Laptop> laptopList;
//The relationship between InputPane and PurchasePane is Aggregation
private PurchasePane purchasePane;
//----
private GridPane Gpane, RightPane;
private Label label, l2, l3, l4, l5, errL;
private Button btn1;
private TextField text, t2, t3, t4, t5;
private TextArea ta;
//constructor
public InputPane(ArrayList<Laptop> list, PurchasePane pPane)
{
laptopList = list;
purchasePane = pPane;
//Step #1: initialize each instance variable and set up the layout
//----
//create a GridPane hold those labels & text fields
//consider using .setPadding() or setHgap(), setVgap()
//to control the spacing and gap, etc.
//----
Gpane = new GridPane();
Gpane.setHgap(10);
Gpane.setVgap(10);
Gpane.setPadding(new Insets(30, 30, 10, 20));
label = new Label("Brand");
l2 = new Label("Model");
l3 = new Label("CPU(GHz)");
l4 = new Label("RAM(GB)");
l5 = new Label("Price($)");
动漫人物
慕后森
相关分类