JavaFX scenes + drawing stuff 🌄
Вставка
- Опубліковано 21 сер 2024
- Javafx scenes tutorial example explained
#JavaFX #scene #scenes
package application;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root,600,600,Color.LIGHTSKYBLUE);
Stage stage = new Stage();
Text text = new Text();
text.setText("WHOOOOOA!!");
text.setX(50);
text.setY(50);
text.setFont(Font.font("Verdana",50));
text.setFill(Color.LIMEGREEN);
Line line = new Line();
line.setStartX(200);
line.setStartY(200);
line.setEndX(500);
line.setEndY(200);
line.setStrokeWidth(5);
line.setStroke(Color.RED);
line.setOpacity(0.5);
line.setRotate(45);
Rectangle rectangle = new Rectangle();
rectangle.setX(100);
rectangle.setY(100);
rectangle.setWidth(100);
rectangle.setHeight(100);
rectangle.setFill(Color.BLUE);
rectangle.setStrokeWidth(5);
rectangle.setStroke(Color.BLACK);
Polygon triangle = new Polygon();
triangle.getPoints().setAll(
200.0,200.0,
300.0,300.0,
200.0,300.0
);
triangle.setFill(Color.YELLOW);
Circle circle = new Circle();
circle.setCenterX(350);
circle.setCenterY(350);
circle.setRadius(50);
circle.setFill(Color.ORANGE);
Image image = new Image("pizza.png");
ImageView imageView = new ImageView(image);
imageView.setX(400);
imageView.setY(400);
root.getChildren().add(text);
root.getChildren().add(line);
root.getChildren().add(rectangle);
root.getChildren().add(triangle);
root.getChildren().add(circle);
root.getChildren().add(imageView);
stage.setScene(scene);
stage.show();
}
}
------------------------------
Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
Free Download / Stream: bit.ly/2JnDfCE
Music promoted by Audio Library • Up In My Jam (All Of A...
------------------------------
package application;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root,600,600,Color.LIGHTSKYBLUE);
Stage stage = new Stage();
Text text = new Text();
text.setText("WHOOOOOA!!");
text.setX(50);
text.setY(50);
text.setFont(Font.font("Verdana",50));
text.setFill(Color.LIMEGREEN);
Line line = new Line();
line.setStartX(200);
line.setStartY(200);
line.setEndX(500);
line.setEndY(200);
line.setStrokeWidth(5);
line.setStroke(Color.RED);
line.setOpacity(0.5);
line.setRotate(45);
Rectangle rectangle = new Rectangle();
rectangle.setX(100);
rectangle.setY(100);
rectangle.setWidth(100);
rectangle.setHeight(100);
rectangle.setFill(Color.BLUE);
rectangle.setStrokeWidth(5);
rectangle.setStroke(Color.BLACK);
Polygon triangle = new Polygon();
triangle.getPoints().setAll(
200.0,200.0,
300.0,300.0,
200.0,300.0
);
triangle.setFill(Color.YELLOW);
Circle circle = new Circle();
circle.setCenterX(350);
circle.setCenterY(350);
circle.setRadius(50);
circle.setFill(Color.ORANGE);
Image image = new Image("pizza.png");
ImageView imageView = new ImageView(image);
imageView.setX(400);
imageView.setY(400);
root.getChildren().add(text);
root.getChildren().add(line);
root.getChildren().add(rectangle);
root.getChildren().add(triangle);
root.getChildren().add(circle);
root.getChildren().add(imageView);
stage.setScene(scene);
stage.show();
}
}
I loved the video
Can you make a video about making a game using javaFX
Your channel is underrated. I've never seen better coding tutorials than yours! PLEASE KEEP GOING!!
True... i also just found him today. This channel is not only informative but also chill cool... bro...
bro code please never stop uploading these videos, you are a huge help for me in my journey into coding java spigot plugins and saved my butt more than one time, thanks! :D
Thank you so much for all the wonderful videos..
Very awesome stuff!
bro you're such a legend. The way you teach us java is never boring and always exciting. You are better than my teacher. I have learned so much from you. I just wanna thank you for all your hardwork. Please never ever stop teaching us java. And I hope someday I could meet you or even repay you from all of the free java vids tutorial ive watch your channel. Anyways bro I also hope you're doing well and always keep being awesome. Then Finally the day will come when we finally defeat the youtube algorithm hahahah
edit: A quick question bro. Are you planning on teaching java programming for embedded systems? cause I would really love to learn from you
Super video
Nice
I like your channel and I know that It will grow into bigger channel ❤️
just you explaining it how you did helped me a bunch
Thanks for this awesome video and other videos in whole list
super vidéo
Thumb up, great work! ... as always 😉
Sick program broski
👍🏻😊😊
Great!! I hope you make more videos
gg
amazing chanel
Useful 👌👍
50 mins in college class = I don't get any sh!t, 15 mins watching this = I can get my assignment done. You are a God
Great explanation 🎉
great
Excellent info!
awesome
Really good stuff!!
This is one tutorial that ranks above most. It is the setup, and the method here that works. Bro Code is solid, and is above the rest. Learn the ways of the code.
"WHOOOOA!!,nice video
i only learned swing on my oop course. nice to learn javaFX here. very nice video bro
Great tutorial!
Interesting. Thank you!
Nice video bro
🔥🔥
love u bro, thanks for vid
Thanks for making this video
That was great!
Thanks !!
Great video!
I love your idea of a sandwich but I've always thought of it as a pizza. The stage is the dough, the scene is the tomato sauce, and the scene graph would be the toppings. Great video though!
Это божественно!
thanks you bro please make more of these
Thanks for that!
Please make tutorial on jdbc jsp servlet
love you man
This is better and more fun than University
you are a blessing
thanks 👏
Thanks a lot!
Hi dear bro please make more videos of javafx.
Adding an image was a little bit different that what I thought. I didn't expect that extra step of ImageView.
Great series so far! It's bit outdated (tho that also might be me using IntelliJ Ultimate. Other than the fact that project creation works differently (and more fluently) the tutorials hold up well!
Same. I’m watching today and I use IntelliJ ultimate. The process to get JavaFX started up is a bit different and it’s hard to find current videos that teach it well
wow thank's so much man
ily
Thanks!
early :)
Javafx+ series pls
thank u broo
thank you man
your videos are super useful! could you maybe cover some OpenGL?
Pizza!
Pizza
Can you make a video about Java streams? Please
Thank you. we need to create 3d canvas. is it also pssible?
he told me to comment, so i did
text.setText("WHOOOOA"); ✔
can you go over how to resize a rectangle in javafx ?
Change the values of the start coordinates (x ,y), and the end coordinates (x ,y) 1,1 to 10,10...it makes a square. 1,1 to 10,20 makes an actual rectangle.
What happened to Bro hes been missing? Where are you Bro?
Can we not get a video series on java networking
heyyy bro! I wanted you to make a tutorial in which there is a simple dimple square, nothing special in a new window and there's an enemy. We can move the player using W A S D and I want the enemy to follow me.
Long story short - a red square (enemy) which follows you ( you are a blue Square which is a player)
Can we print these shapes in the graphics context by calling those objects? But not using these fillRect(), fillPolygon(), etc. in a graphics context?
hey bro, nice video. but can you please make a video about JavaFX where you explain each methods thoroughly?
I wonder! When there was no *you. How ppl used to learn.
*(UA-cam and you.)
Can someone please tell me, my triangle isnt showing on scene, i write same code😢
BROOOOOo help meeeeee! I want to do a transparent colors for a flag in a post card we have to do for school please help me I can't find it I am very new in programming please hit me up!!!!
THANKS A LOOOT. I WAS PREPARING FOR ENDTERM AND I COULDNT DRAW TRIANGLE. IF IT WASNT FOR YOU :D
I have a problem when uploading the image to the code, knowing that I have placed it inside the program file
I had this too fixed it by doing Image image = new Image(new File("src/icon.png").toURI().toString());
@@benjaminlgur Thank you very much i had the same Problem and with that is works .i dont know what i would have done without your kommend
Why do we need to create an object named Group of type root at the beginning of the code?
The name of the object is root and the type is Group. This group is basically just a container for the drawings.
hey man Ive got this assignment where we need to make a circle with 3 nodes that form an internal triangle in the circle. Anyway I can pick your brain for a few questions ?
Hey Legend bro
my IntelliSense in Eclipse is acting funny, it shows some option and never shows many others, especially when I use Swing or Java FX, any advice for fix