Java panels 🟥

Sdílet
Vložit
  • čas přidán 26. 07. 2024
  • Java GUI panel JPanel swing tutorial for beginners
    #Java #panel #jpanel #GUI #swing #tutorial #beginners
  • Věda a technologie

Komentáře • 104

  • @BroCodez
    @BroCodez  Před 4 lety +63

    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);
    }
    }

    • @brandonjablasone7544
      @brandonjablasone7544 Před 4 měsíci

      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 )

  • @bitcoin1532
    @bitcoin1532 Před 3 lety +56

    I don't skip the ads so u can have the revenue u deserve

  • @travel_to_wonders6666
    @travel_to_wonders6666 Před 2 lety

    Op explain bro thnx for sharing khowledge in such way

  • @omar100k6
    @omar100k6 Před 4 lety +6

    bro the way you explain these concepts is so good....thank you so much for the videos they really help a lot!!

  • @danny.3036
    @danny.3036 Před 3 lety +2

    Thanks, Bro! ☕ You're awesome!

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 Před rokem +2

    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

  • @stephendavol5589
    @stephendavol5589 Před 6 měsíci

    Great job breaking it down. Thanks man!

  • @bruce9067
    @bruce9067 Před 4 lety +9

    Bro, I literally started learning how to make GUIs in java yesterday and you upload this
    You're awesome

  • @TheRickyfranco13
    @TheRickyfranco13 Před rokem

    This video is so informative. Thank you for the hard work

  • @WatIsUrMobileNumber
    @WatIsUrMobileNumber Před 2 lety

    Nice and understandable explanation bro 👍👍👍

  • @carloseduardosabbaghfranqu9367

    Muchas gracias, estoy aprendiendo apenas y tú video me ayudó bastante, muy claro todo 😁

  • @Neeraj_vish_
    @Neeraj_vish_ Před 2 měsíci

    That's really nice 👍♥️

  • @peterkalaba7618
    @peterkalaba7618 Před 2 lety

    i like your explanation......... very understood........😍😍😍

  • @techtalk9548
    @techtalk9548 Před 2 lety

    You are the best!

  • @mudassirnaz1813
    @mudassirnaz1813 Před 2 lety

    thanks , and I appreciate your hard work.

  • @ItamiPlaysGuitar
    @ItamiPlaysGuitar Před 4 lety +15

    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

    • @BroCodez
      @BroCodez  Před 4 lety +16

      thanks bro! It's pure discipline. Believe me the low views are really discouraging lol

    • @ssrot4352
      @ssrot4352 Před 3 lety +6

      @@BroCodez but you still do it, so a lot of us are very grateful :)

  • @vipinpeethambaran9777
    @vipinpeethambaran9777 Před 2 lety

    Great video 👌

  • @G4brielLirio
    @G4brielLirio Před rokem

    Thank you my friend! You help me so much!!!!

  • @analyticseninteligenciamer724

    Thank you so muck Master!!!

  • @rupeshsunuwar1868
    @rupeshsunuwar1868 Před 3 lety

    thanks a lot buddy!!!!! U r great.

  • @ajdndbdjbdj
    @ajdndbdjbdj Před rokem

    Great job homie

  • @Demajaasa
    @Demajaasa Před 3 lety

    liking and commenting since this vid was helpful

  • @ajaykumar_tamilan
    @ajaykumar_tamilan Před rokem

    nice video thanks bro

  • @pt4909
    @pt4909 Před rokem

    Thank you!

  • @karimsaid3472
    @karimsaid3472 Před 10 měsíci

    good explanation bro

  • @AdrianTregoning
    @AdrianTregoning Před 2 lety +10

    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);

    • @stranger9951
      @stranger9951 Před rokem +1

      This solved my problem. Thanks!

    • @LK2LD
      @LK2LD Před 11 měsíci +1

      Thank youu mate

  • @deepdaddy1208
    @deepdaddy1208 Před 4 lety +2

    great video bro

  • @carlosllige8922
    @carlosllige8922 Před 2 lety +2

    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?

  • @user-mr5qm1fr9c
    @user-mr5qm1fr9c Před 2 lety

    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.

  • @egrenzgo5650
    @egrenzgo5650 Před rokem

    Yey, Thank youu!!!

  • @henryjohannesen6986
    @henryjohannesen6986 Před rokem

    You're my hero thank you

  • @d-news4076
    @d-news4076 Před 2 lety

    Thank you Bro Code!

  • @13_iwayannathawiguna_xiipa68

    keep up bro

  • @amarald842
    @amarald842 Před 4 lety +5

    That's so cool :D

  • @muhammedkabbani6434
    @muhammedkabbani6434 Před rokem

    brilliant

  • @user-zq6yx7of5f
    @user-zq6yx7of5f Před rokem

    Thank you very much

  • @user-xh1dx9st6b
    @user-xh1dx9st6b Před 5 měsíci

    I read that it is recommended to use JPanel for background image, hope you create a tutorial on that

  • @jaymob5037
    @jaymob5037 Před 2 lety

    Where are the other jpanel related videos? Is there a playlist? Would love to watch more

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 Před 2 lety

    thanks bro

  • @arambradosty2297
    @arambradosty2297 Před 2 lety

    thank you

  • @kemann3815
    @kemann3815 Před 2 lety

    Besta da best

  • @mweatherly
    @mweatherly Před 2 lety +1

    Thank you Bro Code

  • @Simis999
    @Simis999 Před rokem

    labai didelis ačiū iš Lietuvos!

  • @bwsoul9770
    @bwsoul9770 Před 3 lety

    Maa maan thank u

  • @anaralizada8884
    @anaralizada8884 Před 2 lety

    very good

  • @honoredegg
    @honoredegg Před 2 lety

    51th. Thank you, ma Bro Sensei

  • @sfsdfsfdd
    @sfsdfsfdd Před 10 měsíci

    W tutorial

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Před 2 lety

    Thanks

  • @PoorwayTraning
    @PoorwayTraning Před rokem

    thanks

  • @manuelgonzalezpalafox2627

    ly bro 3

  • @user-ie7bt3hk3h
    @user-ie7bt3hk3h Před 7 měsíci

    nice

  • @MURAT-pu4hg
    @MURAT-pu4hg Před rokem

    you are my god

  • @deepinmind4091
    @deepinmind4091 Před rokem

    heeeeeey BRO!!

  • @augischadiegils.5109
    @augischadiegils.5109 Před 3 lety

  • @cdjosh3568
    @cdjosh3568 Před 3 lety +1

    Beat the algorithm!

  • @justinpalmer9387
    @justinpalmer9387 Před 2 lety

    Goated

  • @jamaalgamble3441
    @jamaalgamble3441 Před 6 měsíci

    YASSSS!

  • @yunskodubinks8277
    @yunskodubinks8277 Před 2 lety

    ❤💚💙

  • @ihsannuruliman3656
    @ihsannuruliman3656 Před 3 lety +1

    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...

  • @wdwuccnxcnh7022
    @wdwuccnxcnh7022 Před 2 lety

    How did you add the image????

  • @Ollie__07
    @Ollie__07 Před 2 lety

    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.

  • @natgfx6027
    @natgfx6027 Před 2 lety

    what if we overlap them what will happen

  • @zeinabbarakat5558
    @zeinabbarakat5558 Před 6 měsíci

    how do I add a Button over the JPanel?

  • @towbeetowbee3124
    @towbeetowbee3124 Před 2 lety

    how can i resize my icon inside the label??

  • @sabermmirza
    @sabermmirza Před 3 lety

    thank

    • @BroCodez
      @BroCodez  Před 3 lety

      thanks for watching Saber!

  • @8rboy
    @8rboy Před 2 lety

    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

  • @kylemandeeomadlao9014
    @kylemandeeomadlao9014 Před 4 měsíci

    how to add image?

  • @rectaalborween8471
    @rectaalborween8471 Před 5 měsíci

    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?

  • @BISAMARKSMANDOANG
    @BISAMARKSMANDOANG Před rokem

    gg

  • @soumelee5661
    @soumelee5661 Před rokem

  • @kushal6065
    @kushal6065 Před rokem

    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.

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Před rokem

  • @slumdogskillionaire923

    7:25 Border layout

  • @siriusleto3758
    @siriusleto3758 Před 2 lety

    2. comment

  • @slumdogskillionaire923

    6:50 Flow Layout Manager

  • @user-xc9wf4hs4b
    @user-xc9wf4hs4b Před 5 měsíci

    -1000 HP to the Algorythm

  • @rooveloft5273
    @rooveloft5273 Před 2 lety

    When i am creating a panel, its covering the entire frame, even if i set bounds. My code is the exact same as yours.

    • @abdulahad-vk2yq
      @abdulahad-vk2yq Před 2 lety

      ik its late but i had the same problem....dont forget to put this "frame.setLayout(null);" in frame

  • @kimharveybaruela4128
    @kimharveybaruela4128 Před 2 lety

    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

  • @haitamelgana5139
    @haitamelgana5139 Před rokem

    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

  • @qwerttz1033
    @qwerttz1033 Před 2 lety

    I copied your code but my icon is invisible

  • @Paul122M
    @Paul122M Před 3 lety

    random comment

  • @greeneggsandmushrooms9855

    slenap

  • @joyceasante8292
    @joyceasante8292 Před rokem

    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);
    }
    }

  • @anjapietralla5767
    @anjapietralla5767 Před 6 měsíci

  • @eugenezuev7349
    @eugenezuev7349 Před 2 měsíci