Java panels 🟥

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 106

  • @BroCodez
    @BroCodez  4 года назад +66

    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 8 месяцев назад

      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 года назад +62

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

  • @AdrianTregoning
    @AdrianTregoning 2 года назад +13

    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

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 Год назад +3

    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

  • @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!

  • @bruce9067
    @bruce9067 4 года назад +9

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

  • @ItamiPlaysGuitar
    @ItamiPlaysGuitar 4 года назад +16

    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 года назад +17

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

  • @stephendavol5589
    @stephendavol5589 10 месяцев назад

    Great job breaking it down. Thanks man!

  • @travel_to_wonders6666
    @travel_to_wonders6666 2 года назад

    Op explain bro thnx for sharing khowledge in such way

  • @dianamilenaarchilacordoba4632
    @dianamilenaarchilacordoba4632 2 месяца назад

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

  • @TheRickyfranco13
    @TheRickyfranco13 Год назад

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

  • @Neeraj_vish_
    @Neeraj_vish_ 6 месяцев назад

    That's really nice 👍♥️

  • @liaMXWolfGaming
    @liaMXWolfGaming 9 месяцев назад

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

  • @carloseduardosabbaghfranqu9367
    @carloseduardosabbaghfranqu9367 2 года назад

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

  • @ajaykumar_tamilan
    @ajaykumar_tamilan 2 года назад

    nice video thanks bro

  • @danny.3036
    @danny.3036 3 года назад +2

    Thanks, Bro! ☕ You're awesome!

  • @jaymob5037
    @jaymob5037 3 года назад

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

  • @karimsaid3472
    @karimsaid3472 Год назад

    good explanation bro

  • @mudassirnaz1813
    @mudassirnaz1813 3 года назад

    thanks , and I appreciate your hard work.

  • @deepdaddy1208
    @deepdaddy1208 4 года назад +2

    great video bro

  • @vipinpeethambaran9777
    @vipinpeethambaran9777 2 года назад

    Great video 👌

  • @peterkalaba7618
    @peterkalaba7618 2 года назад

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

  • @Demajaasa
    @Demajaasa 3 года назад

    liking and commenting since this vid was helpful

  • @anaralizada8884
    @anaralizada8884 2 года назад

    very good

  • @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

  • @G4brielLirio
    @G4brielLirio 2 года назад

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

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

  • @曾毓哲-b1t
    @曾毓哲-b1t Год назад

    Thank you very much

  • @henryjohannesen6986
    @henryjohannesen6986 Год назад

    You're my hero thank you

  • @amarald842
    @amarald842 4 года назад +5

    That's so cool :D

    • @BroCodez
      @BroCodez  4 года назад +2

      whoa W.D. Gaster appears!

    • @amarald842
      @amarald842 4 года назад +3

      @@BroCodez XD

  • @Amirrjl-y8z
    @Amirrjl-y8z 11 месяцев назад

    nice

  • @ajdndbdjbdj
    @ajdndbdjbdj Год назад

    Great job homie

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

  • @muhammedkabbani6434
    @muhammedkabbani6434 2 года назад

    brilliant

  • @techtalk9548
    @techtalk9548 3 года назад

    You are the best!

  • @rectaalborween8471
    @rectaalborween8471 9 месяцев назад

    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?

  • @13_iwayannathawiguna_xiipa68
    @13_iwayannathawiguna_xiipa68 3 года назад

    keep up bro

  • @zeinabbarakat5558
    @zeinabbarakat5558 10 месяцев назад

    how do I add a Button over the JPanel?

  • @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?

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 2 года назад

    thanks bro

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

    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.

  • @honoredegg
    @honoredegg 2 года назад

    51th. Thank you, ma Bro Sensei

  • @mweatherly
    @mweatherly 2 года назад +1

    Thank you Bro Code

  • @analyticseninteligenciamer724
    @analyticseninteligenciamer724 3 года назад

    Thank you so muck Master!!!

  • @towbeetowbee3124
    @towbeetowbee3124 2 года назад

    how can i resize my icon inside the label??

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

  • @kemann3815
    @kemann3815 3 года назад

    Besta da best

  • @Simis999
    @Simis999 2 года назад

    labai didelis ačiū iš Lietuvos!

  • @sfsdfsfdd
    @sfsdfsfdd Год назад

    W tutorial

  • @pt4909
    @pt4909 Год назад

    Thank you!

  • @wdwuccnxcnh7022
    @wdwuccnxcnh7022 3 года назад

    How did you add the image????

  • @rupeshsunuwar1868
    @rupeshsunuwar1868 3 года назад

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

  • @arambradosty2297
    @arambradosty2297 2 года назад

    thank you

  • @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

  • @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

  • @natgfx6027
    @natgfx6027 3 года назад

    what if we overlap them what will happen

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 года назад

    Thanks

  • @kylemandeeomadlao9014
    @kylemandeeomadlao9014 8 месяцев назад

    how to add image?

  • @yunskodubinks8277
    @yunskodubinks8277 2 года назад

    ❤💚💙

  • @manuelgonzalezpalafox2627
    @manuelgonzalezpalafox2627 2 года назад

    ly bro 3

  • @PoorwayTraning
    @PoorwayTraning Год назад

    thanks

  • @egrenzgo5650
    @egrenzgo5650 2 года назад

    Yey, Thank youu!!!

  • @d-news4076
    @d-news4076 2 года назад

    Thank you Bro Code!

  • @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

  • @MURAT-pu4hg
    @MURAT-pu4hg 2 года назад

    you are my god

  • @cdjosh3568
    @cdjosh3568 4 года назад +1

    Beat the algorithm!

  • @bwsoul9770
    @bwsoul9770 4 года назад

    Maa maan thank u

    • @BroCodez
      @BroCodez  4 года назад

      thank you for watching!

  • @qwerttz1033
    @qwerttz1033 2 года назад

    I copied your code but my icon is invisible

  • @slumdogskillionaire923
    @slumdogskillionaire923 3 года назад

    7:25 Border layout

  • @soumelee5661
    @soumelee5661 2 года назад

  • @augischadiegils.5109
    @augischadiegils.5109 3 года назад

  • @deepinmind4091
    @deepinmind4091 Год назад

    heeeeeey BRO!!

  • @BISAMARKSMANDOANG
    @BISAMARKSMANDOANG Год назад

    gg

  • @justinpalmer9387
    @justinpalmer9387 3 года назад

    Goated

  • @jamaalgamble3441
    @jamaalgamble3441 10 месяцев назад

    YASSSS!

  • @slumdogskillionaire923
    @slumdogskillionaire923 3 года назад

    6:50 Flow Layout Manager

  • @sabermmirza
    @sabermmirza 4 года назад

    thank

    • @BroCodez
      @BroCodez  4 года назад

      thanks for watching Saber!

  • @SaphiraBlauauge
    @SaphiraBlauauge 9 месяцев назад

    -1000 HP to the Algorythm

  • @siriusleto3758
    @siriusleto3758 2 года назад

    2. comment

  • @anjapietralla5767
    @anjapietralla5767 10 месяцев назад

  • @greeneggsandmushrooms9855
    @greeneggsandmushrooms9855 3 года назад

    slenap

  • @Paul122M
    @Paul122M 3 года назад

    random comment

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

  • @eugenezuev7349
    @eugenezuev7349 6 месяцев назад

  • @floppaclan304
    @floppaclan304 Месяц назад

    thanks bro

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Год назад