Java panels 🟥

Поділитися
Вставка
  • Опубліковано 19 вер 2024

КОМЕНТАРІ • 105

  • @BroCodez
    @BroCodez  4 роки тому +64

    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 6 місяців тому

      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 3 роки тому +59

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

  • @omar100k6
    @omar100k6 4 роки тому +6

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

    • @BroCodez
      @BroCodez  4 роки тому

      Glad you like them!

  • @ItamiPlaysGuitar
    @ItamiPlaysGuitar 4 роки тому +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  4 роки тому +16

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

    • @ssrot4352
      @ssrot4352 3 роки тому +6

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

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 Рік тому +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

  • @AdrianTregoning
    @AdrianTregoning 2 роки тому +11

    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 Рік тому +1

      This solved my problem. Thanks!

    • @LK2LD
      @LK2LD Рік тому +1

      Thank youu mate

  • @bruce9067
    @bruce9067 4 роки тому +9

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

  • @dianamilenaarchilacordoba4632
    @dianamilenaarchilacordoba4632 13 годин тому

    great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much

  • @danny.3036
    @danny.3036 3 роки тому +2

    Thanks, Bro! ☕ You're awesome!

  • @amarald842
    @amarald842 4 роки тому +5

    That's so cool :D

    • @BroCodez
      @BroCodez  4 роки тому +2

      whoa W.D. Gaster appears!

    • @amarald842
      @amarald842 4 роки тому +3

      @@BroCodez XD

  • @travel_to_wonders6666
    @travel_to_wonders6666 2 роки тому

    Op explain bro thnx for sharing khowledge in such way

  • @stephendavol5589
    @stephendavol5589 8 місяців тому

    Great job breaking it down. Thanks man!

  • @deepdaddy1208
    @deepdaddy1208 4 роки тому +2

    great video bro

  • @Neeraj_vish_
    @Neeraj_vish_ 4 місяці тому

    That's really nice 👍♥️

  • @liaMXWolfGaming
    @liaMXWolfGaming 7 місяців тому

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

  • @TheRickyfranco13
    @TheRickyfranco13 Рік тому

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

  • @peterkalaba7618
    @peterkalaba7618 2 роки тому

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

  • @ajaykumar_tamilan
    @ajaykumar_tamilan Рік тому

    nice video thanks bro

  • @techtalk9548
    @techtalk9548 3 роки тому

    You are the best!

  • @carlosllige8922
    @carlosllige8922 2 роки тому +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?

  • @G4brielLirio
    @G4brielLirio 2 роки тому

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

  • @mudassirnaz1813
    @mudassirnaz1813 3 роки тому

    thanks , and I appreciate your hard work.

  • @vipinpeethambaran9777
    @vipinpeethambaran9777 2 роки тому

    Great video 👌

  • @WatIsUrMobileNumber
    @WatIsUrMobileNumber 2 роки тому

    Nice and understandable explanation bro 👍👍👍

  • @Demajaasa
    @Demajaasa 3 роки тому

    liking and commenting since this vid was helpful

  • @karimsaid3472
    @karimsaid3472 Рік тому

    good explanation bro

  • @曾毓哲-b1t
    @曾毓哲-b1t Рік тому

    Thank you very much

  • @pt4909
    @pt4909 Рік тому

    Thank you!

  • @ИльяТребоганов-й3х

    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.

  • @ajdndbdjbdj
    @ajdndbdjbdj Рік тому

    Great job homie

  • @user-ie7bt3hk3h
    @user-ie7bt3hk3h 9 місяців тому

    nice

  • @sfsdfsfdd
    @sfsdfsfdd Рік тому

    W tutorial

  • @honoredegg
    @honoredegg 2 роки тому

    51th. Thank you, ma Bro Sensei

  • @carloseduardosabbaghfranqu9367
    @carloseduardosabbaghfranqu9367 2 роки тому

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

  • @analyticseninteligenciamer724
    @analyticseninteligenciamer724 3 роки тому

    Thank you so muck Master!!!

  • @13_iwayannathawiguna_xiipa68
    @13_iwayannathawiguna_xiipa68 3 роки тому

    keep up bro

  • @henryjohannesen6986
    @henryjohannesen6986 Рік тому

    You're my hero thank you

  • @arambradosty2297
    @arambradosty2297 2 роки тому

    thank you

  • @jaymob5037
    @jaymob5037 2 роки тому

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

  • @rupeshsunuwar1868
    @rupeshsunuwar1868 3 роки тому

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

  • @mweatherly
    @mweatherly 2 роки тому +1

    Thank you Bro Code

  • @yunskodubinks8277
    @yunskodubinks8277 2 роки тому

    ❤💚💙

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 роки тому

    Thanks

  • @manuelgonzalezpalafox2627
    @manuelgonzalezpalafox2627 2 роки тому

    ly bro 3

  • @muhammedkabbani6434
    @muhammedkabbani6434 2 роки тому

    brilliant

  • @ihsannuruliman3656
    @ihsannuruliman3656 3 роки тому +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...

  • @kemann3815
    @kemann3815 2 роки тому

    Besta da best

  • @PoorwayTraning
    @PoorwayTraning Рік тому

    thanks

  • @egrenzgo5650
    @egrenzgo5650 2 роки тому

    Yey, Thank youu!!!

  • @Simis999
    @Simis999 2 роки тому

    labai didelis ačiū iš Lietuvos!

  • @anaralizada8884
    @anaralizada8884 2 роки тому

    very good

  • @MURAT-pu4hg
    @MURAT-pu4hg Рік тому

    you are my god

  • @d-news4076
    @d-news4076 2 роки тому

    Thank you Bro Code!

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 2 роки тому

    thanks bro

  • @deepinmind4091
    @deepinmind4091 Рік тому

    heeeeeey BRO!!

  • @cdjosh3568
    @cdjosh3568 4 роки тому +1

    Beat the algorithm!

  • @zeinabbarakat5558
    @zeinabbarakat5558 8 місяців тому

    how do I add a Button over the JPanel?

  • @rectaalborween8471
    @rectaalborween8471 7 місяців тому

    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?

  • @jamaalgamble3441
    @jamaalgamble3441 8 місяців тому

    YASSSS!

  • @bwsoul9770
    @bwsoul9770 3 роки тому

    Maa maan thank u

    • @BroCodez
      @BroCodez  3 роки тому

      thank you for watching!

  • @kushal6065
    @kushal6065 Рік тому

    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.

  • @8rboy
    @8rboy 2 роки тому

    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

  • @wdwuccnxcnh7022
    @wdwuccnxcnh7022 2 роки тому

    How did you add the image????

  • @Ollie__07
    @Ollie__07 2 роки тому

    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.

  • @justinpalmer9387
    @justinpalmer9387 2 роки тому

    Goated

  • @towbeetowbee3124
    @towbeetowbee3124 2 роки тому

    how can i resize my icon inside the label??

  • @kylemandeeomadlao9014
    @kylemandeeomadlao9014 6 місяців тому

    how to add image?

  • @slumdogskillionaire923
    @slumdogskillionaire923 2 роки тому

    7:25 Border layout

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Рік тому

  • @natgfx6027
    @natgfx6027 2 роки тому

    what if we overlap them what will happen

  • @SaphiraBlauauge
    @SaphiraBlauauge 7 місяців тому

    -1000 HP to the Algorythm

  • @rooveloft5273
    @rooveloft5273 2 роки тому

    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 2 роки тому

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

  • @augischadiegils.5109
    @augischadiegils.5109 3 роки тому

  • @slumdogskillionaire923
    @slumdogskillionaire923 2 роки тому

    6:50 Flow Layout Manager

  • @siriusleto3758
    @siriusleto3758 2 роки тому

    2. comment

  • @haitamelgana5139
    @haitamelgana5139 Рік тому

    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

  • @kimharveybaruela4128
    @kimharveybaruela4128 2 роки тому

    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

  • @BISAMARKSMANDOANG
    @BISAMARKSMANDOANG Рік тому

    gg

  • @sabermmirza
    @sabermmirza 3 роки тому

    thank

    • @BroCodez
      @BroCodez  3 роки тому

      thanks for watching Saber!

  • @anjapietralla5767
    @anjapietralla5767 7 місяців тому

  • @qwerttz1033
    @qwerttz1033 2 роки тому

    I copied your code but my icon is invisible

  • @Paul122M
    @Paul122M 3 роки тому

    random comment

  • @greeneggsandmushrooms9855
    @greeneggsandmushrooms9855 3 роки тому

    slenap

  • @joyceasante8292
    @joyceasante8292 Рік тому

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

  • @soumelee5661
    @soumelee5661 Рік тому

  • @eugenezuev7349
    @eugenezuev7349 4 місяці тому