java里jsp边框大小,设置边框大小

I want to make the border of a borderpane more round and bold.

I tested this code:

bpi.setStyle("-fx-background-color: linear-gradient(to bottom, #f2f2f2, #d4d4d4);"

+ " -fx-border: 12px solid; -fx-border-color: white; -fx-background-radius: 15.0;"

+ " -fx-border-radius: 15.0");

I get this result:

oT69J.png

How I can fix this?

解决方案

Why your current approach doesn't work

Don't use -fx-border (it doesn't even currently exist in JavaFX CSS).

Though there are other fx-border-* attributes such as -fx-border-color, -fx-border-width and -fx-border-radius, I wouldn't recommend them either.

Suggested Approach

Instead, use a combination of layered attributes:

-fx-background-color

-fx-background-insets

-fx-background-radius

You can find documentation on these CSS attribute features in the JavaFX CSS reference guide.

Although using -fx-background-* attributes for a border seems strange:

It is the way that all of the borders in the default JavaFX modena.css stylesheet are handled.

In my experience, when borders are rounded, applying borders in this way is simpler and gives better results than using -fx-border-* attributes.

Sample Code

For instance, here is an example fxml file which applies the standard modena.css style attribute values for "button like things" to a BorderPane. (modena.css comes from Java 8).

MGoXl.png

You can copy and paste the fxml and css, then load them up in SceneBuilder to see what it looks like.

button-like.css

.button-like {

-fx-background-color:

-fx-shadow-highlight-color,

-fx-outer-border,

-fx-inner-border,

-fx-body-color;

-fx-background-insets: 0 0 -1 0, 0, 1, 2;

-fx-background-radius: 3px, 3px, 2px, 1px;

}

button-like.fxml

minHeight="-Infinity" minWidth="-Infinity" prefHeight="131.0"

prefWidth="196.0" xmlns:fx="http://javafx.com/fxml/1"

xmlns="http://javafx.com/javafx/2.2">

styleClass="button-like"

/>

Note

You wouldn't actually want to apply the above exact style in your application for styling something like a BorderPane, as that is not a "button like thing". Using the same styling for something that is not a button would confuse the user. But the sample approach should demonstrate the general idea on layering backgrounds to achieve the style you want.

Additional Example

This example uses the same FXML layout file defined above, just a different stylesheet to achieve a different style.

xiV6z.png

AnchorPane {

-fx-background-color: #232732;

}

.button-like {

-fx-outer-border: white;

-fx-body-color: linear-gradient(to bottom, #FAFAFA, #EAEAEA);

-fx-background-color:

-fx-outer-border,

-fx-body-color;

-fx-background-insets: 0, 6;

-fx-background-radius: 6px, 0px;

-fx-background-image: url('http://icons.iconarchive.com/icons/appicns/simplified-app/64/appicns-Chrome-icon.png');

-fx-background-repeat: no-repeat;

-fx-background-position: center;

}

/**

Icon license: Free for non-commercial use.

Icon license Commercial usage: Not allowed

Icon source: http://appicns.com

*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值