Java LayeredPane 📚

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

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

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

    import javax.swing.*;
    import java.awt.*;
    public class Main {

    public static void main(String[] args) {

    // JLayeredPane = Swing container that provides a
    // third dimension for positioning components
    // ex. depth, Z-index

    JLabel label1= new JLabel();
    label1.setOpaque(true);
    label1.setBackground(Color.RED);
    label1.setBounds(50,50,200,200);

    JLabel label2= new JLabel();
    label2.setOpaque(true);
    label2.setBackground(Color.GREEN);
    label2.setBounds(100,100,200,200);

    JLabel label3= new JLabel();
    label3.setOpaque(true);
    label3.setBackground(Color.BLUE);
    label3.setBounds(150,150,200,200);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setBounds(0,0,500,500);

    //layeredPane.add(label1, JLayeredPane.DEFAULT_LAYER);
    layeredPane.add(label1, Integer.valueOf(0));
    layeredPane.add(label2, Integer.valueOf(2));
    layeredPane.add(label3, Integer.valueOf(1));

    JFrame frame = new JFrame("JLayeredPane");
    frame.add(layeredPane);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(new Dimension(500, 500));
    frame.setLayout(null);
    frame.setVisible(true);
    }
    }

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

      Practicing...
      import javax.swing.*;
      import java.awt.*;
      public class Main
      {
      public static void main(String[] args) {
      JLabel label1 = new JLabel();
      label1.setOpaque(true);
      label1.setBackground(Color.BLUE);
      label1.setBounds(25,25,100,100);
      JLabel label2 = new JLabel();
      label2.setOpaque(true);
      label2.setBackground(Color.YELLOW);
      label2.setBounds(75,75,100,100);
      JLabel label3 = new JLabel();
      label3.setOpaque(true);
      label3.setBackground(Color.RED);
      label3.setBounds(125,125,100,100);
      JLayeredPane layeredPane = new JLayeredPane();
      layeredPane.setBounds(0,0,250,250);
      layeredPane.add(label1, Integer.valueOf(0));
      layeredPane.add(label2, Integer.valueOf(1));
      layeredPane.add(label3, Integer.valueOf(3));
      JFrame frame = new JFrame("JLayeredPane");
      frame.add(layeredPane);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(new Dimension (500, 500));
      frame.setLayout(null);
      frame.setVisible(true);
      }
      }

  • @archangel8273
    @archangel8273 3 года назад +8

    This saved my life for a Assignment. I wasn't even aware of JLayeredPane until your video. Thank you, your content is well structured and delivered perfectly!

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

  • @Daaninator
    @Daaninator 3 года назад +1

    bro code... ur ma bro

  • @apostolostsantakis6871
    @apostolostsantakis6871 2 года назад +2

    THANK YOU. Oracle's descriptions were confusing, but you managed to teach me LayeredPane in a short comprehensive video. Good job.

  • @krishp2321
    @krishp2321 2 месяца назад +1

    I'm curious about why at 7:02 we need to use the wrapper class for the numbers that are being used as shortcuts to correspond to specific layers?

    • @kcseanbrixd.calinao6700
      @kcseanbrixd.calinao6700 23 дня назад +1

      I think it's because of the Enum Constant. as per his Enum video. Not sure tho

  • @Healthyroutines.
    @Healthyroutines. 4 года назад +2

    is this tutorial enough to learn java android for android development and please what are the tutorial that you recommend for Android development
    thank you are the best

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

      Android uses Java but the layout is different. I believe FreeCodeCamp has a course when I did a search. They have good content

  • @joshdyer1688
    @joshdyer1688 Год назад +1

    Many thanks for producing these excellent tutorials with clear explanations.

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

    Wow man, you found me and this is just great! Your uploads are all very awesome and informative. I can't wait to watch these because I've been wanting to teach myself Python and C++. Thank you 😃

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

      thanks! I'll be adding more Python and C++ videos in the future. Right now I have been focusing on Java for the time being due to popular demand

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

      @@BroCodez Great! No problem, I could use some review with Java. I need to learn the swing library anyway haha

  • @云从龙-z7k
    @云从龙-z7k 5 месяцев назад

    Hello Bro, curious question: I tried to call the .setBounds() methods for layeredPane, but it didn't work. Can you please help me?

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

    Woah I’m dropping all kinds of comments

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

    Хай тем, кто смотрит в переводе! Учимся боли в суставах, пацаны, аахах)

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

    thanks!

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

    Once explained properly its amazing how easy it was although I was wondering if there was more explanation to the different layers. If they intended certain layers in preference for certain tasks?

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

    Hallo Bro, your Videos are Great!! can you give me an answer to my problem? (sorry i'm german)
    when i add a MouseMotionListener on an Label in your Program above, it makes the dragging but its flickering . Perhaps ist not so good idea to drag Labels? Greetings from Germany Marianne

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

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

    I wondered what happens when you remove Integer.valueOf() and instead just put into the number you want. Very interesting thing happens. If you put Integer.valueOf just like in the video, the label which gets 0 is first put into the screen. Label 1 is put second, label 2 is put third etc.
    On the other hand, if you don't write Integer.valueOf and instead you just write the number you want, then the 0 label is the one which is put the last, label 1 is put second to last etc.

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

    Thank you!!! You're the best!

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

    In Germany we say:
    "Ehre bruder! Hast uns gerettet!"

  • @Bomber-Trebor
    @Bomber-Trebor Месяц назад

    Commend XD

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

    Love new music background :DDD

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

    Maybe i can use this in making a GUI library

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

    thanks

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

    Thanks

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

    Yea!

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

    Hi friend can you explain difference between Color.red and Color.RED (because java is a case sensitive language then how the constant is allow lowercase letters. its going to break java is a case sensitive language or not?)

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

    Thanks✨

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

    Bro,
    How to add multiple icons on JFrame/JDialog (example, I need to place info icon in JFrame)

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

      to put it in the JFrame you can just use a label:
      ImageIcon infoIcon = new ImageIcon("src/info.png");
      JLabel infoLabel = new JLabel();
      infoLabel.setIcon(infoIcon);
      this.add(infoLabel);
      // if you are using
      that should work

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

    Thank you very mach bro 👍👋👍

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

    Exactly what i was looking for, thanks!❤

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

    Very easy think

  • @speklex779
    @speklex779 11 месяцев назад

    Nice video

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

    THANK YOU Bro.

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

    thanks bro

  • @НікітаОрлов-с3ч
    @НікітаОрлов-с3ч Год назад

    Thanks for lessons !!!!!!

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

    thanks Brooooo

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

    stuffnthings

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

    thanks bro

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

    Thanks

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

    thank you for the content

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

    Nice video

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

    best teacher, thank you 👍

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

    Muito bom como sempre!!!

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

    Nice, bro!

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

    nice vid

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

    شكرا شكرا شكرا شكرا
    انه مجهود رائع
    شكرا مرة ثانية 🤍🤍🤍
    ------------------------------------ -------------------------- ----------------------------
    Thanks thanks thanks thanks
    It's a great effort
    Thanks again🤍🤍🤍