您现在的位置是:主页 > news > 网站开发技术入股协议/百度2022第三季度财报

网站开发技术入股协议/百度2022第三季度财报

admin2025/6/21 1:24:57news

简介网站开发技术入股协议,百度2022第三季度财报,中卫平面设计招聘,用asp做网站流程通过此项目能够掌握JavaFX桌面项目全流程开发。包括项目构建,编码,标题与任务栏图标,打包发布。 开发流程 1.创建JavaFX项目 打开你的Java IDE(例如IntelliJ IDEA、Eclipse等),并创建一个新的JavaFX项目…

网站开发技术入股协议,百度2022第三季度财报,中卫平面设计招聘,用asp做网站流程通过此项目能够掌握JavaFX桌面项目全流程开发。包括项目构建,编码,标题与任务栏图标,打包发布。 开发流程 1.创建JavaFX项目 打开你的Java IDE(例如IntelliJ IDEA、Eclipse等),并创建一个新的JavaFX项目…

通过此项目能够掌握JavaFX桌面项目全流程开发。包括项目构建,编码,标题与任务栏图标,打包发布。

开发流程

1.创建JavaFX项目

打开你的Java IDE(例如IntelliJ IDEA、Eclipse等),并创建一个新的JavaFX项目。

2.设计用户界面

在Scene Builder工具中设计一个简单的用户界面。您可以包括以下组件:一个列表视图,用于显示待办事项;一个文本字段,用于输入新任务;和三个按钮,用于添加、删除和清除所有任务。

3.编写控制器类

在Java代码中编写控制器类,并将其与您的UI关联。您需要在控制器类中实现添加、删除和清除功能,并将它们与对应的按钮事件关联起来。此外,您还需要为任务列表提供模型和适配器。在这个示例代码中,我们使用了JavaFX的FXML库和注释来定义用户界面和控制器类。initialize()方法用于初始化任务列表视图handleAddButtonAction()、handleDeleteButtonAction()和handleClearButtonAction()分别处理添加、删除和清除按钮的事件。

package sample;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import sample.control.Card;
import sample.control.LabelComb;

public class Controller {
@FXML
private GridPane gridPane;

@FXML
private ListView<HBox> todoListView;@FXML
private TextField newTodoTextField;public void initialize() {// Initialize the list view with some example tasksHBox card1 = getHBox("Task 1");HBox card2 = getHBox("Task 2");HBox card3 = getHBox("Task 3");ObservableList<HBox> tasks = FXCollections.observableArrayList(card1, card2, card3);todoListView.setItems(tasks);}@FXML
private void handleAddButtonAction(MouseEvent event) {String newTask = newTodoTextField.getText();HBox card = getHBox(newTask);if (!newTask.isEmpty()) {todoListView.getItems().add(card);newTodoTextField.clear();}
}private HBox getHBox(String newTask) {double width = todoListView.getPrefWidth();LabelComb labelComb = new LabelComb().init(100,newTask,"Green",Card.BASE_STYLE,null);return Card.initCard(width,20, Pos.BASELINE_CENTER,labelComb);
}@FXML
private void handleDeleteButtonAction(MouseEvent event) {int selectedIndex = todoListView.getSelectionModel().getSelectedIndex();if (selectedIndex >= 0) {todoListView.getItems().remove(selectedIndex);}
}@FXML
private void handleClearButtonAction(MouseEvent event) {todoListView.getItems().clear();
}
@FXML
public void handleCloseButtonAction(MouseEvent event) {Main.mainView.hide();
}

}

4.编译和运行

完成代码编写后,编译并运行您的应用程序。

以上就是一个简单的JavaFX ToDoList应用程序开发过程。

5.打包发布

  • 使用JavaFX默认工程开发程序可以使用Build Artifacts发布,见上篇博文:https://mp.weixin.qq.com/s?__biz=MzI2OTg4MTMxOA==&mid=2247483778&idx=1&sn=e9a128731f49e2c80e5a8c5fb5be9dd4&chksm=ead8db0bddaf521dafb6ea78439bdedab412b9be735c7f4670fefffbca33ac3c3e4ff1e16b73#rd
  • 使用JavaFX8 Maven插件zenjava进行native打包。注意要将ico图标文件放到项目工程对应目录/src/main/deploy/windows/todo-list.ico,同时要保证图标名称与打包后exe名称一致。Maven配置如下。
   <build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.5.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>com.zenjava</groupId><artifactId>javafx-maven-plugin</artifactId><version>8.8.3</version><configuration><mainClass>sample.Main</mainClass><appName>todo-list</appName><vendor>sample</vendor><needShortcut>true</needShortcut><bundleArguments><icon>${project.basedir}/src/main/deploy/windows/todo-list.ico</icon><installdirChooser>true</installdirChooser></bundleArguments></configuration></plugin></plugins></build>

点击maven插件中的jfx:native进行打包。
双击上图运行安装程序,可以选择安装目录,安装结束会自动生成桌面快捷方式。如下图所示,程序运行时,所有图标均已换成了我们自己安装的图标。
在这里插入图片描述