1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
public class MainStage extends Application {
private Group root;
private Scene scene;
private TabPane tabPane = new TabPane();
private BorderPane mainPane = new BorderPane();
private static final int LARGEUR = 1240;
private static final int HAUTEUR = 800;
private static Metier CoucheMetier;
/*
* Main
*/
public static void main(String[] args)
{
//*****Connect To DB
try
{
CoucheMetier = new Metier();
}
catch (ExceptionAccesBd e)
{
System.out.println("\nAccès à la BD impossible (" + e.getMessage() + ")");
System.exit(0);
}
// Launch App
MainStage.launch();
}
/*
* (non-Javadoc)
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
@Override
public void start(Stage stage)
{
root = new Group();
scene = new Scene(root,LARGEUR, HAUTEUR);
// Create TabPane
tabPane.setSide(Side.LEFT);
tabPane.setTabMinWidth(150);
tabPane.setTabMaxWidth(150);
tabPane.setTabMinHeight(300);
tabPane.setTabMaxHeight(300);
tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
//css
tabPane.getStyleClass().add("tabPane");
scene.getStylesheets().add("couchePrésentation/tabPane.css");
//Creation des Tab
//Tab1
Tab tabProduit = new Tab();
tabProduit.setGraphic(new Label("Produits"));
tabPane.getTabs().add(tabProduit);
tabProduit.getStyleClass().add("tab");
// SetContent To TabProduit
tabProduit.setContent(createTabProduit(tabProduit));
//Tab2
Tab tabCommandes = new Tab();
tabCommandes.setGraphic(new Label("Commandes"));
tabPane.getTabs().add(tabCommandes);
tabCommandes.getStyleClass().add("tab");
//Tab3
Tab tabClients = new Tab();
tabClients.setGraphic(new Label("Clients"));
tabPane.getTabs().add(tabClients);
tabClients.getStyleClass().add("tab");
mainPane.setCenter(tabPane);
mainPane.prefHeightProperty().bind(scene.heightProperty());
mainPane.prefWidthProperty().bind(scene.widthProperty());
root.getChildren().add(mainPane);
stage.setScene(scene);
stage.show();
}
/*
* CreateTabProduit ---> Tab1
*/
private Node createTabProduit(Tab tabProduit) {
AnchorPane panneauProduit = new AnchorPane();
panneauProduit.getStyleClass().add("PanneauProduit");
TableView<Vin> vinTable = new TableView<Vin>();
vinTable.getStyleClass().add("vinTable");
HBox hboxTop = new HBox();
hboxTop.getStyleClass().add("hboxTop");
HBox hboxFooter = new HBox();
hboxFooter.getStyleClass().add("hboxFooter");
VBox vboxRight = new VBox();
vboxRight.getStyleClass().add("vboxRight");
AnchorPane.setTopAnchor(hboxTop, 10.0);
AnchorPane.setLeftAnchor(vinTable, 10.0);
AnchorPane.setBottomAnchor(hboxFooter, 10.0);
AnchorPane.setBottomAnchor(vboxRight, 10.0);
panneauProduit.getChildren().addAll(vinTable,hboxTop,hboxFooter);
tabProduit.setContent(panneauProduit);
//création tableau vin
TableColumn<Vin, String> firstNameCol = new TableColumn<Vin, String>("Nom");
TableColumn<Vin, String> origineCol = new TableColumn<Vin, String>("origine");
TableColumn<Vin, String> milleCol = new TableColumn<Vin, String>("millésime");
vinTable.getColumns().addAll(firstNameCol, origineCol, milleCol);
//création hboxTop
TextField tfNom = new TextField();
TextField tfOrigine = new TextField();
TextField tfMillésime = new TextField();
Button btChercher = new Button("Chercher");
hboxTop.getChildren().addAll(tfNom,tfMillésime,tfOrigine,btChercher);
//création hboxFooter
Button btQuitter=new Button();
hboxFooter.getChildren().add(btQuitter);
//création vboxRight
Button btVin=new Button();
Button btAlcool=new Button();
Button btProduit=new Button();
vboxRight.getChildren().addAll(btVin,btAlcool,btProduit);
return null;
} |
Partager