<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<!-- 入口main方法所在的类 改成方法的类名 -->
<mainClass>Apps</mainClass>
</manifest>
</archive>
<descriptorRefs>
<!-- 全依赖jar包的后缀名 -->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<!-- 添加此项后,可直接使用mvn package | mvn install -->
<executions>
<execution>
<id>make-assemble</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package model;
import java.time.LocalDateTime;
public class Match {
/**
* 比赛时间
*/
private String matchDateTime;
/**
* 比赛时间
*/
private String matchName;
/**
* 主队
*/
private String homeTeam;
/**
* 客队
*/
private String awayTeam;
/**
* 让球
*/
private String handicap;
/**
* 大小球
*/
private String goals;
/**
* 角球
*/
private String corner;
/**
* 半场比分
*/
private String halfScore;
/**
* 全场比分
*/
private String fullScore;
/**
* 半场角球
*/
private String halfCorner;
/**
* 全场角球
*/
private String fullCorner;
public Match() {
}
public Match(String matchDateTime, String matchName, String homeTeam, String awayTeam, String handicap, String goals, String corner,
String halfScore, String fullScore, String halfCorner, String fullCorner) {
this.matchDateTime = matchDateTime;
this.matchName = matchName;
this.homeTeam = homeTeam;
this.awayTeam = awayTeam;
this.handicap = handicap;
this.goals = goals;
this.corner = corner;
this.halfScore = halfScore;
this.fullScore = fullScore;
this.halfCorner = halfCorner;
this.fullCorner = fullCorner;
}
public String getMatchDateTime() {
return matchDateTime;
}
public void setMatchDateTime(String matchDateTime) {
this.matchDateTime = matchDateTime;
}
public String getMatchName() {
return matchName;
}
public void setMatchName(String matchName) {
this.matchName = matchName;
}
public String getHomeTeam() {
return homeTeam;
}
public void setHomeTeam(String homeTeam) {
this.homeTeam = homeTeam;
}
public String getAwayTeam() {
return awayTeam;
}
public void setAwayTeam(String awayTeam) {
this.awayTeam = awayTeam;
}
public String getHandicap() {
return handicap;
}
public void setHandicap(String handicap) {
this.handicap = handicap;
}
public String getGoals() {
return goals;
}
public void setGoals(String goals) {
this.goals = goals;
}
public String getCorner() {
return corner;
}
public void setCorner(String corner) {
this.corner = corner;
}
public String getHalfScore() {
return halfScore;
}
public void setHalfScore(String halfScore) {
this.halfScore = halfScore;
}
public String getFullScore() {
return fullScore;
}
public void setFullScore(String fullScore) {
this.fullScore = fullScore;
}
public String getHalfCorner() {
return halfCorner;
}
public void setHalfCorner(String halfCorner) {
this.halfCorner = halfCorner;
}
public String getFullCorner() {
return fullCorner;
}
public void setFullCorner(String fullCorner) {
this.fullCorner = fullCorner;
}
}
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.fxml.FXMLLoader;
/**
* javafx程序有三层,最外面的是Stage层,一个Stage就是一个独立的窗口。
* 在往里是Scene层,一个Scene就是一个窗口内部的一个状态。
* 在往里就是一个一个的node节点,节点可以是按钮、标签、文本等组件、
*/
public class IndexApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
// 设置窗口最大化
//primaryStage.setMaximized(true);
// 加载视图文件
FXMLLoader loader = new FXMLLoader(getClass().getResource("index.fxml"));
Scene scene = new Scene(loader.load());
primaryStage.setTitle("fxml窗体");
primaryStage.setScene(scene);
primaryStage.show();
}
}
package indexForm;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.event.ActionEvent;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import model.Match;
import services.IndexServices;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
public class IndexController implements Initializable {
private IndexServices services = new IndexServices();
@FXML
public HBox topHBox;
@FXML
public HBox bottomHBox;
@FXML
public VBox vBox;
@FXML
public Label label;
@FXML
public TextField txField;
@FXML
public Button searchButton;
@FXML
public Button exportButton;
@FXML
public TableView tableView;
@FXML
public TableColumn matchDateTime;
@FXML
public TableColumn matchName;
@FXML
public TableColumn homeTeam;
@FXML
public TableColumn awayTeam;
@FXML
public TableColumn handicap;
@FXML
public TableColumn goals;
@FXML
public TableColumn corner;
@FXML
public TableColumn halfScore;
@FXML
public TableColumn fullScore;
@FXML
public TableColumn halfCorner;
@FXML
public TableColumn fullCorner;
@FXML
public void searchHandle(ActionEvent e) throws IOException {
/* Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("警告");
alert.setHeaderText(null);
alert.setContentText(txField.getText());
alert.showAndWait();*/
/**初始化tableview数据*/
tableView.getItems().setAll(services.readerExcel());
}
@FXML
public void exportHandle(ActionEvent e) throws IOException {
List<Match> list = services.getMatchInfo(txField.getText());
/**导出Excel*/
services.exportExcel(list);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
/**初始化button样式*/
searchButton.setFont(Font.font("Microsoft YaHei", 18));
/**初始化TableColumn, 绑定对象属性*/
matchDateTime.setCellValueFactory(new PropertyValueFactory<Match, String>("matchDateTime"));
matchName.setCellValueFactory(new PropertyValueFactory<Match, String>("matchName"));
homeTeam.setCellValueFactory(new PropertyValueFactory<Match, String>("homeTeam"));
homeTeam.setCellValueFactory(new PropertyValueFactory<Match, String>("homeTeam"));
awayTeam.setCellValueFactory(new PropertyValueFactory<Match, String>("awayTeam"));
handicap.setCellValueFactory(new PropertyValueFactory<Match, String>("handicap"));
goals.setCellValueFactory(new PropertyValueFactory<Match, String>("goals"));
corner.setCellValueFactory(new PropertyValueFactory<Match, String>("corner"));
halfScore.setCellValueFactory(new PropertyValueFactory<Match, String>("halfScore"));
fullScore.setCellValueFactory(new PropertyValueFactory<Match, String>("fullScore"));
halfCorner.setCellValueFactory(new PropertyValueFactory<Match, String>("halfCorner"));
fullCorner.setCellValueFactory(new PropertyValueFactory<Match, String>("fullCorner"));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TableColumn?>
<VBox fx:id="vBox" xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="indexForm.IndexController" prefWidth="1480" prefHeight="960" spacing="50">
<HBox fx:id="topHBox">
<children>
<TextField fx:id="txField" prefWidth="800.0" prefHeight="45.0">
<HBox.margin>
<Insets top="50" left="260.0" bottom="0" right="0" />
</HBox.margin>
</TextField>
<Button fx:id="searchButton" text="搜索" onAction="#searchHandle" prefWidth="80.0" prefHeight="45.0" >
<HBox.margin>
<Insets top="50" left="0.0" bottom="0" right="0" />
</HBox.margin>
</Button>
<Button fx:id="exportButton" text="导出" onAction="#exportHandle" prefWidth="80.0" prefHeight="45.0" >
<HBox.margin>
<Insets top="50" left="0.0" bottom="0" right="0" />
</HBox.margin>
</Button>
</children>
</HBox>
<HBox fx:id="bottomHBox" alignment="CENTER"> <!--水平居中-->
<TableView fx:id="tableView" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets top="10.0" left="10.0" bottom="10.0" right="10.0" />
</HBox.margin>
<columns>
<TableColumn fx:id="matchDateTime" style="-fx-alignment: CENTER;-fx-font-family:'Consolas'; -fx-font-size:15;" prefWidth="180.0" sortable="false" text="比赛时间" />
<TableColumn fx:id="matchName" style="-fx-alignment: CENTER;-fx-font-family:'Consolas'; -fx-font-size:15;" prefWidth="80.0" sortable="false" text="赛事" />
<TableColumn fx:id="homeTeam" style="-fx-alignment: CENTER;-fx-font-family:'Consolas'; -fx-font-size:15;" prefWidth="120.0" sortable="false" text="主队" />
<TableColumn fx:id="awayTeam" style="-fx-alignment: CENTER;-fx-font-family:'Consolas'; -fx-font-size:15;" prefWidth="120.0" sortable="false" text="客队" />
<TableColumn fx:id="handicap" style="-fx-alignment: CENTER;-fx-font-family:'Consolas';-fx-font-size:15;" prefWidth="180.0" sortable="false" text="主队 让球 客队" />
<TableColumn fx:id="goals" style="-fx-alignment: CENTER;-fx-font-family:'Consolas';-fx-font-size:15;" prefWidth="180.0" sortable="false" text="高于 大小球 低于" />
<TableColumn fx:id="corner" style="-fx-alignment: CENTER;-fx-font-family:'Consolas';-fx-font-size:15;" prefWidth="180.0" sortable="false" text="高于 角球 低于" />
<TableColumn fx:id="halfScore" style="-fx-alignment: CENTER;-fx-font-family:'Consolas';-fx-font-size:15;" prefWidth="100.0" sortable="false" text="半场比分" />
<TableColumn fx:id="fullScore" style="-fx-alignment: CENTER;-fx-font-family:'Consolas';-fx-font-size:15;" prefWidth="100.0" sortable="false" text="全场比分" />
<TableColumn fx:id="halfCorner" style="-fx-alignment: CENTER;-fx-font-family:'Consolas';-fx-font-size:15;" prefWidth="100.0" sortable="false" text="半场角" />
<TableColumn fx:id="fullCorner" style="-fx-alignment: CENTER;-fx-font-family:'Consolas';-fx-font-size:15;" prefWidth="100.0" sortable="false" text="全场角" />
</columns>
</TableView>
</HBox>
</VBox>
标签:String,javafx,FXML,其他,new,import,public From: https://www.cnblogs.com/michaelShao/p/18139429