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 :

Liaison entre classe de calcul et interface Javafx


Sujet :

JavaFX

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 14
    Par défaut Liaison entre classe de calcul et interface Javafx
    Bonjours,

    Je vais essayer d'être le plus clair possible.
    Je code mon interface graphique à l'aide de Javafx et j'ai une autre classe possédant un Thread qui me permet d'effectuer tout mes calculs et qui renvoie des booléens (pour savoir ou j'en suis dans mon thread).
    Dans une fenêtre de mon interface j'aimerai qu'un Button apparaisse lorsque mon thread renvoi un booléen true spécifique.
    J'ai essayer en créant une méthode dans la classe de mon interface, en essayant de modifier la visibilité de mon Button depuis la classe possédant le thread et d'autres méthodes mais sans succès...
    La meme erreur survient à chaque fois et elle inscrit "NullPointerException", puis elle me montre la ligne de code où se trouve ma tentative de changer la visibilité du Button.

    Auriez-vous une idée pour arranger ça s'il vous plait ?

  2. #2
    Modérateur

    Avatar de Robin56
    Homme Profil pro
    Architecte de système d'information
    Inscrit en
    Juin 2009
    Messages
    5 297
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Architecte de système d'information

    Informations forums :
    Inscription : Juin 2009
    Messages : 5 297
    Par défaut
    Mieux qu'un beau discours, du code pour illustrer tes propos serait appréciable.
    Responsable Java de Developpez.com (Twitter et Facebook)
    Besoin d'un article/tutoriel/cours sur Java, consulter la page cours
    N'hésitez pas à consulter la FAQ Java et à poser vos questions sur les forums d'entraide Java
    --------
    Architecte Solution
    LinkedIn : https://www.linkedin.com/in/nicolascaudard/

  3. #3
    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
    Utilise un Service !

    en essayant de modifier la visibilité de mon Button depuis la classe possédant le thread
    C'est mal !
    Platform.runLater() si pas dans le JavaFX Application Thread.
    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

  4. #4
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 14
    Par défaut
    Voici des bouts de mon code :

    Le Thread extérieur à l'interface :

    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
    public class Gestes extends Thread {
     
    	// INITIALISATION
     
    	public MyControllerFenetreTuto1 tuto;
            int i =0;
     
     
    	public void run() {
    		while (!stop) {
    			if (isTuto1) {
    				tuto1();
    			}
    			if (isFinTuto1) {
     
    			}
    			try {
    				Thread.sleep(20);
    			} catch (InterruptedException e) {
    			}
    		}
     
    	}
     
    	public void tuto1() {
                    i++;
    		if (i== 10) {
    			setIsFinTuto1(true);
    			setIsTuto1(false);
    			tuto.btnVisible();
     
    		}
    	public void setIsTuto1(boolean pIsTuto) {
    		isTuto1 = pIsTuto;
    	}
     
    	}
    La Fenetre qui permet par un click sur un button d'accéder a la fenêtre du Tuto1 :

    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
    public class MyControllerFenetrePrincipale implements Initializable,
    		ControlledScreen {
     
    	Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    	int h = (int) dimension.getHeight();
    	int l = (int) dimension.getWidth();
     
     
     
    	MyControllerFenetreTuto1 fenetreTuto1;
     
    	MyScreenController myController;
     
    	/*
    	 * @FXML AnchorPane anchorPane2;
    	 */
     
    	@FXML
    	ToggleGroup groupeRadio1;
     
    	@FXML
    	public ComboBox<String> cbbNbrManche;
     
    	@FXML
    	ObservableList<String> list = FXCollections.observableArrayList("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");
     
    	@Override
    	public void initialize(URL url, ResourceBundle rb) {
    		cbbNbrManche.setItems(list);
    		// anchorPane2.relocate((600-l)/2, (600-h)/2); REPLACER EN HAUT À GAUCHE
    	}
     
    	public void setScreenParent(MyScreenController screenParent) {
    		myController = screenParent;
    	}
     
    	@FXML
    	public void goToScreen1(ActionEvent event) {
    		myController.setScreen(Main.IDENTIFICATION_SCREEN);
     
    	}
     
    	@FXML
    	public void goToScreenPartie(ActionEvent event) {
    		if (cbbNbrManche.getValue() != null
    				&& groupeRadio1.getSelectedToggle() != null) {
    			myController.setScreen(Main.PARTIE_SCREEN);
     
    		}
    	}
     
    	@FXML
    	public void goToScreenTuto1(ActionEvent event) {
     
    		myController.setScreen(Main.TUTO1_SCREEN);
    		Main.test1.setIsTuto1(true);
     
     
    	}
     
    	@FXML
    	public void goToScreenPalmares(ActionEvent event) {
    		myController.setScreen(Main.PALMARES_SCREEN);
    	}
     
    	@FXML
    	public void goToScreenDefis(ActionEvent event) {
    		myController.setScreen(Main.DEFIS_SCREEN);
    	}
     
    }
    Avec son FXML :

    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
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import javafx.scene.*?>
    <?import javafx.scene.text.*?>
    <?import java.lang.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.image.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.layout.AnchorPane?>
     
    <AnchorPane fx:id="anchorPane2" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.MyControllerFenetrePrincipale">
       <children>
          <Label layoutX="165.0" layoutY="72.0" prefHeight="20.0" prefWidth="138.0" text="Nombre de Manches :" />
          <Label layoutX="165.0" layoutY="152.0" prefHeight="20.0" prefWidth="50.0" text="Niveau :" />
          <RadioButton layoutX="235.0" layoutY="154.0" mnemonicParsing="false" text="Facile ">
             <toggleGroup>
                <ToggleGroup fx:id="groupeRadio1" />
             </toggleGroup>
             <cursor>
                <Cursor fx:constant="HAND" />
             </cursor>
          </RadioButton>
          <RadioButton layoutX="235.0" layoutY="182.0" mnemonicParsing="false" text="Moyen" toggleGroup="$groupeRadio1">
             <cursor>
                <Cursor fx:constant="HAND" />
             </cursor></RadioButton>
          <RadioButton layoutX="235.0" layoutY="210.0" mnemonicParsing="false" text="Difficile" toggleGroup="$groupeRadio1">
             <cursor>
                <Cursor fx:constant="HAND" />
             </cursor></RadioButton>
          <Label layoutX="165.0" layoutY="282.0" prefHeight="20.0" prefWidth="80.0" text="Palmarès :" />
          <ImageView fitHeight="22.0" fitWidth="23.0" layoutX="271.0" layoutY="281.0" pickOnBounds="true" preserveRatio="true">
             <image>

    La fenetre du Tuto1 où se trouve un Button qui n'est pas visible à l'origine :

    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
    public class MyControllerFenetreTuto1 implements Initializable,
    		ControlledScreen {
     
    	Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    	int h = (int) dimension.getHeight();
    	int l = (int) dimension.getWidth();
     
    	MyScreenController myController;
     
    	@FXML
    	Button btnPasserTuto1;
     
    	public void initialize(URL url, ResourceBundle rb) {
     
     
    		anchorPaneTuto1.relocate((900 - l) / 2, (600 - h) / 2);
     
    		final File file1 = new File("Final//LeapCiseaux.mp4");
    		final Media media1 = new Media(file1.toURI().toString());
    		final MediaPlayer mediaPlayer1 = new MediaPlayer(media1);
    		mediaView1.setMediaPlayer(mediaPlayer1);
    		mediaView1.setCursor(Cursor.HAND);
    		mediaView1.setOnMouseClicked(new EventHandler<MouseEvent>() {
    			public void handle(MouseEvent me) {
    				mediaPlayer1.stop();
    				mediaPlayer1.play();
    			}
    		});
     
    	}
    	public void setScreenParent(MyScreenController screenParent) {
    		myController = screenParent;
    	}
     
    	public void btnVisible(){
    		btnPasserTuto1.setVisible(true);
    	}

    Voila ! Si vous avez besoins de plus d'information a propos de mon code demandez moi !
    Merci d'avance pour votre aide !

    PS: J'ai aussi essayer en passant par mais cela n'a pas marcher. Idem pour .

    Et je tiens a préciser que mes interfaces ne sont pas dans la classe "extends Application" mais dans d'autres classes "implements Initialisable, ControlledScreen"

  5. #5
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 14
    Par défaut
    Citation Envoyé par Robin56 Voir le message
    Mieux qu'un beau discours, du code pour illustrer tes propos serait appréciable.
    Voila qui est fait

  6. #6
    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
    Ok, ça a l'air d'être un sacré foutoir... d'autant plus que le code a l'air un peu épuré des parties qui auraient pu nous donner des réponses.

    Ou est le FXML ? Comment est chargé le FXML ? Comment charges tu le contrôleur du FXML ? As tu correctement déclaré ton bouton dans ton FXML ? Est-ce qu'il est déjà null dans la méthode initialize() ? As tu au moins pensé à passer sur ton code avec un débogueur ?
    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

  7. #7
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 14
    Par défaut
    voila mon fxml du tuto1 :

    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
    <?xml version="1.0" encoding="UTF-8"?>
     
    <?import javafx.scene.image.*?>
    <?import javafx.scene.text.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.media.*?>
    <?import java.lang.*?>
    <?import javafx.scene.layout.*?>
    <?import javafx.scene.layout.AnchorPane?>
     
    <AnchorPane fx:id="anchorPaneTuto1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.MyControllerFenetreTuto1">
       <children>
          <Label layoutX="48.0" layoutY="7.0" prefHeight="77.0" prefWidth="343.0" text="TUTO N°1 :">
             <font>
                <Font size="64.0" />
             </font>
          </Label>
          <ImageView fx:id="imgPasserTuto1" fitHeight="50.0" fitWidth="50.0" layoutX="457.0" layoutY="20.0" pickOnBounds="true" preserveRatio="true" visible="false">
             <image>
                <Image url="@../photo/20387-bubka-fleche.png" />
             </image>
          </ImageView>
          <Button fx:id="btnPasserTuto1" layoutX="457.0" layoutY="20.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#goToScreenTuto2" opacity="0.4" prefHeight="50.0" prefWidth="50.0" visible="false" />
          <MediaView fx:id="mediaView1" fitHeight="800.0" fitWidth="1000.0" layoutY="94.0" />
          <Label layoutX="54.0" layoutY="75.0" prefHeight="16.0" prefWidth="313.0" text="( Click sur la fenetre pour lancer ou rejouer la vidéo )" />
       </children>
    </AnchorPane>
    Pour le chargement des fxml, une partie se passe dans le Main :

    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
    public class Main extends Application {
     
    	public static String IDENTIFICATION_SCREEN = "FenetreIdentification";
    	public static String IDENTIFICATION_SCREEN_FXML = "/application/FenetreIdentification.fxml";
    	public static String PALMARES_SCREEN = "Palmares";
    	public static String PALMARES_SCREEN_FXML = "/application/FenetrePalmares.fxml";
    	public static String DEFIS_SCREEN = "Defis";
    	public static String DEFIS_SCREEN_FXML = "/application/FenetreDefis.fxml";
    	public static String TUTO1_SCREEN = "Tuto1";
    	public static String TUTO1_SCREEN_FXML = "/application/FenetreTuto1.fxml";
    	public static String TUTO2_SCREEN = "Tuto2";
    	public static String TUTO2_SCREEN_FXML = "/application/FenetreTuto2.fxml";
    	public static String TUTO3_SCREEN = "Tuto3";
    	public static String TUTO3_SCREEN_FXML = "/application/FenetreTuto3.fxml";
    	public static String PARTIE_SCREEN = "Partie";
    	public static String PARTIE_SCREEN_FXML = "/application/FenetrePartie.fxml";
    	public static String QUITTER_PARTIE_SCREEN = " Quitter Partie";
    	public static String QUITTER_PARTIE_SCREEN_FXML = "/application/FenetreQuitterPartie.fxml";
    	public static String PRINCIPALE_SCREEN = "Shifumi";
    	public static String PRINCIPALE_SCREEN_FXML = "/application/FenetrePrincipale.fxml";
     
    	Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    	int h = (int) dimension.getHeight();
    	int l = (int) dimension.getWidth();
     
    	public static Gestes test1 = new Gestes();
     
     
    	@Override
    	public void start(Stage primaryStage) {
     
    		MyScreenController mainContainer = new MyScreenController();
    		mainContainer.loadScreen(Main.IDENTIFICATION_SCREEN,
    				Main.IDENTIFICATION_SCREEN_FXML);
    		mainContainer.loadScreen(Main.PARTIE_SCREEN,
    				Main.PARTIE_SCREEN_FXML);
    		mainContainer.loadScreen(Main.QUITTER_PARTIE_SCREEN,
    				Main.QUITTER_PARTIE_SCREEN_FXML);
    		mainContainer.loadScreen(Main.PALMARES_SCREEN,
    				Main.PALMARES_SCREEN_FXML);
    		mainContainer.loadScreen(Main.DEFIS_SCREEN,
    				Main.DEFIS_SCREEN_FXML);
    		mainContainer.loadScreen(Main.TUTO1_SCREEN,
    				Main.TUTO1_SCREEN_FXML);
    		mainContainer.loadScreen(Main.TUTO2_SCREEN,
    				Main.TUTO2_SCREEN_FXML);
    		mainContainer.loadScreen(Main.TUTO3_SCREEN,
    				Main.TUTO3_SCREEN_FXML);
    		mainContainer.loadScreen(Main.PRINCIPALE_SCREEN,
    				Main.PRINCIPALE_SCREEN_FXML);
     
     
    		mainContainer.setScreen(Main.PRINCIPALE_SCREEN);
     
    		Group root = new Group();
    		root.getChildren().addAll(mainContainer);
     
    		Scene scene = new Scene(root, l, h, Color.WHITE);
    		scene.getRoot().relocate((l-600)/2, (h-600)/2);   
    		primaryStage.setScene(scene);
    		primaryStage.setTitle("Shifoumi");
    		primaryStage.show();
    		test1.start();
     
    	}
     
    	public static void main(String[] args) {
    		launch(args);
    	}
     
    }
    Et le reste se passe dans MyScreenController :

    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
    public class MyScreenController extends AnchorPane {
     
     
    	public HashMap<String, Node> screens = new HashMap<>();
     
    	public MyScreenController() {
    		super();
    	}
     
    	public void addScreen(String name, Node screen) {
    		screens.put(name, screen);
    	}
     
    	public Node getScreen(String name) {
    		return screens.get(name);
    	}
     
    	public boolean loadScreen(String name, String resource) {
    		try {
    			FXMLLoader myLoader = new FXMLLoader(getClass().getResource(
    					resource));
    			Parent loadScreen = (Parent) myLoader.load();
    			ControlledScreen myScreenControler = ((ControlledScreen) myLoader
    					.getController());
    			myScreenControler.setScreenParent(this);
    			addScreen(name, loadScreen);
    			return true;
    		} catch (Exception e) {
    			System.out.println(e.getMessage());
    			return false;
    		}
    	}
     
    	public boolean setScreen(final String name) {
    		if (screens.get(name) != null) { // screen loaded
    			final DoubleProperty opacity = opacityProperty();
     
    			if (!getChildren().isEmpty()) { // if there is more than one screen
    				Timeline fade = new Timeline(new KeyFrame(Duration.ZERO,
    						new KeyValue(opacity, 1.0)), new KeyFrame(new Duration(
    						800), new EventHandler<ActionEvent>() {
    					@Override
    					public void handle(ActionEvent t) {
     
    						getChildren().remove(0); // remove the displayed screen
    						getChildren().add(0, screens.get(name)); // add the
    																	// screen
    						Timeline fadeIn = new Timeline(new KeyFrame(
    								Duration.ZERO, new KeyValue(opacity, 0.0)),
    								new KeyFrame(new Duration(800), new KeyValue(
    										opacity, 1.0)));
    						fadeIn.play();
     
    					}
    				}, new KeyValue(opacity, 0.0)));
    				fade.play();
     
    			} else {
    				setOpacity(0.0);
     
    				getChildren().add(screens.get(name)); // no one else been
    														// displayed, then just
    														// show
    				Timeline fadeIn = new Timeline(new KeyFrame(Duration.ZERO,
    						new KeyValue(opacity, 0.0)), new KeyFrame(new Duration(
    						2500), new KeyValue(opacity, 1.0)));
    				fadeIn.play();
    			}
    			return true;
    		} else {
    			System.out.println("screen hasn't been loaded!!! \n");
    			return false;
    		}
    	}
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    public interface ControlledScreen {
    	public void setScreenParent(MyScreenController screenPage);
    }
    Oui comme tu peux le constater mon bouton est correctement déclarer. Lorsque je souhaite modifier sa visibilité dans le initialize() cela fonctionne ! Mais une fois que je sort du initialize() peu importe où je me trouve, l'erreur "NullPointerException" apparait ..
    Donc non, il n'est pas null dans la méthode initialize() mais il l'est partout ailleurs.

  8. #8
    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
    Oui en effet, du coup c'est bien ce que je pensais : il null dans le 2nd contrôleur, celui que tu instancies manuellement... et c'est bien normal.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    MyControllerFenetreTuto1 fenetreTuto1 = new MyControllerFenetreTuto1();
    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. Liaison entre classes ?
    Par zpico dans le forum Débuter avec Java
    Réponses: 1
    Dernier message: 22/02/2012, 14h55
  2. Syntaxe - liaisons entre classe
    Par 10say dans le forum UML
    Réponses: 4
    Dernier message: 31/08/2011, 14h14
  3. Réponses: 2
    Dernier message: 25/08/2010, 15h17
  4. Pas de liaisons entre classes dans un diagramme des classes
    Par zoom35 dans le forum Diagrammes de Classes
    Réponses: 3
    Dernier message: 26/06/2008, 15h40
  5. [AS2] liaison entre classe et symbole
    Par ooyeah dans le forum ActionScript 1 & ActionScript 2
    Réponses: 1
    Dernier message: 04/07/2005, 09h41

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