You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JFXDecorator使用问题:修改边框颜色及移除窗口缩放按钮

Hey there! Let's work through those two JFXDecorator issues you've run into—they're both easy fixes with the right methods and CSS tweaks.

1. Changing the Black Border Color

JFXDecorator relies on CSS for its styling, so you can override the default black border either with inline styles or an external CSS file (the latter is better for maintainability if you have multiple style changes down the line).

Option 1: Inline Style (Quick Fix)

Add this line right after initializing your decorator to set the border color and width directly in code:

decorator.setStyle("-fx-border-color: #2196F3; -fx-border-width: 2px;");

Replace #2196F3 with any hex color code, RGB value, or named color you prefer (e.g., red, rgb(76, 175, 80)).

Create a CSS file (e.g., decorator-styles.css) with this rule:

.jfx-decorator {
    -fx-border-color: #4CAF50; /* Your desired border color */
    -fx-border-width: 1.5px; /* Adjust border thickness as needed */
}

Then link the CSS file to your decorator:

decorator.getStylesheets().add(getClass().getResource("/path/to/decorator-styles.css").toExternalForm());
2. Removing the Window Zoom/Maximize Button

The setCustomMaximize(false) method you're using only disables the custom maximize behavior—it doesn't hide the button itself. To fully remove the zoom button, use the setMaximizeButtonVisible() method:

decorator.setMaximizeButtonVisible(false);

If you ever need to hide the minimize button too, you can use:

decorator.setMinimizeButtonVisible(false);

Updated Full Code Example

Here's how your start method would look with both fixes applied:

public void start(Stage primaryStage){ 
    JFXDecorator decorator = new JFXDecorator(primaryStage, gridContainer); 
    decorator.setCustomMaximize(false); 
    decorator.setText("Window Title"); 
    
    // Fix 1: Change border color
    decorator.setStyle("-fx-border-color: #2196F3; -fx-border-width: 2px;");
    
    // Fix 2: Hide zoom/maximize button
    decorator.setMaximizeButtonVisible(false);
    
    Scene scene = new Scene(decorator);
    primaryStage.setScene(scene);
    primaryStage.show();
}

内容的提问来源于stack exchange,提问作者Melowski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:10:09