import java.awt.BorderLayout; import java.awt.Color; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Main { public static void main(String[] args) { // JPanel = a GUI component that functions as a container to hold other components ImageIcon icon = new ImageIcon("thumbsup.png");
I know you might not see this but I think it will be super nice If you do this from scratch and implement it by using the component or Jcomponent package (Java API )
Great video! I did this myself and used a much larger *.PNG photo. I struggled quite a bit to resize it (to make it smaller), but if anyone wants to know the code here's how, you'll figure out where to place it. Love these videos. Great to work through things yourself. ImageIcon icon = new ImageIcon("wind.png"); Image scaleImage = icon.getImage().getScaledInstance(200, 200,Image.SCALE_DEFAULT); icon = new ImageIcon(scaleImage);
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
I liked the video and I subscribed but, I still don't know how you find the energy to prepare these videos with that small amount of views. You are incredible
Bro one question tho... Do people really use Java Desktop to create program, let alone Java Swing? I actually learn this because of my univ (and to be honest I don't really like Java Swing GUI). Because there's some language like C-Sharp which produce .exe extension that being used widely and I haven't yet encountered any .jar file in my life...
Apparently borderlayout doesn't play nice with multiple components. If i have multiple labels then only the last one shows up. Is this intendent or am i being silly?
Thank you for all the tutorials bro. I have a question, is coding java swing components the same as designing it from a JFrame form? do you also have tutorials on swing Events? When creating a program/app do you prefer coding the whole thing or designing it and then coding events?
I don't know why my image refuses to be output, even after following all the steps and 0 errors are occuring. Everything displays but the png or the jpg i unclude on the code, if anyone can enlighten me please
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Main {
public static void main(String[] args) {
// JPanel = a GUI component that functions as a container to hold other components
ImageIcon icon = new ImageIcon("thumbsup.png");
JLabel label = new JLabel();
label.setText("Hi");
label.setIcon(icon);
label.setVerticalAlignment(JLabel.TOP);
label.setHorizontalAlignment(JLabel.LEFT);
//label.setBounds(100, 100, 75, 75);
JPanel redPanel = new JPanel();
redPanel.setBackground(Color.red);
redPanel.setBounds(0, 0, 250, 250);
redPanel.setLayout(new BorderLayout());
JPanel bluePanel = new JPanel();
bluePanel.setBackground(Color.blue);
bluePanel.setBounds(250, 0, 250, 250);
bluePanel.setLayout(new BorderLayout());
JPanel greenPanel = new JPanel();
greenPanel.setBackground(Color.green);
greenPanel.setBounds(0, 250, 500, 250);
greenPanel.setLayout(new BorderLayout());
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null);
frame.setSize(750,750);
frame.setVisible(true);
greenPanel.add(label);
frame.add(redPanel);
frame.add(bluePanel);
frame.add(greenPanel);
}
}
I know you might not see this but I think it will be super nice If you do this from scratch and implement it by using the component or Jcomponent package (Java API )
I don't skip the ads so u can have the revenue u deserve
🗿👑
Great video! I did this myself and used a much larger *.PNG photo. I struggled quite a bit to resize it (to make it smaller), but if anyone wants to know the code here's how, you'll figure out where to place it. Love these videos. Great to work through things yourself.
ImageIcon icon = new ImageIcon("wind.png");
Image scaleImage = icon.getImage().getScaledInstance(200, 200,Image.SCALE_DEFAULT);
icon = new ImageIcon(scaleImage);
This solved my problem. Thanks!
Thank youu mate
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
bro the way you explain these concepts is so good....thank you so much for the videos they really help a lot!!
Glad you like them!
Bro, I literally started learning how to make GUIs in java yesterday and you upload this
You're awesome
I liked the video and I subscribed but, I still don't know how you find the energy to prepare these videos with that small amount of views. You are incredible
thanks bro! It's pure discipline. Believe me the low views are really discouraging lol
@@BroCodez but you still do it, so a lot of us are very grateful :)
Great job breaking it down. Thanks man!
Op explain bro thnx for sharing khowledge in such way
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
This video is so informative. Thank you for the hard work
That's really nice 👍♥️
I read that it is recommended to use JPanel for background image, hope you create a tutorial on that
Muchas gracias, estoy aprendiendo apenas y tú video me ayudó bastante, muy claro todo 😁
nice video thanks bro
Thanks, Bro! ☕ You're awesome!
Where are the other jpanel related videos? Is there a playlist? Would love to watch more
good explanation bro
thanks , and I appreciate your hard work.
great video bro
thanks Dbest!
Great video 👌
i like your explanation......... very understood........😍😍😍
liking and commenting since this vid was helpful
very good
I don't know why my picture doesnt show up in my. I am doing exactly what you do but my JFrame doesnt show anything. So frustrating
Thank you my friend! You help me so much!!!!
Bro one question tho... Do people really use Java Desktop to create program, let alone Java Swing? I actually learn this because of my univ (and to be honest I don't really like Java Swing GUI). Because there's some language like C-Sharp which produce .exe extension that being used widely and I haven't yet encountered any .jar file in my life...
Thank you very much
You're my hero thank you
That's so cool :D
whoa W.D. Gaster appears!
@@BroCodez XD
nice
Great job homie
hello I want to make the corners of the center panel rounded. tried many times but failed. the solution must be in borderlayout of the frame.
brilliant
You are the best!
Apparently borderlayout doesn't play nice with multiple components. If i have multiple labels then only the last one shows up.
Is this intendent or am i being silly?
keep up bro
how do I add a Button over the JPanel?
Thank you for all the tutorials bro. I have a question, is coding java swing components the same as designing it from a JFrame form? do you also have tutorials on swing Events?
When creating a program/app do you prefer coding the whole thing or designing it and then coding events?
thanks bro
Heeeey, bro! This video is the best that i ever seen! Like. I tried to use Jpanel with JFrame for a long time. Great video! I love you XD.
51th. Thank you, ma Bro Sensei
Thank you Bro Code
Thank you so muck Master!!!
how can i resize my icon inside the label??
Can someone tell me how I add multiple icons. I have them in the same directory if that helps. I want to aline them in a row but not sure how.
Besta da best
labai didelis ačiū iš Lietuvos!
W tutorial
Thank you!
How did you add the image????
thanks a lot buddy!!!!! U r great.
thank you
I don't know why my image refuses to be output, even after following all the steps and 0 errors are occuring. Everything displays but the png or the jpg i unclude on the code, if anyone can enlighten me please
When i am creating a panel, its covering the entire frame, even if i set bounds. My code is the exact same as yours.
ik its late but i had the same problem....dont forget to put this "frame.setLayout(null);" in frame
what if we overlap them what will happen
Thanks
how to add image?
❤💚💙
ly bro 3
thanks
Yey, Thank youu!!!
Thank you Bro Code!
Hi sir may i ask about the panel, how to code if the green panel is beside the blue, please help me how to code, i hope you notice, thank you
How to code when each panel have icon and text?
you are my god
Beat the algorithm!
Maa maan thank u
thank you for watching!
I copied your code but my icon is invisible
7:25 Border layout
❤
heeeeeey BRO!!
gg
Goated
YASSSS!
6:50 Flow Layout Manager
thank
thanks for watching Saber!
-1000 HP to the Algorythm
2. comment
slenap
random comment
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.BorderLayout;
public class Main{
public static void main(String[ ]args){
ImageIcon icon = new ImageIcon("image.png");
JLabel label = new JLabel();
label.setText("Coding is fun!");
label.setIcon(icon);
//label.setVerticalAlignment(JLabel.BOTTOM);
//label.setHorizontalAlignment(JLabel.LEFT);
label.setBounds(50,50,25,25);
JPanel orangePanel = new JPanel();
orangePanel.setBackground(Color.orange);
orangePanel.setBounds(0,0,125,125);
//orangePanel.setLayout(new BorderLayout());
orangePanel.setLayout(null);
JPanel yellowPanel = new JPanel();
yellowPanel.setBackground(Color.yellow);
yellowPanel.setBounds(0,0,125,125);
//yellowPanel.setLayout(new BorderLayout());
yellowPanel.setLayout(null);
JPanel pinkPanel = new JPanel();
pinkPanel.setBackground(Color.pink);
pinkPanel.setBounds(0,125,250,125);
//pinkPanel.setLayout(new BorderLayout());
pinkPanel.setLayout(null);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
frame.setSize(380,380);
frame.setLayout(null);
frame.setVisible(true);
orangePanel.add(label);
pinkPanel.add(label);
yellowPanel.add(label);
frame.add(orangePanel);
frame.add(yellowPanel);
frame.add(pinkPanel);
}
}
thanks bro