Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

java - JavaFX如何删除按钮的边框(JavaFX how to remove the borders from button)

https://i.stack.imgur.com/Y76Fl.png

(https://i.stack.imgur.com/Y76Fl.png)

On this picture on left side - running java program, and right side - Scene builder layout.

(在此图片的左侧-运行Java程序,右侧-场景构建器布局。)

This is my github code: https://github.com/captsmile/calc

(这是我的github代码: https : //github.com/captsmi??le/calc)

  ask by user63180 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can do the following code in .css file

(您可以在.css文件中执行以下代码)

.button
 {
    -fx-background-color: transparent;
 }

This will make the color of button as the color of your application's background color(due to transparency).

(这将使按钮的颜色成为应用程序背景颜色的颜色(由于透明)。)

Furthermore you may also apply some effects to make your button looks more cool.

(此外,您还可以应用一些效果以使按钮看起来更酷。)

To add effects

(添加效果)

.button:hover 
{
  -fx-background-color: yellow;
} 
.button:pressed
{
  -fx-background-color: brown;
}

At the end ,you may attach the case file with your file(suppose index.java file in which you want to apply css) by writing following code in your index.java

(最后,可以通过在index.java中编写以下代码,将案例文件附加到文件(假设要在其中应用css的index.java文件)中)

scene.getStylesheets().add(getClass().getClassLoader().getResource("application.css").toExternalForm());

Where application.css is the css file with whole css code given above .

(其中application.css是上面提供了完整CSS代码的CSS文件。)

This application file must be present in your src folder.

(此应用程序文件必须存在于src文件夹中。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...