JavaFX ImageView 🖼️
HTML-код
- Опубликовано: 28 июн 2024
- JavaFX ImageView node tutorial example explained
#JavaFX #ImageView #node
// ******************* Controller.java *******************
package application;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class Controller {
//ImageView is a Node used for painting images loaded with Images
// Image = picture
// ImageView = picture frame
@FXML
ImageView myImageView;
Button myButton;
Image myImage = new Image(getClass().getResourceAsStream("shrek2.jpg"));
public void displayImage() {
myImageView.setImage(myImage);
}
}
// ********************************************************
Bro Code merch store 👟 :
===========================================================
teespring.com/stores/bro-code-5
=========================================================== Наука
// ******************** Controller.java ********************
package application;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class Controller {
//ImageView is a Node used for painting images loaded with Images
// Image = picture
// ImageView = picture frame
@FXML
ImageView myImageView;
Button myButton;
Image myImage = new Image(getClass().getResourceAsStream("shrek2.jpg"));
public void displayImage() {
myImageView.setImage(myImage);
}
}
// ********************************************************
What about main class, what we gonna type there 🤔
@@sofbreez6987 do you have it?
@@sofbreez6987The usual
this applies to all of ur JavaFX videos but you've singlehandedly saved my CS project. your videos have given me a proper understanding of most fundamental JavaFX concepts and take me through using its features in a way that's slow enough for me to understand but fast enough to not bore me to death like other tutorials.
you're one of the best in the game, keep it up
Bro.. Praying for the RUclips algorithm
You make Java so fun to learn ! Keep up the gr8 work!
Great video thanks bro
I have to use JavaFX for my assignments this week and I'm glad I found your videos! Shrek is very inspirational, good choice! 😎
yep... doin it right now 2 days before its due
Great videos, perfect tempo for me, upload more of this, please, :)
You are the best man....
if u have a problems with mouse entered, change the event from action to mouse, like this:
"public void displayAvatar(MouseEvent)", but its important to use for button action event
thanks Broo i learnt a lot from your tutos
you literally saved my life bro
Thankyou so much bro, i owe you :'D
I like it!
Love your content !
Hey Bro xD i really like your content and your way of explaining things Keep up !!
And please do a Javascript Course I'm really needing that thnx..
Great job bro.
Bro, you are awesome!!!!!!!!!
NICE IMAGES
Bruh you´ve save my whole Data Structure curse haha
nice 👍
Dude you are the man
Nice content broh
Thanks!
Bro post more stuff
I am addicted to your channel
Nice
Thx bro
thanks!!!
Shrek is love, Shrek is life.
please make more javafx videos
bro can you make a video about spring freamwork?
😁😁😁😁😁😁😁😁😁😁
Was watching your video a I noticed you never showed your main class. Do you mind posting?
Hi bro, What If I want to Show/Hide the picture using the button? How can I do that?
How can I make it so a user can upload a profile picture from their saved pictures in their files?
dabest
Guys is good using a gui designer or writing the code
Alright video overall, the only thing I did not like is that you did not show how to get scenebuilder downloaded and configuring the path. Other than that good video
I cracked myself at 00:02
you insisted on us for comment, i could not reject you
it doesnt work for me gives me error i followed every step is it jst me guys ?
I had the same issue and finally got it to work... The issue seems to be with the version of JavaFX and/or openJDK in the lesson vs. what I'm using and probably what you used. I'm using v22 for both but below are my notes including the last line which resolved it.
// This is the lesson example but won't work. Some issue w/ the stream which results in null
// Image myImage = new Image(getClass().getResourceAsStream("/images/image2.png"));
// This version works but it's not JavaFX i.e. it's a work around to some stream issue.
// Image myImage = new Image(String.valueOf(new File("/images/image2.png")));
// OK This actually works! AS:LKDAS:DJKH!@#!@(&*#!@#
Image myImage = new Image( getClass().getResource( "/images/image2.png").toExternalForm());
Great job bro.