소스 검색

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

yangyi 1 개월 전
부모
커밋
ef18e0470c
1개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 2
      client/src/main/java/space/anyi/client/controller/MainController.java

+ 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());