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 )
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
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
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);
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?
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?
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
🗿👑
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!
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 :)
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
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
Bro, I literally started learning how to make GUIs in java yesterday and you upload this
You're awesome
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
Thanks, Bro! ☕ You're awesome!
That's so cool :D
whoa W.D. Gaster appears!
@@BroCodez XD
Op explain bro thnx for sharing khowledge in such way
Great job breaking it down. Thanks man!
great video bro
thanks Dbest!
That's really nice 👍♥️
I read that it is recommended to use JPanel for background image, hope you create a tutorial on that
This video is so informative. Thank you for the hard work
i like your explanation......... very understood........😍😍😍
nice video thanks bro
You are the best!
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?
Thank you my friend! You help me so much!!!!
thanks , and I appreciate your hard work.
Great video 👌
Nice and understandable explanation bro 👍👍👍
liking and commenting since this vid was helpful
good explanation bro
Thank you very much
Thank you!
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.
Great job homie
nice
W tutorial
51th. Thank you, ma Bro Sensei
Muchas gracias, estoy aprendiendo apenas y tú video me ayudó bastante, muy claro todo 😁
Thank you so muck Master!!!
keep up bro
You're my hero thank you
thank you
Where are the other jpanel related videos? Is there a playlist? Would love to watch more
thanks a lot buddy!!!!! U r great.
Thank you Bro Code
❤💚💙
Thanks
ly bro 3
brilliant
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...
Besta da best
thanks
Yey, Thank youu!!!
labai didelis ačiū iš Lietuvos!
very good
you are my god
Thank you Bro Code!
thanks bro
heeeeeey BRO!!
Beat the algorithm!
how do I add a Button over the JPanel?
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?
YASSSS!
Maa maan thank u
thank you for watching!
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.
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
How did you add the image????
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.
Goated
how can i resize my icon inside the label??
how to add image?
7:25 Border layout
what if we overlap them what will happen
-1000 HP to the Algorythm
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
❤
6:50 Flow Layout Manager
2. comment
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
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?
gg
thank
thanks for watching Saber!
I copied your code but my icon is invisible
random comment
slenap
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);
}
}