准备写一个简单的进销存软件,记录一下遇到的问题的和每天的工作。
初步的想法是用Spring Boot搭建后端,MyBatis进行数据库操作;软件运行在Windows上,使用JavaFx来进行图形界面编程,如果可行的话,使用些好看的开源控件库美化一下。Maven做依赖管理。开发工具使用idea,数据库直接建在我的云服务器上部署好的mysql上,远程连接进行操作。
有时间的话再加上会接着写安卓端、小程序端或者网页版。网页版可能性比较大,因为想看看若依框架

1

需求分析,建数据库。

2. JavaFx

2.0 项目结构

2.1 依赖

关于Javafx的各种讲解和介绍很多,看了很多有了大致了解,这里使用maven管理该项目,新建项目后,加入相关依赖主要是openjfx的依赖,其他的可以根据自己的需要进行添加,我这里主要加了okhttp的依赖进行网络请求,需要注意的是okhttp中需要剔除安卓部分。

<dependency><groupId>org.openjfx</groupId><artifactId>javafx-controls</artifactId><version>13.0.2</version>
</dependency>
<dependency><groupId>org.openjfx</groupId><artifactId>javafx-fxml</artifactId><version>13.0.2</version></dependency><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>4.7.2</version><scope>compile</scope><exclusions><exclusion><groupId>com.google.android</groupId><artifactId>android</artifactId></exclusion></exclusions></dependency>

2.2 启动类

作为进销存系统,需要登陆界面和操作界面,所以将启动类进行了一些修改,start()和main()函数是保持不变的,将sence设置为静态数据,同时将FXMLLoader独立出来作为一个单独的函数。并另设一个setRoot函数,进行界面的切换。具体代码如下

public class App extends Application {private static Scene scene;@Overridepublic void start(Stage stage) throws IOException {Parent root = loadFXML("primary");//初始化界面scene = new Scene(root);stage.setScene(scene);stage.setTitle("进销存系统");stage.setResizable(false);//设置窗体不可改变大小stage.show();}static void setRoot(String fxml) throws IOException {Parent root = loadFXML(fxml);if(fxml.equals("secondary")){//转换到第二界面是可以进行一些其他操作}scene.setRoot(root);}public static Parent loadFXML(String fxml) throws IOException {FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));return fxmlLoader.load();}public static void main(String[] args) {launch();}
}

2.3控件的使用

可以使用scene builder进行可视化的界面编写
使用主标签中使用fx:controller设置界面对应的控制器

<AnchorPane xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.example.SecondaryController">

2.3.1 button

在fxml文件中加入一个button标签,设置点击时对应调用的函数

<Button layoutX="705.0" layoutY="78.0" onAction="#addtoChuhuoList" text="" />

在org.example.SecondaryController中具体实现addtoChuhuoList函数

2.3.2 choiceBox

choiceBox的设置操作和button类似,不同的是他作为下拉列表需要进行数据装配。这里装载到下拉列表中的全部是String。

private ChoiceBox choiceBox;//控件定义,对应fxml文件中设置的id
String[] s = new String[size];//定义字符串数组
//自行装载字符串数据
choiceBox.getItems().setAll(s);//完成装载,便可以正常显示
//需要更改下拉选项时,改变s中的值即可;

2.3.3 textField

private TextField t;
//获取文本框中输入的内容
String text = t.getValue().toString();
//清空
t.setText("");

2.3.4 tableView

fxml中控件布局的写法

<TableView fx:id="chuhuo_liebiao" layoutX="34.0" layoutY="117.0" prefHeight="383.0" prefWidth="966.0"><columns><TableColumn fx:id="chuhuo_liebiao_tiaoma" prefWidth="100.0" text="条码" /><TableColumn fx:id="chuhuo_liebiao_changjia" prefWidth="75.0" text="厂家" /><TableColumn fx:id="chuhuo_liebiao_xilie" prefWidth="75.0" text="系列" /><TableColumn fx:id="chuhuo_liebiao_pinming" prefWidth="75.0" text="品名" /><TableColumn fx:id="chuhuo_liebiao_xinghao" prefWidth="75.0" text="型号" /><TableColumn fx:id="chuhuo_liebiao_guige" prefWidth="75.0" text="规格" /><TableColumn fx:id="chuhuo_liebiao_jiage" prefWidth="75.0" text="价格" /><TableColumn fx:id="chuhuo_liebiao_shuliang" prefWidth="75.0" text="数量" /><TableColumn fx:id="chuhuo_liebiao_shanchu" prefWidth="75.0" text="删除" /></columns></TableView>

每一个列和表格都有他的id,在具体设置时会用到。
这里使用临时类进行表格数据的储存和装载。

//定义数据列表
public static ObservableList<linshiHuowu> chuhuo_liebiao_data = FXCollections.observableArrayList();
//在合适的地方定义对应实体类
public class linshiHuowu{private final SimpleStringProperty tiaoma;private final SimpleStringProperty changjia;private final SimpleStringProperty xilie;private final SimpleStringProperty pinming;private final SimpleStringProperty xinghao;private final SimpleIntegerProperty guige;private final SimpleIntegerProperty shuliang;private final SimpleIntegerProperty jiage;
}
//得到的数据新建linshiHuowu对象,并加入到数据列表中
linshiHuowu l = new linshiHuowu();
chuhuo_liebiao_data.add(l);
//数据装配
chuhuo_liebiao_tiaoma.setCellValueFactory(new PropertyValueFactory<linshiHuowu, String>("tiaoma"));//括号中字段对应实体类linshiHuowu中的属性chuhuo_liebiao_changjia.setCellValueFactory(new PropertyValueFactory<linshiHuowu, String>("changjia"));chuhuo_liebiao_xilie.setCellValueFactory(new PropertyValueFactory<linshiHuowu, String>("xilie"));chuhuo_liebiao_pinming.setCellValueFactory(new PropertyValueFactory<linshiHuowu, String>("pinming"));chuhuo_liebiao_xinghao.setCellValueFactory(new PropertyValueFactory<linshiHuowu, String>("xinghao"));chuhuo_liebiao_guige.setCellValueFactory(new PropertyValueFactory<linshiHuowu, Integer>("guige"));chuhuo_liebiao_jiage.setCellValueFactory(new PropertyValueFactory<linshiHuowu, Integer>("jiage"));chuhuo_liebiao_shuliang.setCellValueFactory(new PropertyValueFactory<linshiHuowu, Integer>("shuliang"));//设置删除按钮chuhuo_liebiao_shanchu.setCellFactory((col)->{TableCell<linshiHuowu, String> cell = new TableCell<>(){@Overrideprotected void updateItem(String item, boolean empty) {super.updateItem(item, empty);this.setText(null);this.setGraphic(null);if(!empty){Button shanchuButton = new Button("删除");this.setGraphic(shanchuButton);shanchuButton.setOnMouseClicked((me)->{linshiHuowu shanchuH = this.getTableView().getItems().get(this.getIndex());//从数据列表中删除该数据this.getTableView().getItems().remove(this.getIndex());});}}};return cell;});chuhuo_liebiao.setItems(chuhuo_liebiao_data);

tableView主要参考以下文章JavaFX表格控件TableView高级应用:自动添加ID列、删除操作列、单元格内容个性化渲染
tableView的官方文档翻译
有机会写一篇专门的tableView的各种操作的文章。

2.3.5 弹窗

Spring boot+ JavaFx实现进销存系统相关推荐

  1. 基于ssm(spring mybatis) java超市进销存系统源码设计

    超市进销存系统主要为商品的进货上架.销售收银.仓库存储提供线上管理的功能. 目标客户:中小型超市 客户的业务需求: 改变传统的人工管理,实现日常管理信息化: 通过对库存和销售信息的快速查询和处理,提高 ...

  2. spring boot 超市进销存系统源码

    spring boot 超市进销存系统源码 功能:本系统根据权限划分为三种用户:系统管理员,货物管理员,商品管理员(具体角色可以根据权限划分多个) 系统管理员默认功能:客户管理,供应商管理,商品管理, ...

  3. 手机进销存系统/供应链管理系统

    花了将近两个月的时间学习了一个企业级进销存项目,已经结束了两周多,现在终于有时间来对这个项目的学习做个总结了! 一.首先介绍下这个项目 (注:本人目前大三,专业为信息管理,与编程沾边不多.而我对编程很 ...

  4. Java项目:ssm+mysql医药进销存系统

    作者主页:夜未央5788 简介:Java领域优质创作者.Java项目.学习资料.技术互助 文末获取源码 功能介绍 医药进销存系统,主要功能包括: 公告管理:发布公告.公告列表: 生产管理:订单列表.增 ...

  5. 基于javaweb的商品进销存系统(java+vue+springboot+mybatis+mysql)

    基于javaweb的商品进销存系统(java+vue+springboot+mybatis+mysql) 运行环境 Java≥8.MySQL≥5.7.Node.js≥10 开发工具 后端:eclips ...

  6. Java项目:医药进销存系统(java+SSM+JSP+Layui+jQuery+Maven+mysql)

    源码获取:博客首页 "资源" 里下载! 功能介绍 医药进销存系统,主要功能包括: 公告管理:发布公告.公告列表: 生产管理:订单列表.增加生产.订单日志: 分店采购:分店审核.采购 ...

  7. 基于SSM的网页版进销存系统项目说明

    阿里云演示地址  演示账号:17705696620 ,演示密码:111111. 项目图片 项目背景 本人工作有8年时间,工作采用C语言进行金融POS终端的开发,主要是进行收单机构的支付平台的对接(85 ...

  8. 基于springboot+vue的超市进销存系统 elementui

    本次设计任务是要设计一个超市进销存系统,通过这个系统能够满足超市进销存系统的管理及员工的超市进销存管理功能.系统的主要功能包括:首页.个人中心.员工管理.客户管理.供应商管理.承运商管理.仓库信息管理 ...

  9. 进销存系统的一些事儿

    List与Set的区别: List有序[有索引].Set无序[没有索引.TreeSet底层使用二叉树结构实现,所以有序] List允许数据重复.Set不允许重复 实际开发中可以使用Set集合来去除重复 ...

最新文章

  1. Dojo QuickStart 快速入门教程 (1) Why Dojo
  2. 最新的B站弹幕和评论爬虫,你们要的冰冰来啦!
  3. [欧拉函数] Bzoj P2186 沙拉公主的困惑
  4. python 底层原理processpoolexecutor_python 多进程并行编程 ProcessPoolExecutor的实现
  5. Java 的内存管理机制是怎样的?
  6. treeset java_Java TreeSet iterator()方法与示例
  7. 基于机器视觉技术的瓷砖分色检测系统解析
  8. Java FileOutputStream
  9. 首次安装pytorch--实测可用
  10. Android客户端和服务器端数据交互的第一种方法
  11. Vue3动态路由与路由守卫
  12. ROS | 机器人操作系统简介
  13. 自适应在线聊天室源码
  14. mysql frm idb_MySQL利用frm和idb文件进行数据恢复MySQL利用frm和idb文件进行数据恢复...
  15. CodeForces 669A Little Artem and Presents
  16. apple账号被锁定且密码无法重设
  17. MySQL 优化:Explain 执行计划详解
  18. 学习Python会用到的8个软件,你用的哪些
  19. 数据挖掘Task 5: 模型融合
  20. 013-SpringCloud系列之SpringCloudAlibabaNacos服务注册和配置中心

热门文章

  1. Fluke万用表故障排除的几种方法
  2. 爬虫篇-小程序后台数据获取【附源码】
  3. 一些闲言碎语,好记星不如烂笔头(一)
  4. Mac 上好用的软件推荐
  5. iframe页面跳转刷新父页面窗口问题
  6. php——实现linux的定时任务
  7. 汉字转码和解码的使用
  8. 阐述:UTF-8编码是如何向下兼容ASCII码的?
  9. python--列表应用
  10. 在设置iis windows身份验证,出错:登录失败:用户帐户限制。可能的原因包括不允许空密码登录时间限制或强制的策略限制。