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