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

JavaFX作业

前言:

        在写这个作业之前,尝试在JavaFX中添加全局快捷键,测试了大概5个小时,到处找教程换版本,结果最后还是没找到支持Java8以上的(也有可能是我自己的问题),最后只能退而求其次,用jintellitype这个库来在原生swing里面添加了全局快捷键,算是圆了我对SAO Utils的一个执念吧,虽然实际上相差甚远。

        准备顶着数值分析考试和六级的压力(其实六级也没什么压力,主要室友太卷六级了。。人各有志,但是数值分析真不会啊)把这次的Java作业做了,虽然我明显感觉老师进度太快了,我群里面大三的都才学到这里,。。这才第七周啊,而且老师我只是大二啊,你这,,你这,,太夸张了这速度,还有就是讲课讲软件开发这块的注意事项,我个人觉得不如先确保我能开发一个软件比较好,。好了,废话就到这里。

作业:

1.安装向导

        提供一个setup.jar,模拟常见的软件安装交互特性。

        主要功能:上一步下一步的页面切换,按钮交互响应,页面创建

2.广播

        制作一个可以向子窗体同步信息的父窗体,内容由文本框输入,父窗体上放一个广播按钮和一个子窗体创建按钮,广播按钮点击后可以让父窗体输入文本显示到所有子窗体上,子窗体创建按钮点击后创建新的窗体(点击一次创建一次)。

        主要功能:文本输入,信息同步,按钮交互响应,窗体创建

3.监控

        制作一个可以收集自己创建的子窗体信息的父窗体,父窗体上放一个子窗体创建按钮,点击后创建新的窗体(点击一次创建一次),每个子窗体上都有一个按钮,点击后主窗体显示各窗体按钮各自的点击次数以及总和。

        主要功能:窗体创建,信息传递,按钮交互响应,计数计算

4.双向实时通讯

        创建一个主窗体和一个从窗体,主窗体上显示“已完成了   %”,从窗体上显示一个进度条(初始为0,在下方显示百分比)和两个按钮,一个增加按钮一个减少按钮,点击增加按钮,进度条增加1%,点击减少,进度条减少1%,从窗体的进度条和主窗体显示的  %相关联,同样的,主窗体上也有这两个按键。

        主要功能:按钮响应,信息双向同步,计数

5.微信群模拟

        用JavaFX模拟微信群聊功能。

        程序运行时可以动态创建多个窗体,在创建窗体时,选择一个群加入,每个窗体代表一个人,使用窗体背景色区分开各个群,在群内部,群成员发送的消息只有群成员间能看到。

完成(慢慢更新ing)

        1.详解有时间写

package com.example.test10;import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;public class SetupWizard extends Application {private Stage stage;private int currentPage;private VBox pageContainer;private final Button backButton = new Button("Back");private final Button nextButton = new Button("Next");public static void main(String[] args) {launch(args);}@Overridepublic void start(Stage primaryStage) {stage = primaryStage;stage.setTitle("Setup Wizard");BorderPane root = new BorderPane();Scene scene = new Scene(root, 400, 300);// 创建页面容器pageContainer = new VBox();pageContainer.setPadding(new Insets(20));pageContainer.setAlignment(Pos.CENTER_LEFT);// 创建页面VBox page1 = createPage1();VBox page2 = createPage2();VBox page3 = createPage3();// 添加页面到容器pageContainer.getChildren().addAll(page1, page2, page3);// 设置当前页面currentPage = 0;showCurrentPage();// 创建按钮容器HBox buttonContainer = new HBox();buttonContainer.setPadding(new Insets(20));buttonContainer.setAlignment(Pos.BOTTOM_RIGHT);// 设置布局HBox.setMargin(backButton, new Insets(0, 10, 0, 0));backButton.setOnAction(event -> showPreviousPage());nextButton.setOnAction(event -> showNextPage());buttonContainer.getChildren().addAll(backButton, nextButton);root.setCenter(pageContainer);root.setBottom(buttonContainer);nextButton.setDisable(true);stage.setScene(scene);stage.show();}private VBox createPage1() {VBox page = new VBox();page.setSpacing(10);Label label = new Label("Please read and accept the agreement:");CheckBox checkBox = new CheckBox("I agree to the above terms and conditions");checkBox.setOnAction(event -> nextButton.setDisable(!checkBox.isSelected()));page.getChildren().addAll(label, checkBox);return page;}private VBox createPage2() {VBox page = new VBox();page.setSpacing(10);Label label = new Label("Please enter the installation directory:");TextField directoryField = new TextField();directoryField.textProperty().addListener((observable, oldValue, newValue) ->nextButton.setDisable(newValue.isEmpty()));page.getChildren().addAll(label, directoryField);return page;}private VBox createPage3() {VBox page = new VBox();page.setSpacing(10);Label label = new Label("Please select an option:");Button exitButton = new Button("Exit");exitButton.setOnAction(event -> stage.close());HBox buttonContainer = new HBox();buttonContainer.setAlignment(Pos.BOTTOM_RIGHT);buttonContainer.getChildren().addAll(backButton, exitButton);page.getChildren().addAll(label, buttonContainer);return page;}private void showPreviousPage() {if (currentPage > 0) {currentPage--;showCurrentPage();}}private void showNextPage() {if (currentPage < pageContainer.getChildren().size() - 1) {currentPage++;showCurrentPage();nextButton.setDisable(true);}}private void showCurrentPage() {pageContainer.getChildren().forEach(page -> page.setVisible(false));pageContainer.getChildren().get(currentPage).setVisible(true);backButton.setDisable(currentPage == 0);nextButton.setDisable(currentPage == pageContainer.getChildren().size() - 1);}
}

http://www.lryc.cn/news/218794.html

相关文章:

  • 【使用Python编写游戏辅助工具】第五篇:打造交互式游戏工具界面:PySide6/PyQT高效构建GUI工具
  • 06.Oracle数据备份与恢复
  • 大航海时代Ⅳ 威力加强版套装 HD Version (WinMac)中文免安装版
  • 微信小程序 uCharts的使用方法
  • 面试算法54:所有大于或等于节点的值之和
  • 七月论文审稿GPT第二版:从Meta Nougat、GPT4审稿到LongLora版LLaMA、Mistral
  • PyTorch入门学习(十二):神经网络-搭建小实战和Sequential的使用
  • Linux shell编程学习笔记20:case ... esac、continue 和break语句
  • 树莓派4无法进入桌面模式(启动后出现彩色画面,然后一直黑屏,但是可以正常启动和ssh)
  • 花草世界生存技能
  • 执行npm install时老是安装不成功node-sass的原因和解决方案
  • 【MongoDB】集群搭建实战 | 副本集 Replica-Set | 分片集群 Shard-Cluster | 安全认证
  • 「Verilog学习笔记」四选一多路器
  • asp.net 创建docker容器
  • Linux项目自动化构建工具-make/Makefile使用
  • 【React】03.脚手架的进阶应用
  • WPF开源控件HandyControl——零基础教程
  • chinese-stable-diffusion中文场景文生图prompt测评集合
  • K-均值聚类算法
  • Xbox漫游指南
  • 降低毕业论文写作压力的终极指南
  • SELECT COUNT( * ) 与SELECT COUNT( 1 ) 区别
  • [python 刷题] 1248 Count Number of Nice Subarrays
  • 堆叠注入 [GYCTF2020]Blacklist1
  • 算法:Java构建二叉树并递归实现二叉树的前序、中序、后序遍历
  • 既然有了字节流,为什么还要有字符流?
  • 3+单细胞+代谢+WGCNA+机器学习
  • 音乐推荐与管理系统Python+Django网页界面+协同过滤推荐算法
  • (论文阅读15/100)You Only Look Once: Unified, Real-Time Object Detection
  • init进程启动过程