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

如何在JavaFX中设置TextArea圆角样式?白角残留问题求助

解决JavaFX TextArea边角白色残留问题

你遇到的边角白色残留,是因为TextArea本身默认带有白色背景,且内部.content区域的默认内边距导致背景没完全覆盖圆角区域,露出了外层的白色。调整CSS即可解决:

#txa_movieEditComment {
    -fx-font-size: 17;
    -fx-focus-color: transparent;
    -fx-text-box-border: transparent;
    /* 隐藏TextArea本身的背景,避免露出白色 */
    -fx-background-color: transparent;
    -fx-background-radius: 12;
}

#txa_movieEditComment .content{
    -fx-background-color: #949494;
    -fx-background-radius: 12;
    /* 消除内边距,让背景填满整个圆角区域 */
    -fx-background-insets: 0;
    /* 可选:给文本加内边距,避免贴边 */
    -fx-padding: 8px;
}

#txa_movieEditComment .scroll-bar:vertical,
#txa_movieEditComment .scroll-bar:vertical .track,
#txa_movieEditComment .scroll-bar:vertical .track-background {
    -fx-background-color: #191919;
}

#txa_movieEditComment .scroll-bar:vertical .thumb {
    -fx-background-color: #949494;
    -fx-background-radius: 12;
}

核心修改点:

  • 给#txa_movieEditComment设置-fx-background-color: transparent,彻底隐藏外层默认白色背景
  • 给.content添加-fx-background-insets: 0,消除默认内边距,让灰色背景完全覆盖圆角区域
  • 可选的-fx-padding用来调整文本和边框的间距,避免文字紧贴圆角边缘

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 21:47:17