Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, why when i want to start my JavaFX project window comes out?

image — ImgBB[^]

the code:

package application;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class Controller {

	@FXML
	
	ImageView myView;
	Button myButton;
	
	Image myImage = new Image(getClass().getResourceAsStream("back.jpg"));
	
	//method that change our image
	
	public void displayImage() {
		
		myView.setImage(myImage);
		
		
	}
}



<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>


<AnchorPane xmlns:fx="http://javafx.com/fxml/1"
	xmlns="http://javafx.com/javafx/8.0.171">
	<children>
		<AnchorPane layoutX="-6.0" prefHeight="421.0"
			prefWidth="518.0">
			<children>
				<Button fx:id="myButton" layoutX="230.0" layoutY="322.0"
					mnemonicParsing="false" onAction="#isplayImage" prefHeight="70.0"
					prefWidth="105.0" text="Button" />
				<ImageView fx:id="myView" fitHeight="228.0"
					fitWidth="290.0" layoutX="138.0" layoutY="39.0" pickOnBounds="true"
					preserveRatio="true">
					<image>
						<Image url="@../../../Desktop/front.jpg" />
					</image>
				</ImageView>
			</children>
		</AnchorPane>
	</children>
</AnchorPane>


What I have tried:

I really dont know where the mistake is?
Posted
Updated 17-Dec-21 5:59am

1 solution

Looks like a simple spelling mistake:
Java
mnemonicParsing="false" onAction="#isplayImage" prefHeight="70.0"

Shouldn't that be displayImage?
 
Share this answer
 
Comments
JamesDorr 17-Dec-21 12:06pm    
doesn't fix things
Richard MacCutchan 17-Dec-21 12:26pm    
Sorry, we cannot guess what is happening.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900