1、jtable的使用:
DefaultTableModel model;
Vector data=new Vector();
for(Email email:emails)
{
Vector row=new Vector();
row.add(email.getSend());
row.add(email.getContent());
row.add(email.getDate());
data.add(row);
}
Vector columnNames=new Vector();
columnNames.add("发件人");
columnNames.add("邮件内容");
columnNames.add("收件时间");
model=new DefaultTableModel(data, columnNames);
//GmailTableModel model = new GmailTableModel();
jTable1.setModel(model);
model.fireTableDataChanged();
2、javaFX加载fxml界面并且向controller传入参数
private void showMainUI(Stage newStage, String fxml) {
FXMLLoader loader = new FXMLLoader();
InputStream in = getClass().getResourceAsStream(fxml);
loader.setBuilderFactory(new JavaFXBuilderFactory());
loader.setLocation(getClass().getResource(fxml));
Pane page = null;
try {
page = (Pane) loader.load(in);
Scene scene = new Scene(page);
MainController controller = loader.getController();
controller.setStage(newStage);
newStage.setScene(scene);
newStage.sizeToScene();
newStage.show();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException ex) {
Logger.getLogger(MyGmail.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
3、javafx创建新窗体:
Stage stage = new Stage();
//create root node of scene, i.e. group
Group rootGroup = new Group();
//create scene with set width, height and color
Scene scene = new Scene(rootGroup, 200, 200, Color.WHITESMOKE);
//set scene to stage
stage.setScene(scene);
//set title to stage
stage.setTitle("New stage");
//center stage on screen
stage.centerOnScreen();
//show the stage
stage.show();