如何使RadioButton看起来像JavaFX中的常规Button [英] How to make a RadioButton look like regular Button in JavaFX

查看:210
本文介绍了如何使RadioButton看起来像JavaFX中的常规Button的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现类似工具箱的窗格,因此用户一次只能选择一个工具,然后我从 Button 切换到 RadioButton 表示其行为。

I'm implementing a toolbox-like pane, so user can only pick one tool at a time, and I switched from Button to RadioButton for its behavior.

但我发现 RadioButton 使用自己的皮肤点,但我仍然希望它显示为普通的按钮。我是JavaFX和FXML的初学者,所以任何人都知道如何实现这一目标?

But I found that RadioButton uses its own skin with a dot, however I still want it to display like a normal Button. I'm a beginner with JavaFX and FXML, so anyone know how can I accomplish this?

推荐答案

首先创建一个单选按钮,删除单选按钮样式,然后添加切换按钮样式,如

First Create a radio button, remove the radio-button style and then add the toggle-button style like

RadioButton radioButton=new RadioButton("Radio");
radioButton.getStyleClass().remove("radio-button");
radioButton.getStyleClass().add("toggle-button");

希望能解决您的问题

这篇关于如何使RadioButton看起来像JavaFX中的常规Button的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆