javafx实现开窗效果

javafx实现开窗效果

在线运行:launch

界面设计:

1、移动窗口主要是使用GridPane存放Rectangle,然后设置Rectangle的fill和stroke属性,使其整个GridPane展示如窗户一样。Rectangle{ -fx-stroke-width:10; -fx-stroke:radial-gradient(radius 100%, #C60, #C90, #C60); -fx-stroke-type:inside; -fx-border-insets:5; }

2、通过css的设置,设置Rectangle的stroke属性,width宽度,颜色,stroke类型(inside则stroke的向里面延伸,举个例子:若rect宽100,你设置width为10,则实际展示还是100,不过空白的地方就只有90. 如type设置为outside,则展示为110, stroke占10,空白还是100)。在代码里还设置了rect的fill属性,使其有种朦胧的效果 RadialGradient gradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.rgb(255, 255, 255, 0.1)), new Stop(1, Color.rgb(255, 255, 255, 1)) }); rect1.setFill(gradient);

3、窗口的移动,仅仅是在MouseEnter和MouseExited事件中,使用Timeline改变GridPane的layoutx,y值。因为向上移动的部分不能够展示出来,所以还需要设置整个视口,所以对JFXeeWindow类可视进行裁剪,只显示固定的部分。 rect = new Rectangle(400,600); this.setClip(rect);

效果图:

源码下载

posted on 2013-03-29 12:58  韩细  阅读(1743)  评论(0编辑  收藏  举报