当前位置: 首页 > news >正文

深圳政府门户网站建设评价西安seo霸屏

深圳政府门户网站建设评价,西安seo霸屏,网站备案和域名备案区别,自己建网站教程一、功能需要由来和大致效果 今天,我们要用javaFx来实现一个鼠标穿透画布的功能,该需求来自于在我们的javaFx桌面应用中,需要实现一个悬浮的桌面侧边工具栏,在工具栏中有画笔绘制,批注的功能,能够实现在任何…

        一、功能需要由来和大致效果

        今天,我们要用javaFx来实现一个鼠标穿透画布的功能,该需求来自于在我们的javaFx桌面应用中,需要实现一个悬浮的桌面侧边工具栏,在工具栏中有画笔绘制,批注的功能,能够实现在任何软件之上做笔记绘制,同时可以操作工具栏下一层的所有软件。

        我把这个功能提出来了,写了一个demo。大致效果如下:

 当程序启动后,程序的整个背景是透明的,除了程序中的组件,如按钮,这个时候即可以看到背面的任何软件,桌面,也能看到程序中的组件。此时,可以在整个桌面上进行画笔的绘制。

   当我点击鼠标穿透按钮后,画布上的笔记正常显示,同时,我的鼠标可以操作背面的任何软件

     通过上图中的圆圈圈起来的鼠标光标,可以得知,此时我是可以操作背面的程序的。


二、程序实现

      要实现以上效果,其实最关键的几点是:

    1)需要把javaFx中的Scene和stage的背景设置为透明

    scene.setFill(Color.TRANSPARENT);stage.initStyle(StageStyle.TRANSPARENT);

 2)一开始要能够看到当前javafx程序背面的东西,需要设置背景为透明,但不是完全透明,此时才可以在画布上绘制

pane.setStyle("-fx-background-color: rgba(255,255,255,0.1);");

3)要实现鼠标穿透当前画布,进而可以操作画布背面的其它软件,则需要将画布的背景设置为完全透明,透明度为0

pane.setStyle("-fx-background-color: rgba(255,255,255,0);");

4)当不需要操作背面的软件,希望回到画布的绘制时,再把背景的透明度设置为0.1即可。

 是不是很简单呢,好的。以下是实现的全部代码。

 

package test;import java.io.IOException;import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.shape.StrokeLineJoin;
import javafx.scene.shape.StrokeType;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;public class Test extends Application {boolean transpant = false;Polyline polyline;Button btn  ;public void start(Stage stage) throws Exception {// TODO Auto-generated method stubPane pane = new Pane();Rectangle2D bounds = Screen.getPrimary().getVisualBounds();double screenWidth = bounds.getWidth();double screenHeight = bounds.getHeight();btn = new Button("鼠标穿透");btn.setPrefWidth(100);btn.setPrefHeight(50);btn.setLayoutX(screenWidth/2);btn.setLayoutY(screenHeight/2);pane.getChildren().add(btn);Scene scene = new Scene(pane, screenWidth, screenHeight);scene.setFill(Color.TRANSPARENT);
//		scene.getStylesheets().add(ToolsBarStage.class.getResource("/res/css/default.css").toExternalForm());stage.initStyle(StageStyle.TRANSPARENT);//pane.setStyle("-fx-background-color: rgba(255,255,255,0.1);");stage.setScene(scene); // Place the scene in the stagestage.show();stage.setAlwaysOnTop(true);	//点击按钮后,切换为批注模式或操作模式btn.setOnMouseClicked(new EventHandler<Event>() {@Overridepublic void handle(Event event) {// TODO Auto-generated method stubif(!transpant) {//关键点,实现鼠标 穿透到可以操作桌面背景pane.setStyle("-fx-background-color: rgba(255,255,255,0);");transpant = true;}else {pane.setStyle("-fx-background-color: rgba(255,255,255,0.1);");transpant = false;}}});//根据鼠标的拖动和按压进行绘制pane.setOnMousePressed(e -> {//设置线条的样式StrokeType strokeType = StrokeType.CENTERED;int strokeMiterLimit = 5;StrokeLineJoin strokeLineJoin = StrokeLineJoin.BEVEL;StrokeLineCap strokeLineCap = StrokeLineCap.ROUND;polyline = new Polyline();polyline.setStrokeLineCap(strokeLineCap);polyline.setStrokeLineJoin(strokeLineJoin);polyline.setStrokeMiterLimit(strokeMiterLimit);polyline.setStrokeType(strokeType);polyline.setStrokeWidth(2);polyline.setSmooth(true);pane.getChildren().add(polyline);});//鼠标拖动绘制pane.setOnMouseDragged(e -> {polyline.getPoints().add(e.getSceneX());polyline.getPoints().add( e.getSceneY());});}public static void main(String[] args) {Test test = new Test();Platform.runLater(() -> {try {Stage stage = new Stage();test.start(stage);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}});}
}

http://www.dt0577.cn/news/4671.html

相关文章:

  • 俄罗斯电商平台有哪些系统优化app最新版
  • 沧州最新消息今天百度关键词优化方法
  • 南通建筑人才网seo关键词优化软件app
  • 武汉定制网页设计seo发帖网站
  • wordpress去掉搜索功能上海站群优化公司
  • 学校定制网站建设公司营业推广名词解释
  • 网站用php做的吗app推广公司怎么对接业务
  • 织梦如何做网站百度官网入口链接
  • 南山网站建设多少钱软文案例200字
  • 域名注册没有网站电商运营工资大概多少
  • 有网站源程序怎么做网站后台湖南有实力seo优化哪家好
  • 济南市住建厅官方网站国外免费建站网站搭建
  • 怎么看一个网站有没有做百度推广怎么推广游戏叫别人玩
  • 怎么用PHP做网站留言板宁波百度快照优化排名
  • 都是做面食网站广告行业怎么找客户
  • 沈阳快速建站公司有哪些百度地图人工客服电话
  • jquery 类似wordpress重庆网站seo诊断
  • 北京市建设工程造价管理协会网站东莞百度搜索优化
  • 西安市网站制作公司营销推广活动策划书模板
  • 仙居做网站在哪里做seo的基本工作内容
  • 北京网站备案拍照的地点宁波seo网站排名优化公司
  • 专门做win7系统的网站百度客服中心电话
  • 沈阳网站建设索王道下拉seo站长工具平台
  • 网站开发有多少种推广公司经营范围
  • wordpress更改了域名 图片不显示陕西seo主管
  • 鸡泽信息网seo如何优化排名
  • 做网站宝鸡蓝牙耳机网络营销推广方案
  • 阿里云自己做网站企业网站建设方案书
  • 沙井做网站的公司外包公司值得去吗
  • 专注与开发网站的北京网络公司优秀的营销案例