IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaFX Discussion :

Anchore pane dans une Tab (TabPane)


Sujet :

JavaFX

  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Août 2015
    Messages : 12
    Par défaut Anchore pane dans une Tab (TabPane)
    bonjour,

    je souhaite mettre un Anchore pane dans un tab de TabPane, afin d'y placer différente vbox et hbox.
    comme ceci:

    Nom : Capture.JPG
Affichages : 982
Taille : 240,4 Ko

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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;
    	}
    je ne comprends pas pourquoi mes éléments ne s'affiche pas....

    Merci d'avance.

  2. #2
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 900
    Billets dans le blog
    54
    Par défaut
    Ben dans createTabProduit(Tab tabProduit), tu fais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    tabProduit.setContent(panneauProduit);
    [...]
    return null;
    Et tu affectes ensuite la valeur de retour de la méthode (null) dans l'onglet :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    tabProduit.setContent(createTabProduit(tabProduit));
    Donc forcement, y aura rien qui va s'afficher.
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

Discussions similaires

  1. Lancer une fonction dans une tab bootstrap
    Par luangue dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 28/10/2015, 14h11
  2. [Cocoa] Double tabbar (ou tabbar dans une tab)
    Par kheraud dans le forum Apple
    Réponses: 2
    Dernier message: 08/12/2010, 16h19
  3. ouvrir une requette dans une tab dans internet explorer 7
    Par DjeinSlainteLand dans le forum VB 6 et antérieur
    Réponses: 0
    Dernier message: 11/06/2008, 17h06
  4. [Tableaux] resultat sql dans une tab html
    Par digger dans le forum Langage
    Réponses: 15
    Dernier message: 26/06/2006, 12h43
  5. Insérer une ligne automatiquement dans une autre tab
    Par davyd dans le forum Langage SQL
    Réponses: 10
    Dernier message: 29/03/2005, 17h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo