Kaynağa Gözat

fix:修复卖家中心列表没有占满宽度的问题

yangyi 1 ay önce
ebeveyn
işleme
ef18e0470c

+ 8 - 2
client/src/main/java/space/anyi/client/controller/MainController.java

@@ -562,6 +562,7 @@ public class MainController {
     // ── Seller ──
 
     private void setupMyBookTable() {
+        myBookTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
         myBookIdCol.setCellValueFactory(new PropertyValueFactory<>("bookId"));
         myBookTitleCol.setCellValueFactory(new PropertyValueFactory<>("title"));
         myBookPriceCol.setCellValueFactory(new PropertyValueFactory<>("sellingPrice"));
@@ -570,9 +571,14 @@ public class MainController {
             @Override
             protected void updateItem(Void item, boolean empty) {
                 super.updateItem(item, empty);
+                if (empty || getIndex() < 0 || getIndex() >= getTableView().getItems().size()) {
+                    setText(null);
+                    setGraphic(null);
+                    return;
+                }
                 Book book = getTableView().getItems().get(getIndex());
                 Integer status = book != null ? book.getStatus() : null;
-                if (empty || status == null) {
+                if (status == null) {
                     setText(null);
                     setGraphic(null);
                 } else {
@@ -621,7 +627,7 @@ public class MainController {
             @Override
             protected void updateItem(Void item, boolean empty) {
                 super.updateItem(item, empty);
-                if (empty) {
+                if (empty || getIndex() < 0 || getIndex() >= getTableView().getItems().size()) {
                     setGraphic(null);
                 } else {
                     Book b = getTableView().getItems().get(getIndex());