import java.sql.SQLException;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
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.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class BaseBorderPane extends BorderPane{
private GridPaneTop gridPaneTop =null;
private VBoxCenter vBoxCenter= null;
private GridPaneBottom gridPaneBottom =null;
DataManagement dm=new DataManagement();
TeachingInformation tInfo=null;
private Window source=null;
public static void main(String[] args) {
}
public BaseBorderPane(Window source,TeachingInformation tInfo){
this.source=source;
this.tInfo=tInfo;
gridPaneTop =new GridPaneTop(source);
vBoxCenter =new VBoxCenter(source);
gridPaneBottom =new GridPaneBottom(source);
Update(tInfo);
this.setTop(gridPaneTop);
this.setCenter(vBoxCenter);
this.setBottom(gridPaneBottom);
}
public boolean Update(TeachingInformation tInfo){
gridPaneTop.setData(tInfo);
vBoxCenter.setData(tInfo);
gridPaneBottom.setData(tInfo);
return true;
}
public GridPane getGridPaneTop() {
return gridPaneTop;
}
public VBoxCenter getVBoxCenter() {
return vBoxCenter;
}
public GridPane getGridPaneBottom() {
return gridPaneBottom;
}
}
class GridPaneTop extends GridPane{
TextField stdentidTF =new TextField("123");
//gender
RadioButton manRB= new RadioButton("男");
RadioButton womRB= new RadioButton("女");
ToggleGroup tg=new ToggleGroup();
CheckBox graduatedCkB=new CheckBox("毕业");
TextField nameTF =new TextField("000");
ComboBox<String> classnameCbB=new ComboBox<String>();
private Window source=null;
public GridPaneTop(Window source){
this.source=source;
this.setAlignment(Pos.CENTER);
this.setPadding(new Insets(11.5,12.5,13.5,14.5));//设置各项间距
this.setHgap(5.5);
this.setVgap(5.5);
this.add(new Label("学号:"), 0, 0);
this.add(stdentidTF, 1, 0);
manRB.setSelected(true);
this.add(manRB, 2, 0);
this.add(womRB, 3, 0);
this.add(graduatedCkB, 4, 0);
manRB.setToggleGroup(tg);
womRB.setToggleGroup(tg);
this.add(new Label("姓名:"), 0, 1);
this.add(nameTF, 1, 1);
this.add(new Label("班级:"), 2, 1);
classnameCbB.getItems().addAll("null","null","null","null");
this.add(classnameCbB, 3, 1);
register();
}
public void setData(TeachingInformation tInfo){
StudentInformation sInfo=tInfo.sInfo;
stdentidTF.setText(sInfo.getId());
if(sInfo.getGender().equals("1")){
manRB.setSelected(true);
womRB.setSelected(false);
}else{
manRB.setSelected(false);
womRB.setSelected(true);
}
if(sInfo.getGraduated().equals("1")){
graduatedCkB.setSelected(true);
}else{
graduatedCkB.setSelected(false);
}
nameTF.setText(sInfo.getName());
classnameCbB.getItems().clear();
for(Classes i:tInfo.classes){
classnameCbB.getItems().add(i.classid+" "+i.classname);
if(i.classid.equals(sInfo.getClassid())){
classnameCbB.getSelectionModel().select(i.classid+" "+i.classname);
}
}
if(sInfo.getClassid().equals("")){
classnameCbB.getSelectionModel().select(0);
}
}
public void register(){
stdentidTF.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
source.temporaryStudent.setId(stdentidTF.getText());
if(!source.tInfo.sInfo.getId().equals(source.temporaryStudent.getId())){
source.tInfo.sInfo.isSet=true;
System.out.println("setId:"+source.tInfo.sInfo.getId()+"->"+source.temporaryStudent.getId());
}
System.out.println("setId"+source.tInfo.sInfo.isSet);
}
});
nameTF.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
source.temporaryStudent.setName(nameTF.getText());
if(!source.tInfo.sInfo.getName().equals(source.temporaryStudent.getName())){
source.tInfo.sInfo.isSet=true;
System.out.println("setId:"+source.tInfo.sInfo.getName()+"->"+source.temporaryStudent.getName());
}
System.out.println("setName"+source.tInfo.sInfo.isSet+"->"+source.temporaryStudent.getName()+"<-");
}
});
manRB.setOnAction(e->{
source.temporaryStudent.setGender("1");
if(!source.temporaryStudent.getGender().equals(source.tInfo.sInfo.getGender())){
source.tInfo.sInfo.isSet=true;
System.out.println("Select "+"man->"+source.temporaryStudent.getGender());
}
});
womRB.setOnAction(e->{
source.temporaryStudent.setGender("0");
if(!source.temporaryStudent.getGender().equals(source.tInfo.sInfo.getGender())){
source.tInfo.sInfo.isSet=true;
System.out.println("Select "+"wom->"+source.temporaryStudent.getGender());
}
});
graduatedCkB.setOnAction(e->{
source.temporaryStudent.setGraduated(graduatedCkB.isSelected()?"1":"0");
if(!source.temporaryStudent.getGraduated().equals(source.tInfo.sInfo.getGraduated())){
source.tInfo.sInfo.isSet=true;
System.out.println("Select "+"getGraduated->"+source.temporaryStudent.getGraduated());
}
});
classnameCbB.setOnAction(e->{
if(source.tInfo.sInfo.getClassid()!=null&&classnameCbB.getValue()!=null){
source.temporaryStudent.setClassid(classnameCbB.getValue().substring(0,6));
if(!source.temporaryStudent.getClassid().equals(source.tInfo.sInfo.getClassid())){
source.tInfo.sInfo.isSet=true;
System.out.println("Select "+"getClassid->"+source.temporaryStudent.getClassid());
}
for(Classes i:source.tInfo.classes){
// System.out.println(i.classid+source.temporaryStudent.getClassid()+i.classid.equals(source.temporaryStudent.getClassid()));
if(i.classid.equals(source.temporaryStudent.getClassid())){
// System.out.println("ok"+i.classname);
source.temporaryStudent.setClassname(i.classname);
}
}
// System.out.println("Select "+"classnameCbB->"+classnameCbB.getValue());
// System.out.println("-"+source.temporaryStudent.getClassid()+"-"+source.temporaryStudent.getClassname()+"-");
}
});
}
}
class VBoxCenter extends VBox{
VBox vbox = new VBox();
HBox hbox1 = new HBox();
HBox hbox2 = new HBox();
// ScrollBar scrollBarH=new ScrollBar();
// ScrollBar scrollBarV=new ScrollBar();
TableView <GradeReport> table = new TableView<>();
TableColumn<GradeReport, String> subjectid = new TableColumn<GradeReport, String>("课程号");
TableColumn<GradeReport,String> subjectname = new TableColumn<GradeReport,String>("课程名");
TableColumn<GradeReport,String> grade = new TableColumn<GradeReport,String>("成绩");
static ObservableList<GradeReport> report =FXCollections.observableArrayList();
ComboBox<String> moresubject=new ComboBox<String>();
TextField newgrade=new TextField("0~100");
Button addsubject=new Button("添加成绩");
ComboBox<String> nowgrade=new ComboBox<String>();
Button deletegrade=new Button("删除成绩");
private Window source=null;
@SuppressWarnings("unchecked")
public VBoxCenter(Window source){
this.source=source;
// this.setBottom(scrollBarH);
// this.setRight(scrollBarV);
table.setEditable(true);//source.scene.widthProperty().divide(3)
subjectid.prefWidthProperty().bind(this.widthProperty().divide(3));//minWidthProperty().bind(this.widthProperty().divide(3));
subjectid.setCellValueFactory(new PropertyValueFactory<>("subjectid"));
subjectid.setSortType(TableColumn.SortType.DESCENDING);
subjectname.prefWidthProperty().bind(this.widthProperty().divide(3));//minWidthProperty().bind(this.widthProperty().divide(3));
subjectname.setCellValueFactory(new PropertyValueFactory<>("subjectname"));
grade.prefWidthProperty().bind(this.widthProperty().divide(3));//
grade.setCellValueFactory(new PropertyValueFactory<>("grade"));
// grade.setStyle("-fx-alignment:CENTER-RIGHT;");
grade.setCellFactory(e->{
TableCell cell = new TableCell<GradeReport, String>() {
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
setText(empty ? null : getString());
setGraphic(null);
}
private String getString() {
return getItem() == null ? "" : getItem().toString();
}
};
cell.setStyle("-fx-alignment: CENTER-RIGHT;");
return cell;
});
table.setItems(report);
table.getColumns().addAll(subjectid, subjectname, grade);
StackPane sp=new StackPane();
Text blockNumber = new Text("该学生尚无任何课程信息");
blockNumber.setFill(Color.RED);
blockNumber.setFont(Font.font("Amble Cn", FontWeight.BOLD, 18));
sp.getChildren().add(blockNumber);
table.setPlaceholder(sp);
vbox.getChildren().add(table);
hbox1.setAlignment(Pos.CENTER_RIGHT);
hbox1.getChildren().addAll(moresubject,newgrade,addsubject);
hbox2.setAlignment(Pos.CENTER_RIGHT);
hbox2.getChildren().addAll(nowgrade,deletegrade);
vbox.getChildren().addAll(hbox1,hbox2);
// table.seton
/* final TextField addFirstName = new TextField();
addFirstName.setPromptText("First Name");
addFirstName.setMaxWidth(firstNameCol.getPrefWidth());
final TextField addLastName = new TextField();
addLastName.setMaxWidth(lastNameCol.getPrefWidth());
addLastName.setPromptText("Last Name");
final TextField addEmail = new TextField();
addEmail.setMaxWidth(emailCol.getPrefWidth());
addEmail.setPromptText("Email"); */
this.getChildren().add(vbox);
register();
}
public void setData(TeachingInformation tInfo){
report.clear();
for(BaseGradeReport i:tInfo.sInfo.getBaseGradeReport()){
report.add(new GradeReport(i.getSubjectid(),
i.getSubjectname(),
""+i.getGrade()));
}
moresubject.getItems().clear();
try {
for(String i:DataManagement.selectSubjectidFromSubjects()){
Boolean find=false;
for(BaseGradeReport j:tInfo.sInfo.getBaseGradeReport()){
if(i.equals(j.getSubjectid())){
find=true;
}
}
if(!find){
System.out.println("-"+i+"-");
moresubject.getItems().add(i+" "+DataManagement.selectSubjectnameFromSubjects(i));
}
}
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
newgrade.setText("0~100");
nowgrade.getItems().clear();
for(BaseGradeReport i:tInfo.sInfo.getBaseGradeReport()){
nowgrade.getItems().add(i.getSubjectid()+"\t"+i.getSubjectname()+
"\t"+i.getGrade());
}
}
public void register(){
subjectid.setCellFactory(TextFieldTableCell.forTableColumn());
subjectid.setOnEditCommit(
new EventHandler<CellEditEvent<GradeReport, String>>() {
@Override
public void handle(CellEditEvent<GradeReport, String> t) {
//table.getSelectionModel().getSelectedItem().getClassid()
// System.out.println();
if(!t.getNewValue().equals(table.getSelectionModel().getSelectedItem().getSubjectid())){
source.tInfo.sInfo.isSet=true;
try {
String x=null;
for(String j:DataManagement.selectSubjectidFromSubjects()){
if(t.getNewValue().equals(j)){
for(BaseGradeReport i:source.tInfo.sInfo.getBaseGradeReport()){
if(table.getSelectionModel().getSelectedItem().getSubjectid().equals(i.getSubjectid())){
i.setSubjectid(t.getNewValue());
System.out.println(table.getSelectionModel().getSelectedItem().getSubjectid()
+ "->"+t.getNewValue());
StudentInformation.show(source.tInfo.sInfo);
x=j;
}
}
break;
}
}
if(x==null){
new ChildWindow().showNO();
}
}catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
// ((GradeReport) t.getTableView().getItems().get( t.getTablePosition().getRow()) ).setSubjectid(t.getNewValue());
// System.out.println(table.getSelectionModel().getSelectedItem().getSubjectid());
}
}
);
addsubject.setOnAction(e->{
if(newgrade.getText()!=null&&moresubject.getValue()!=null){
String s=moresubject.getValue().substring(0,6);
source.tInfo.sInfo.isSet=true;
try {
source.tInfo.sInfo.getBaseGradeReport().add(new BaseGradeReport(s,
DataManagement.selectSubjectnameFromSubjects(s),
String.valueOf(Integer.valueOf(newgrade.getText()))));
} catch (Exception e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
source.baseBorderPane.Update(source.tInfo);
}
});
// nowgrade;
deletegrade.setOnAction(e->{
if(nowgrade.getValue()!=null){
String s=nowgrade.getValue().substring(0,6);
source.tInfo.sInfo.isSet=true;
try {
for(BaseGradeReport i:source.tInfo.sInfo.getBaseGradeReport()){
if(i.getSubjectid().equals(s)){
source.tInfo.sInfo.getBaseGradeReport().remove(i);
break;
}
}
} catch (Exception e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
source.baseBorderPane.Update(source.tInfo);
});
}
public static class GradeReport {
public final SimpleStringProperty subjectid;
public final SimpleStringProperty subjectname;
public final SimpleStringProperty grade;
public GradeReport(String subjectid,String subjectname,String grade){
this.subjectid=new SimpleStringProperty(subjectid);;
this.subjectname=new SimpleStringProperty(subjectname);
this.grade=new SimpleStringProperty(grade);
}
public String getSubjectid() {
return subjectid.get();
}
public void setSubjectid(String string) {
subjectid.set(string);
}
public String getSubjectname() {
return subjectname.get();
}
public void setSubjectname(String string) {
subjectname.set(string);
}
public String getGrade() {
return grade.get();
}
public void setGrade(String string) {
grade.set(string);
}
}
}
class GridPaneBottom extends GridPane{
Button goTop=new Button("|<");
Button goLeft=new Button("<");
Button goRight=new Button(">");
Button goEnd=new Button(">|");
Button save=new Button("保存");
TextField goTF =new TextField("");
Button goButton =new Button("GO");
Button addStudent =new Button("新增学生");
Button deleteStudent=new Button("删除学生");
Label countStudent =new Label("共:"+StudentInformation.end+"名学生");
Label nowNumber =new Label("当前:第"+StudentInformation.number+"名学生");
private Window source=null;
public GridPaneBottom(Window source) {
this.source=source;
this.setAlignment(Pos.TOP_CENTER);
this.setPadding(new Insets(11.5,12.5,13.5,14.5));//设置各项间距
this.setHgap(5.5);
this.setVgap(5.5);
this.add(goTop, 0, 0);
this.add(goLeft, 1, 0);
this.add(goRight, 2, 0);
this.add(goEnd, 3, 0);
this.add(new Label(" 跳转至"), 4, 0);
goTF.setMaxWidth(60);
this.add(goTF, 5, 0);
this.add(goButton, 6, 0);
this.add(countStudent,7, 0);
this.add(save, 0, 1);
this.add(addStudent, 1, 1);
this.add(deleteStudent, 2, 1);
this.add(nowNumber,7, 1);
// this.setStyle("-fx-text-fill:white;-fx-background-color:green;");
// this.setStyle("-fx-background-color: rgb(78.0,163.0,248.0);");
/* BackgroundImage myBI= new BackgroundImage(new Image("image/sspuBottom.png"),
BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,
BackgroundSize.DEFAULT);
//then you set to your node
this.setBackground(new Background(myBI));*/
register();
}
public void setData(TeachingInformation tInfo){
countStudent.setText(" 共:"+StudentInformation.end+"名学生");
nowNumber.setText("当前:第"+StudentInformation.number+"名学生");
}
public void register(){
goTop.setOnAction(ne->{
System.out.println("goTop...");
if(source.tInfo.sInfo.isSet){
new ChildWindow().save(source);
}
if(source.down){
try {
source.tInfo.sInfo=DataManagement.greateStudent(StudentInformation.START);
source.temporaryStudent=source.tInfo.sInfo.clone();
source.baseBorderPane.Update(source.tInfo);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
});
goLeft.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent arg0) {
// TODO 自动生成的方法存根
if(source.tInfo.sInfo.isSet){
new ChildWindow().save(source);
}
if(source.down){
try {
source.tInfo.sInfo=DataManagement.greateStudent(StudentInformation.number-1);
source.temporaryStudent=source.tInfo.sInfo.clone();
source.baseBorderPane.Update(source.tInfo);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
System.out.println("goLeft...");
}
});
goRight.setOnAction(e->{
if(source.tInfo.sInfo.isSet){
new ChildWindow().save(source);
}
if(source.down){
try {
source.tInfo.sInfo=DataManagement.greateStudent(StudentInformation.number+1);
source.temporaryStudent=source.tInfo.sInfo.clone();
source.baseBorderPane.Update(source.tInfo);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
System.out.println("goRight...");
});
goEnd.setOnAction(e->{
if(source.tInfo.sInfo.isSet){
try {
new ChildWindow().save(source);
// source.tInfo.sInfo.saveStudentData(source.temporaryStudent,source.tInfo.sInfo);
} catch (Exception e1) {
// TODO 自动生成的 catch 块
new ChildWindow().showNO();
}
}
if(source.down){
try {
source.tInfo.sInfo=DataManagement.greateStudent(StudentInformation.end);
source.temporaryStudent=source.tInfo.sInfo.clone();
source.baseBorderPane.Update(source.tInfo);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
System.out.println("goEnd...");
});
goButton.setOnAction(e->{
if(source.tInfo.sInfo.isSet){
try {
new ChildWindow().save(source);
// source.tInfo.sInfo.saveStudentData(source.temporaryStudent,source.tInfo.sInfo);
} catch (Exception e1) {
// TODO 自动生成的 catch 块
new ChildWindow().showNO();
}
}
if(source.down){
if(goTF.getText()!=null){
try {
source.tInfo.sInfo=DataManagement.greateStudent(Integer.valueOf(goTF.getText()));
source.temporaryStudent=source.tInfo.sInfo.clone();
source.baseBorderPane.Update(source.tInfo);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
System.out.println("goTo...");
}
}
});
save.setOnAction(e->{
new ChildWindow().save(source);
});
addStudent.setOnAction(e->{
source.tInfo.sInfo=StudentInformation.sInfoFormat();
source.temporaryStudent=StudentInformation.sInfoFormat();
source.tInfo.sInfo.isSet=true;
source.baseBorderPane.Update(source.tInfo);
});
deleteStudent.setOnAction(e->{
//应该提示是否删除
new ChildWindow().showDelete(source);
source.baseBorderPane.Update(source.tInfo);
});
}
}
class ChildWindow{
public void save(Window source){
source.down=true;
Button YES = new Button("是");
Stage stage=new Stage();
YES.setOnAction(e->{
if(source.tInfo.sInfo.isSet){
if(source.temporaryStudent.getName().equals("")){
System.out.println("请重新输入名字!");
new ChildWindow().showString("名字为空,请重新输入15位以内文字!");
source.down=false;
stage.close();
return ;
}
if(source.temporaryStudent.getName().equals("限15个字符")){
System.out.println("请重新输入学生名字!");
new ChildWindow().showString("请重新输入学生名字!");
source.down=false;
stage.close();
return ;
}
if(source.temporaryStudent.getName().length()>30){
System.out.println("请重新输入名字!");
new ChildWindow().showString("名字过长,请重新输入15位以内文字!");
source.down=false;
stage.close();
return ;
}
if(source.temporaryStudent.getId().equals("")){
System.out.println("请重新输入11位有效学号");
new ChildWindow().showString("学号为空,请重新输入11位有效学号!");
source.down=false;
stage.close();
return ;
}
if(source.temporaryStudent.getId().length()>11){
System.out.println("请重新输入11位有效学号");
new ChildWindow().showString("学号过长,请重新输入11位有效学号!");
source.down=false;
stage.close();
return ;
}
System.out.println("save...true");
try {System.out.println("save...+");
if(source.tInfo.sInfo.isAddStudent){
if(!DataManagement.selectIsIdfromstudents(source.temporaryStudent.getId())){
DataManagement.Addstudent(source.temporaryStudent,source.tInfo.sInfo);
}
else{
new ChildWindow().showString("该学生已存在!");
source.down=false;
return ;
}
}else{
source.tInfo.sInfo.saveStudentData(source.temporaryStudent,source.tInfo.sInfo);
}
System.out.println("save...-");
new ChildWindow().showOK();
} catch (Exception e1) {
// TODO 自动生成的 catch 块
new ChildWindow().showNO();
}
source.tInfo.sInfo.isSet=false;
}else{
new ChildWindow().showOK();
System.out.println("save...false");
}
stage.close();
});
Button NO = new Button("否");
NO.setOnAction(e -> stage.close());
Label label = new Label("是否保存修改?");
HBox hbox=new HBox(50);
hbox.setAlignment(Pos.CENTER);
hbox.getChildren().addAll(YES, NO);
VBox layout = new VBox(10);
layout.getChildren().addAll(label ,hbox);
layout.setAlignment(Pos.CENTER);
Scene scene = new Scene(layout);
stage.setTitle("SAVE");
// window.initModality(Modality.APPLICATION_MODAL);
stage.setMinWidth(300);
stage.setMinHeight(150);
stage.setScene(scene);
stage.showAndWait();
}
public void showDelete(Window source){
Button YES = new Button("是");
Stage stage=new Stage();
YES.setOnAction(e-> {
try {
if(StudentInformation.end>0){
DataManagement.DeletStudent(source.tInfo.sInfo.getId());
new ChildWindow().showString("删除成功!");
source.tInfo.sInfo=DataManagement.greateStudent(StudentInformation.number-1);
source.temporaryStudent=source.tInfo.sInfo.clone();
}else{
new ChildWindow().showString("删除失败!");
}
} catch (Exception e1) {
// TODO 自动生成的 catch 块
stage.close();
new ChildWindow().showString("删除失败!");
}
stage.close();
});
Button NO = new Button("否");
NO.setOnAction(e -> stage.close());
Label label = new Label("是否删除学生?");
HBox hbox=new HBox(50);
hbox.setAlignment(Pos.CENTER);
hbox.getChildren().addAll(YES, NO);
VBox layout = new VBox(10);
layout.getChildren().addAll(label ,hbox);
layout.setAlignment(Pos.CENTER);
Scene scene = new Scene(layout);
stage.setTitle("SAVE");
// window.initModality(Modality.APPLICATION_MODAL);
stage.setMinWidth(300);
stage.setMinHeight(150);
stage.setScene(scene);
stage.showAndWait();
}
public void showString(String title){
Stage stage=new Stage();
Label label = new Label(title);
VBox layout = new VBox(10);
Button OK = new Button("OK");
OK.setOnAction(e -> stage.close());
layout.getChildren().addAll(label,OK);
layout.setAlignment(Pos.CENTER);
Scene scene = new Scene(layout);
stage.setTitle("SAVE");
// window.initModality(Modality.APPLICATION_MODAL);
stage.setMinWidth(300);
stage.setMinHeight(150);
stage.setScene(scene);
stage.showAndWait();
}
public void showOK(){
showString("保存成功!");
}
public void showNO(){
showString("输入错误,请重新检查格式!");
}
}
SQL数据库应用系统开发界面类
猜你喜欢
转载自blog.csdn.net/qq_39464369/article/details/88581853
今日推荐
周排行