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 :

Charger des informations de la base de données à la place des labels lors du chargement de ma page


Sujet :

JavaFX

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Lycéen
    Inscrit en
    Juillet 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 24
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Juillet 2018
    Messages : 15
    Points : 9
    Points
    9
    Par défaut Charger des informations de la base de données à la place des labels lors du chargement de ma page
    Bonjour à tous. Je suis un peu débutant en java et je développe une petite application pour un devoir à l'école. J'ai hésité à poser ma question ici ou dans la forum dédié a JDBC donc finalement je l'ai posté dans les deux ...
    Bon la technologie utilisé est JAVAFX et j’ai une vue avec des labels nom, prénom, tel... que je charge automatiquement comme enfants de mon conteneur dans un tableau en faisant la requête de sélection dans ma base de données ce qui me charge bien ma vue une seule fois car je n'est qu'un seul enregistrement. Mais maintenant au moment de remplacer le texte des labels chaque fois que ma vue est chargée ça me retourne plutôt un java.sql.sqlexcemption : after end of resultset.J'ai éssayer de résourdre le problème en mettant le chargement de ma vue dans un évènement mais maintenant j'ain un java.lang.nullpointerexception
    Bref je vous laisse regarder et merci d'avance.
    Voici le controlleur de la page d'acceuil
    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
     
    public void initialize(URL location, ResourceBundle resources) {
    		acceuilButton.setOnAction(event -> {
    		Reservation reservation = new Reservation();
    		try {
    			ResultSet rs = reservation.getAllReservation();
    			//rs.last();
    			//rs.beforeFirst();
    			int i = 0;
    			ResultSetMetaData resultmetadata = rs.getMetaData();
    			Node [] nodes = new Node[resultmetadata.getColumnCount()];
    			rs.beforeFirst();
    			while(rs.next()) {
    				try {
    					nodes[i] = (Node)FXMLLoader.load(getClass().getResource("/views/ListItemView.fxml"));
    					//give the items some effect
    					final int j = i;
    	                /*nodes[i].setOnMouseEntered(event -> {
    	                    nodes[j].setStyle("-fx-background-color : #0A0E3F");
    	                });
    	                nodes[i].setOnMouseExited(event -> {
    	                    nodes[j].setStyle("-fx-background-color : #02030A");
    	                });*/
    					Conteneur.getChildren().add(nodes[i]);
    					/*System.out.println(rs.getString("nom"));
    					System.out.println(rs.getString("prenom"));
    					System.out.println(rs.getString("tel"));
    					System.out.println(rs.getInt("numchambre"));
    					System.out.println(rs.getInt("prix"));
    					System.out.println(rs.getString("description"));
    					System.out.println(rs.getDate("datedebut"));
    					System.out.println(rs.getDate("datefin"));*/
    					//acceuilButton.setOnAction(event -> {
    						try {
    							ListItemController.setInformations(rs.getString("nom"), rs.getString("prenom"), rs.getString("tel"), rs.getInt("numchambre"), rs.getInt("prix"), rs.getString("description"), rs.getDate("datedebut"), rs.getDate("datefin"));
    						} catch (SQLException e) {
    							// TODO Auto-generated catch block
    							e.printStackTrace();
    						}
    					//});
     
    				} catch (IOException e) {
    					// TODO Auto-generated catch block
    					e.printStackTrace();
    				}
    				i++;
    			}
    		} catch (SQLException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		});
     
    		/*for(int i=0;i < nodes.length;i++) {
    			try {
    				nodes[i] = (Node)FXMLLoader.load(getClass().getResource("/views/ListItemView.fxml"));
    				//give the items some effect
    				final int j = i;
                    nodes[i].setOnMouseEntered(event -> {
                        nodes[j].setStyle("-fx-background-color : #0A0E3F");
                    });
                    nodes[i].setOnMouseExited(event -> {
                        nodes[j].setStyle("-fx-background-color : #02030A");
                    });
    				Conteneur.getChildren().add(nodes[i]);
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    		}*/
     
    	}
    Le controlleur de ma vue en question
    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
     
    package controllers;
     
    import java.net.URL;
    import java.sql.Date;
    import java.time.LocalDate;
    import java.util.ResourceBundle;
     
    import com.jfoenix.controls.JFXButton;
    import javafx.fxml.FXML;
    import javafx.fxml.Initializable;
    import javafx.scene.control.Label;
     
    public class ListItemController implements Initializable{
    	 @FXML
    	    private static Label nomClient;
     
    	    @FXML
    	    private static Label prenomClient;
     
    	    @FXML
    	    private static Label telClient;
     
    	    @FXML
    	    private static Label numChambreClient;
     
    	    @FXML
    	    private static Label prixChambreClient;
     
    	    @FXML
    	    private static Label categorieChambreClient;
     
    	    @FXML
    	    private static Label dateDebutSejourClient;
     
    	    @FXML
    	    private static Label dateFinSejourClient;
     
    	    @FXML
    	    private static JFXButton updateReservation;
     
    	    @FXML
    	    private static JFXButton deleteReservation;
     
    		@Override
    		public void initialize(URL location, ResourceBundle resources) {
    			// TODO Auto-generated method stub
     
    		}
     
    		public static void setInformations(String nom,String prenom,String tel,int numchambre,int prix, String categorie,Date datedebut, Date datefin) {
    			nomClient.setText(nom);
    			prenomClient.setText(prenom);
    			telClient.setText(tel);
    			numChambreClient.setText(Integer.toString(numchambre));
    			prixChambreClient.setText(Integer.toString(prix));
    			categorieChambreClient.setText(categorie);
    			dateDebutSejourClient.setText(datedebut.toString());
    			dateFinSejourClient.setText(datefin.toString());
    		}
    }
    Le code de mon model Reservation
    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
     
    package models;
     
    import java.sql.Connection;
    import java.sql.Date;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
     
    import application.DBConnection;
    import application.Parameter;
     
    public class Reservation {
    	DBConnection connection = new DBConnection(Parameter.HOST_DB, Parameter.USERNAME_DB, Parameter.PASSWORD_DB,
    			Parameter.IPHOST, Parameter.PORT);
    	private String codeClient;
    	private int numChambre;
    	private Date dateDebut;
    	private Date dateFin;
     
    	public Reservation(String codeClient, int numChambre, Date dateDebut, Date dateFin) {
    		this.codeClient = codeClient;
    		this.numChambre = numChambre;
    		this.dateDebut = dateDebut;
    		this.dateFin = dateFin;
    	}
     
    	public Reservation() {
     
    	}
     
    	public ResultSet getAllReservation() {
    		try {
    			Connection connect = connection.connexionDatabase();
    			String sql = "SELECT nom,prenom,client.tel,chambre.numchambre,prix,chambre.tel,prix,description,datedebut,datefin FROM reservation,client,chambre,categorie WHERE client.codeclient=reservation.codeclient  AND chambre.numchambre=reservation.numchambre AND categorie.id=chambre.idcategorie";
    			PreparedStatement ps = connect.prepareStatement(sql);
    			ResultSet rs = ps.executeQuery();
    			return rs;
    		} catch (Exception e) {
    			System.out.print(e.getMessage());
    		}
    		return null;
    	}
    }
    code de l'erreur
    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
     
    Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    	at controllers.ListItemController.setInformations(ListItemController.java:51)
    	at controllers.AcceuilFormController.lambda$0(AcceuilFormController.java:117)
    	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    	at javafx.event.Event.fireEvent(Event.java:198)
    	at javafx.scene.Node.fireEvent(Node.java:8411)
    	at javafx.scene.control.Button.fire(Button.java:185)
    	at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    	at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    	at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    	at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    	at javafx.event.Event.fireEvent(Event.java:198)
    	at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    	at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432)
    	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
    	at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    	at com.sun.glass.ui.View.notifyMouse(View.java:937)
    	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    	at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    	at java.lang.Thread.run(Unknown Source)
    Voici un peu comment cela se présente en interface
    Nom : Capturei.PNG
Affichages : 797
Taille : 181,6 Ko
    En rouge ce sont les labels de ma vue en question à modifier

  2. #2
    Rédacteur/Modérateur

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

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

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 854
    Points
    22 854
    Billets dans le blog
    51
    Par défaut
    Pour ta première exception, c'est une erreur JDBC donc il va falloir voir ça dans le forum approprié (car JDBC n'est pas ma spécialité). D'après le message que tu indiques, je penche pour le fait que tu as essayé d'itérer un poil trop loin en explorant le contenu de ton ResultSet.

    Pour la seconde erreur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    controllers.ListItemController.setInformations(ListItemController.java:51)
    il y a qq chose de null à la ligne 51 de la classe ListItemController. En supposant que le nombre de ligne correspond au code que tu as posté ca serai nomClient qui est null.
    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

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Lycéen
    Inscrit en
    Juillet 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 24
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Juillet 2018
    Messages : 15
    Points : 9
    Points
    9
    Par défaut
    OK merci beaucoup

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Lycéen
    Inscrit en
    Juillet 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 24
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Juillet 2018
    Messages : 15
    Points : 9
    Points
    9
    Par défaut
    Bonjour à tous et merci encore M. Bouye
    Je n'est pas vraiment résolu le problème mais je l'ai contourné en utilisant à la place de ma vue une JFXtreetableview
    Mais maintenant le soucis que j'ai est que j'aimerais avoir pour chaque enregistrement un boutton supprimer qui supprimera l'enregistrement de ma base données et dont je pourrais modifier le style.
    Je n'arrive pas à générer le boutton en question dans ma JFXTreetabeview

  5. #5
    Rédacteur/Modérateur

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

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

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 854
    Points
    22 854
    Billets dans le blog
    51
    Par défaut
    Faut passer par une cellule :

    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
    package treetableview.button;
     
    import javafx.application.Application;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.*;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
     
    import java.net.URL;
    import java.util.Objects;
    import java.util.Optional;
    import java.util.stream.IntStream;
     
    public final class Main extends Application {
        public static void main(final String... args) {
            launch(args);
        }
     
        @Override
        public void start(final Stage stage) throws Exception {
            final var nameColumn = new TreeTableColumn<Foo, String>("Name");
            nameColumn.setCellValueFactory(feature -> new SimpleObjectProperty<String>(String.valueOf(feature.getValue().getValue().index)));
            final var deleteColumn = new TreeTableColumn<Foo, Void>("Delete");
            deleteColumn.setCellFactory(column -> new TreeTableCell<Foo, Void>() {
                private Button renderer;
     
                @Override
                protected void updateItem(Void value, boolean empty) {
                    super.updateItem(value, empty);
                    Node graphic = null;
                    if (!empty) {
                        if (Objects.isNull(renderer)) {
                            renderer = new Button("Delete");
                            renderer.getStyleClass().add("delete-button");
                            renderer.setMaxWidth(Double.MAX_VALUE);
                            renderer.setOnAction(event -> mayBeDeleteRow());
                        }
                        graphic = renderer;
                    }
                    setText(null);
                    setGraphic(graphic);
                }
     
                private void mayBeDeleteRow() {
                    final int rowIndex = getTreeTableRow().getIndex();
                    final var treeItem = getTreeTableRow().getTreeItem();
                    final var item = treeItem.getValue();
                    System.out.printf("Request to delete row #%d: %s%n", rowIndex, item);
                    // @todo Request deletion of item in DB.
                    // @todo When done, remove tree item from tree.
                }
            });
            final var treeTableView = new TreeTableView<Foo>();
            treeTableView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
            treeTableView.setShowRoot(false);
            treeTableView.getColumns().setAll(nameColumn, deleteColumn);
            final var root = new StackPane(treeTableView);
            final var scene = new Scene(root);
            Optional.ofNullable(getClass().getResource("styles.css"))
                    .stream()
                    .map(URL::toExternalForm)
                    .forEach(scene.getStylesheets()::add);
            stage.setTitle("Test");
            stage.setScene(scene);
            stage.show();
            final var treeRoot = new TreeItem<Foo>();
            IntStream.range(0, 10)
                    .mapToObj(Foo::new)
                    .map(TreeItem::new)
                    .forEach(treeRoot.getChildren()::add);
            treeTableView.setRoot(treeRoot);
        }
     
        private static class Foo {
            private final int index;
     
            public Foo(final int index) {
                this.index = index;
            }
     
            @Override
            public String toString() {
                return String.format("Foo #%d", index);
            }
        }
    }
    Apres faut trouver le bon selecteur CSS pour le styling :

    Code CSS : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    .tree-table-cell .delete-button {
        -fx-text-fill: red;
    }
    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

  6. #6
    Futur Membre du Club
    Homme Profil pro
    Lycéen
    Inscrit en
    Juillet 2018
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 24
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Lycéen

    Informations forums :
    Inscription : Juillet 2018
    Messages : 15
    Points : 9
    Points
    9
    Par défaut
    Bonsoir Bouye!
    J'ai éssayer votre code en le modifiant un peu bien sur vu que je nai pas jdk 10 j'utilise plutôt le 1.8 et quand j'essaie de modifier mon environement pour le jdk 10 ca ne reconnait plus les librairies javafx.
    En gros j'ai saisie votre code en e modifiant un peu mais maintenant j'ai les erreus suivantes :
    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
    Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    	at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
    	at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
    	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    	at javafx.event.Event.fireEvent(Event.java:198)
    	at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3470)
    	at javafx.scene.Scene$ClickGenerator.access$8100(Scene.java:3398)
    	at javafx.scene.Scene$MouseHandler.process(Scene.java:3766)
    	at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432)
    	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
    	at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    	at com.sun.glass.ui.View.notifyMouse(View.java:937)
    	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    	at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.reflect.InvocationTargetException
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at sun.reflect.misc.Trampoline.invoke(Unknown Source)
    	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
    	at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
    	... 33 more
    Caused by: java.lang.ClassCastException: controllers.AcceuilFormController$9 cannot be cast to javafx.beans.value.ObservableValue
    	at javafx.scene.control.TreeTableColumn.getCellObservableValue(TreeTableColumn.java:563)
    	at javafx.scene.control.TreeTableColumn.getCellObservableValue(TreeTableColumn.java:548)
    	at javafx.scene.control.TreeTableCell.updateItem(TreeTableCell.java:635)
    	at javafx.scene.control.TreeTableCell.indexChanged(TreeTableCell.java:457)
    	at javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:116)
    	at com.sun.javafx.scene.control.skin.TableRowSkinBase.updateCells(TableRowSkinBase.java:533)
    	at com.sun.javafx.scene.control.skin.TreeTableRowSkin.updateCells(TreeTableRowSkin.java:220)
    	at com.sun.javafx.scene.control.skin.TableRowSkinBase.init(TableRowSkinBase.java:147)
    	at com.sun.javafx.scene.control.skin.TreeTableRowSkin.<init>(TreeTableRowSkin.java:89)
    	at javafx.scene.control.TreeTableRow.createDefaultSkin(TreeTableRow.java:522)
    	at javafx.scene.control.Control.impl_processCSS(Control.java:872)
    	at javafx.scene.Node.processCSS(Node.java:9056)
    	at javafx.scene.Node.applyCss(Node.java:9153)
    	at com.sun.javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1964)
    	at com.sun.javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1797)
    	at com.sun.javafx.scene.control.skin.VirtualFlow.getCellLength(VirtualFlow.java:1879)
    	at com.sun.javafx.scene.control.skin.VirtualFlow.computeViewportOffset(VirtualFlow.java:2528)
    	at com.sun.javafx.scene.control.skin.VirtualFlow.layoutChildren(VirtualFlow.java:1189)
    	at javafx.scene.Parent.layout(Parent.java:1087)
    	at javafx.scene.Parent.layout(Parent.java:1093)
    	at javafx.scene.Parent.layout(Parent.java:1093)
    	at javafx.scene.Parent.layout(Parent.java:1093)
    	at javafx.scene.Parent.layout(Parent.java:1093)
    	at javafx.scene.Scene.doLayoutPass(Scene.java:552)
    	at javafx.scene.Scene.preferredSize(Scene.java:1646)
    	at javafx.scene.Scene.impl_preferredSize(Scene.java:1720)
    	at javafx.stage.Window$9.invalidated(Window.java:864)
    	at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)
    	at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
    	at javafx.stage.Window.setShowing(Window.java:940)
    	at javafx.stage.Window.show(Window.java:955)
    	at javafx.stage.Stage.show(Stage.java:259)
    	at application.Main.changeScreen(Main.java:85)
    	at controllers.LoginFormController.handleloginButtonClicked(LoginFormController.java:47)
    	... 43 more
    En gros ça n'arrive pas a chargé ma classe d'acceuil qui contient votre code la
    Voici le code
    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
    final JFXTreeTableColumn actions = new JFXTreeTableColumn<InfosReservation,Void>("Actions");
    	        actions.setPrefWidth(120);
    	        actions.setCellValueFactory(column -> new JFXTreeTableCell<InfosReservation, Void>(){
    				private JFXButton renderer;
    	        	public void updateItem(Void value, boolean empty) {
    					// TODO Auto-generated method stub
    					super.updateItem(value, empty);
    					Node graphic = null;
    					if(!empty) {
    						if(Objects.isNull(renderer)) {
    							renderer = new JFXButton("Delete");
    							renderer.getStyleClass().add("delete-button");
    							renderer.setMaxWidth(Double.MAX_VALUE);
    							renderer.setOnAction(event -> mayBeDeleteRow());
    						}
    						graphic = renderer;
    					}
    					setText(null);
    					setGraphic(graphic);
    				}
     
    	        	private void mayBeDeleteRow() {
    	        		final int rowIndex = getTreeTableRow().getIndex();
    	        		final TreeItem treeitem = getTreeTableRow().getTreeItem();
    	        		final Object item = treeitem.getValue();
    	        		System.out.println("Request to delete row "+rowIndex+" "+item);
    	        	}
    	        });

  7. #7
    Rédacteur/Modérateur

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

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

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 854
    Points
    22 854
    Billets dans le blog
    51
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Caused by: java.lang.ClassCastException: controllers.AcceuilFormController$9 cannot be cast to javafx.beans.value.ObservableValue
    Tu sembles avoir un soucis dans une valeur retournée par une colonne.

    quand j'essaie de modifier mon environement pour le jdk 10 ca ne reconnait plus les librairies javafx.
    C'est pas normal puisque JavaFX 10 est toujours inclus dans le JDK 10 (c'est qu'à partir du 11 qu'il est plus inclus dedans). Ensuite faut pas avoir peur de var, pour faire fonctionner le code dans le JDK 8 ou 9 il suffit de remplacer var par la classe appropriée.
    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. Réponses: 8
    Dernier message: 10/03/2009, 15h25
  2. Réponses: 2
    Dernier message: 05/07/2007, 18h19
  3. ajouter des informations dans la base de données
    Par gentil dans le forum Hibernate
    Réponses: 7
    Dernier message: 12/04/2007, 11h15
  4. Jtree avec des informations d'une base de données
    Par Lebas dans le forum Composants
    Réponses: 4
    Dernier message: 23/01/2007, 16h27
  5. Réponses: 5
    Dernier message: 01/12/2006, 10h00

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