我正在尝试用两个 Jtables 创建一个 gui。一个输出对象 Bike(如果可用),一个输出对象 Rent。但是默认表模型不断返回空点异常。如何使用值数组列表填充 JTable,然后将其添加到 JPanel 网格布局。
我曾尝试使用默认表模型和 TableModel 以及搜索无用的解决方案。这是一个基本的 GUI 学校项目
存放数组的主类
public static final ArrayList<Bike> bikes = new ArrayList<>();
public static final ArrayList<Customer> customers = new ArrayList<>();
public static final ArrayList<Rent> rents = new ArrayList<>();
ArrayList<Rent> toRemove = new ArrayList<Rent>();
//Create variables
private int customerID = 0;
private final LocalDate currentDate = LocalDate.now();
//Main Method
public static void main(String args[]) {
//Create gui
GUI fr = new GUI();
fr.setSize(1000, 600);
fr.setVisible(true);
fr.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
//Create Initial Objects and fill Arrays
bikes.add(new Bike("Tarmac Disk Expert", 6000.00, "Mountain", true));
bikes.add(new Bike("Epic Hardtail Comp", 3500.00, "Mountain", true));
bikes.add(new Bike("Chisel Comp", 2000.00, "Road", true));
bikes.add(new Bike("Roubaix Sport", 3500.00, "Road", false));
bikes.add(new Bike("Turbo Levi Comp", 9500.00, "City", false));
bikes.add(new Bike("Venge Pro", 9400.00, "City", true));
bikes.add(new EBike("Turbo Como 2.0 650B", 4500.00, "Ebike", true, "Full Power"));
bikes.add(new EBike("Turbo Kenevo Expert", 9500.00, "Ebike", true, "Full Power"));
bikes.add(new EBike("Turbo Levo FSR", 5600.00, "Ebike", true, "Full Power"));
bikes.add(new EBike("Turbo Vado 4.0", 5600.00, "Ebike", true, "Power Assisted"));
bikes.add(new EBike("S-Works Turbo Levo", 4000.00, "Ebike", true, "Power Assisted"));
bikes.add(new EBike("Turbo Como 2.0 Low Entry", 6600.00, "Ebike", true, "Power Assisted"));
customers.add(new Customer(0001, "John Smith", true, "Roubaix Sport"));
customers.add(new Customer(0002, "Madamn Tuscoue", false, "N/A"));
神不在的星期二
眼眸繁星
叮当猫咪
随时随地看视频慕课网APP
相关分类