Partage
  • Partager sur Facebook
  • Partager sur Twitter

Main en java avec XML interface

14 août 2017 à 18:31:42

Bonjour,
J'ai actuellement un projet à réaliser, je dois faire une interface de borne de commande de fast food.
J'ai finis mes vues sur scene builder, je suis donc actuellement en train de réaliser l'appli avec Eclipse
Le problème : J'ai créer mon main, ainsi que les class pour mes vues et le controller, mais lorsque je le lance j'ai des dizaines d'erreurs et je ne comprends absolument pas d'où elles viennent ..
Je vous joins un screen, je suis relativement début et complètement perdu actuellement.
Le but final est d'avoir les views qui s'enchaine grâce au lien et au clique sur chaque bouton, les ingrédients seront rentrés en dur
Sorry pour la taille des images j'ai pas trouver comment mieux faire ^^
Je vous remercie, je suis ouvert à toutes suggestions, conseils, et résolution de problèmes :D
Merci à vous et bonne soirée !

-
Edité par Gnolls 14 août 2017 à 18:34:43

  • Partager sur Facebook
  • Partager sur Twitter
15 août 2017 à 10:18:39

Salut. Pour poster ton code il y a la balise de code(bouton </> , choisis java et colle ton code). Pourrais tu poster toute la stackTrace(les erreurs en rouge). Ton fichier "Home.fxml" est placé où?
  • Partager sur Facebook
  • Partager sur Twitter
15 août 2017 à 21:06:34

Hello,

Merci pour ta réponse !

Voici le code de mon main :

package controller;
	
import view.HomeControl;
import javafx.application.Application;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import model.CHamburger;


public class Main extends Application 
{

    
	 @Override


    public void start(Stage FirstStage) throws Exception 
    {
    	int height = 1800;
    	int width  = 1800;
    	
    	//On charge le fichier FXML
        FXMLLoader loader = new FXMLLoader();
        Parent root = FXMLLoader.load(getClass().getResource("../view/Home.fxml"));
        
        //HomeController HomeController = (HomeController) loader.getController();
        //HomeController.setStage(FirstStage);

        //On crée l'objet scene
        Scene scene = new Scene(root, height, width);

        FirstStage.setTitle("Page de Veille");
        FirstStage.setScene(scene);
        FirstStage.show();
        
        //On lance la création des burgers
        
    }

    public static void main(String[] args) {
        launch(args);
    }
    
    
}

Et voici les erreurs que j'obtiens : 

Exception in Application start method

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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)

at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)

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.launcher.LauncherHelper$FXHelper.main(Unknown Source)

Caused by: java.lang.RuntimeException: Exception in Application start method

at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)

at java.lang.Thread.run(Unknown Source)

Caused by: javafx.fxml.LoadException: 

/C:/Users/Fuchs%20Alexandre/eclipse-workspace/Final/bin/view/Home.fxml:7

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)

at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)

at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)

at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)

at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)

at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)

at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)

at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)

at controller.Main.start(Main.java:32)

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)

at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)

at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)

at java.security.AccessController.doPrivileged(Native Method)

at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)

at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)

at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)

... 1 more

Caused by: java.lang.ClassNotFoundException: View.HomeController

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)

... 22 more

Exception running application controller.Main

Je suis vraiment perdu et je ne comprends même pas les erreurs :/
Mon fichier Home est dans les view :

 

merci et bonne soirée !

  • Partager sur Facebook
  • Partager sur Twitter
15 août 2017 à 22:24:01

Y a pas de quoi. Excuse moi, mais on dirait qu'il te manque des bases. Ce message "Caused by: java.lang.ClassNotFoundException: View.HomeController" est plutôt clair non? La classe "HomeController"(du package view) n'existe pas, effectivement tu l'as appelée "HomeControl". Je te conseille de créer un dossier nommé "resources" dans le dossier "src" et de créer ensuite un autre dossier nommé "fxml" dans le dossier "resources" et d'y placer tous tes fichiers .fxml

Ensuite tu fais

Parent root = FXMLLoader.load(getClass()
.getClassLoader()
.getResource("resources/fxml/Home.fxml"));



-
Edité par kulturman 15 août 2017 à 22:25:47

  • Partager sur Facebook
  • Partager sur Twitter
16 août 2017 à 12:37:07

Hello !

Ca ma l'air d'avancé un peu mais j'ai toujours rien qui s'affiche mon dieu ..

Voilà mon arborescence 

et le code de mon main qui n'a normalement pas changé : 

package controller;
	
import javafx.application.Application;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import model.CHamburger;


public class Main extends Application 
{

    
	 @Override


    public void start(Stage FirstStage) throws Exception 
    {
    	int height = 1800;
    	int width  = 1800;
    	
    	//On charge le fichier FXML
        FXMLLoader loader = new FXMLLoader();
        Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("Home.fxml"));
        
        //HomeController HomeController = (HomeController) loader.getController();
        //HomeController.setStage(FirstStage);

        //On crée l'objet scene
        Scene scene = new Scene(root, height, width);

        FirstStage.setTitle("Page de Veille");
        FirstStage.setScene(scene);
        FirstStage.show();
        
        //On lance la création des burgers
        
    }

    public static void main(String[] args) {
        launch(args);
    }
    
    
}

Est ce que je devrais tout reprendre de 0 ?

Je suis encore perdu :(

Merci encore à toi !

  • Partager sur Facebook
  • Partager sur Twitter
16 août 2017 à 13:20:31

Tu n'as pas fait ce que j'ai dit, c'est

Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ressources/fxml/Home.fxml"));

Tu as un message d'erreur?

  • Partager sur Facebook
  • Partager sur Twitter
17 août 2017 à 12:10:07

Ah j'avais remplacer la ligne de code mais ça m'avait des erreurs, en cherchant hier j'ai réussis à résoudre l'erreur en gardant la ligne de code, ce qui m'ouvre une interface avec le bouton pour démarrer dessus :DDDD

J'ai encore cependant 2 petites questions : 

Est ce que les erreurs dans mes classes comme ça sont graves ?

Et ensuite pour finir, quand je clique sur le boutons, je repars pour 1561651 erreurs ... j'en aurais toujours ou il y a moyen de régler ça ? ...

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.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:8413)
	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.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:381)
	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$354(GlassViewEventHandler.java:417)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
	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$148(WinApplication.java:191)
	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:1771)
	... 48 more
Caused by: java.lang.NullPointerException: inputStream is null.
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2455)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
	at View.HomeController.deverouillerMenu(HomeController.java:35)
	... 58 more

Je te remercie encore tu me sauves bien la vie :) !

Bonne journée à toi

  • Partager sur Facebook
  • Partager sur Twitter
17 août 2017 à 12:44:52

Au moins on a une fenêtre maintenant :D. Pour ce qui est de tes lignes avec fond rouge(à peu près) ce ne sont pas des erreurs, mais je n'utilise pas eclipse donc je ne saurais pas te dire comment enlever ça. Hmm, apprends à lire les erreurs

Caused by: java.lang.NullPointerException: inputStream is null.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2455)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
at View.HomeController.deverouillerMenu(HomeController.java:35)
C'est sûrement le même prblème qu'avec tes fichiers .fmxl. Je te propose de créer un dossier "images" dans le dossier "ressources" et d'y mettre tes images, ensuite tu fais la même chose.
PS:c'est un projet personnel?
  • Partager sur Facebook
  • Partager sur Twitter
18 août 2017 à 11:38:58

Ouii :) !
Super bah je vois voir ça, en faisant quelques recherches je devrais pourvoir me débrouiller !

J'ai repris un projet en cours que je dois finir seul oui :/

Merci et bonne journée ! 

  • Partager sur Facebook
  • Partager sur Twitter
25 février 2019 à 23:11:39

kulturman a écrit:

Y a pas de quoi. Excuse moi, mais on dirait qu'il te manque des bases. Ce message "Caused by: java.lang.ClassNotFoundException: View.HomeController" est plutôt clair non? La classe "HomeController"(du package view) n'existe pas, effectivement tu l'as appelée "HomeControl". Je te conseille de créer un dossier nommé "resources" dans le dossier "src" et de créer ensuite un autre dossier nommé "fxml" dans le dossier "resources" et d'y placer tous tes fichiers .fxml

Ensuite tu fais

Parent root = FXMLLoader.load(getClass()
.getClassLoader()
.getResource("resources/fxml/Home.fxml"));



-
Edité par kulturman 15 août 2017 à 22:25:47

Merci beaucoup ça m'a sauvé. Je cherche depuis tout à l'heure la solution et enfin je la trouve ici!! j'arrive toujours pas à y croire. Thanks 

  • Partager sur Facebook
  • Partager sur Twitter
2 juin 2020 à 19:55:18

import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class Client {

	private StringProperty nom;
	private IntegerProperty montant;
	
	private StringProperty datedebut;
	private StringProperty datefin;
	private IntegerProperty numerocontrat;
	private IntegerProperty numero;
	
	public Client() {}

	public Client(String nom, Integer montant, String datedebut, String datefin, Integer numerocontrat,
			Integer numero) {
		super();
		this.nom =new SimpleStringProperty();
		this.montant = new SimpleIntegerProperty();
		this.datedebut = new SimpleStringProperty();
		this.datefin = new SimpleStringProperty();
		this.numerocontrat = new SimpleIntegerProperty();
		this.numero =  new SimpleIntegerProperty();
	}

	public StringProperty getNom() {
		return nom;
	}

	public void setNom(StringProperty nom) {
		this.nom = nom;
	}

	public IntegerProperty getMontant() {
		return montant;
	}

	public void setMontant(IntegerProperty montant) {
		this.montant = montant;
	}

	public StringProperty getDatedebut() {
		return datedebut;
	}

	public void setDatedebut(StringProperty datedebut) {
		this.datedebut = datedebut;
	}

	public StringProperty getDatefin() {
		return datefin;
	}

	public void setDatefin(StringProperty datefin) {
		this.datefin = datefin;
	}

	public IntegerProperty getNumerocontrat() {
		return numerocontrat;
	}

	public void setNumerocontrat(IntegerProperty numerocontrat) {
		this.numerocontrat = numerocontrat;
	}

	public IntegerProperty getNumero() {
		return numero;
	}

	public void setNumero(IntegerProperty numero) {
		this.numero = numero;
	}
	
	
	
	
}

j'essaie d'afficher un requete en cliquant sur mon bouton "afficher " mais a chaque clique j ai cette errreur

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: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$2(GlassViewEventHandler.java:432)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
	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$4(WinApplication.java:186)
	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)
	... 52 more
Caused by: java.lang.NullPointerException
	at fenetre.Clientfxml.afficher(Clientfxml.java:97)
	... 62 more
package fenetre;

import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ResourceBundle;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import javax.sql.rowset.Predicate;
import javax.swing.JOptionPane;


import application.Prestataire;

import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.collections.transformation.SortedList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;

public class Clientfxml implements Initializable {

	
	  private static final Client client1 = null;

	@FXML
	    private TextField nom;

	    @FXML
	    private TextField montant;

	    @FXML
	    private TextField datedebut1;

	    @FXML
	    private TextField datefin1;

	    @FXML
	    private TextField numerocontrat;

	    @FXML
	    private TextField contact;

	    @FXML
	    private TableView<Client> tableau = new TableView<>();

	    @FXML
	    private TableColumn<Client, String> nomclient;
	    

	    @FXML
	    private TableColumn<Client, Integer> montantclient;

	    @FXML
	    private TableColumn<Client, String> datedebutclient;

	    @FXML
	    private TableColumn<Client, String> datefinclient;

	    @FXML
	    private TableColumn<Client, Integer> numerocontactlient;
        @FXML
        private TableColumn<Client, Integer> contactclient;
	    @FXML
	    private TextField recherche;
	    @FXML
	    private Button afficher;
	    @FXML
	    ObservableList<Client> List;
	    
	    private Executor exc;
	    
	    	
	    public void afficher(ActionEvent arg) {
	    	
	    	Connection con= Connexion.getInstance();
			String sql="select * from Client";
			try {
			Statement state = con.createStatement();
				ResultSet resultat = state.executeQuery(sql);
				while(resultat.next()) {
				
       List.add(new Client(resultat.getString(1),
		resultat.getInt(2),
		resultat.getString(3),
		resultat.getString(4),
		resultat.getInt(5),
		resultat.getInt(6)));
		   }
			con.close()	;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			nomclient.setCellValueFactory(new PropertyValueFactory<Client, String>("nom"));
	  		montantclient.setCellValueFactory(new PropertyValueFactory<Client, Integer>("montant"));
	  		datedebutclient.setCellValueFactory(new PropertyValueFactory<Client, String>("datedebut"));
	  		datefinclient.setCellValueFactory(new PropertyValueFactory<Client, String>("datefin"));
	  	    numerocontactlient.setCellValueFactory(new PropertyValueFactory<Client, Integer>("numerocontrat"));
	  	    contactclient.setCellValueFactory(new PropertyValueFactory<Client, Integer>("numero"));
                 tableau.setItems(List);
	  	   
			}
	
	    
	    

         public void ajouter(ActionEvent arg) {
         
        	
		} 
         
         public void suprimer(ActionEvent arg1) {
        	
        	
         }
        

		// filtre dans la table ;
    
         public void filtre(KeyEvent e) {
        	 
        	 
       
         }
   

	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		exc = Executors.newCachedThreadPool((runnable) ->{
    		Thread t = new Thread(runnable);
    		t.setDaemon(true);
    		return t ;
    	});
		nomclient.setCellValueFactory(new PropertyValueFactory<Client, String>("nom"));
  		montantclient.setCellValueFactory(new PropertyValueFactory<Client, Integer>("montant"));
  		datedebutclient.setCellValueFactory(new PropertyValueFactory<Client, String>("datedebut"));
  		datefinclient.setCellValueFactory(new PropertyValueFactory<Client, String>("datefin"));
  	    numerocontactlient.setCellValueFactory(new PropertyValueFactory<Client, Integer>("numerocontrat"));
  	    contactclient.setCellValueFactory(new PropertyValueFactory<Client, Integer>("numero"));
             tableau.setItems(List); 
	}
        
        

	
}
package fenetre;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Clientfenetre extends Application {

	@Override
	public void start(Stage primaryStage) {
		try {
			Parent root = FXMLLoader.load(getClass().getResource("ClientFenetre.fxml"));
			
			Scene scene = new Scene(root);
			scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
			primaryStage.setScene(scene);
			primaryStage.show();

	   } catch(Exception e) {
			e.printStackTrace();
		}
		
	}

	public static void main(String[] args) {
		launch(args);
	}
}





  • Partager sur Facebook
  • Partager sur Twitter
2 juin 2020 à 22:43:12

Bonjour,

Déterrage

Citation des règles générales du forum :

Avant de poster un message, vérifiez la date du sujet dans lequel vous comptiez intervenir.

Si le dernier message sur le sujet date de plus de deux mois, mieux vaut ne pas répondre.
En effet, le déterrage d'un sujet nuit au bon fonctionnement du forum, et l'informatique pouvant grandement changer en quelques mois il n'est donc que rarement pertinent de déterrer un vieux sujet.

Au lieu de déterrer un sujet il est préférable :

  • soit de contacter directement le membre voulu par messagerie privée en cliquant sur son pseudonyme pour accéder à sa page profil, puis sur le lien "Ecrire un message"
  • soit de créer un nouveau sujet décrivant votre propre contexte
  • ne pas répondre à un déterrage et le signaler à la modération

Je ferme ce sujet. En cas de désaccord, me contacter par MP.

  • Partager sur Facebook
  • Partager sur Twitter