Java LayeredPane 📚

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

КОМЕНТАРІ • 57

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

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

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

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

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

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

    Very easy think

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

    Muito bom como sempre!!!

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

    Exactly what i was looking for, thanks!❤

  • @НікітаОрлов-с3ч
    @НікітаОрлов-с3ч 2 роки тому

    Thanks for lessons !!!!!!

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

    Love new music background :DDD

  • @smrtfasizmu6161
    @smrtfasizmu6161 3 роки тому +2

    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.

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

    best teacher, thank you 👍

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

    Nice video

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

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

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

    Thank you!!! You're the best!

  • @krishp2321
    @krishp2321 3 місяці тому +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 2 місяці тому +1

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

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

    Thank you very mach bro 👍👋👍

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

    thanks

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

    Thanks✨

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

    thanks!

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

    thank you for the content

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

    THANK YOU Bro.

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

    Thanks

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

    thanks Brooooo

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

    Yea!

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

    thanks bro

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

    Nice, bro!

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

    nice vid

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

    Maybe i can use this in making a GUI library

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

  • @Daaninator
    @Daaninator 3 роки тому +1

    bro code... ur ma bro

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

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

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

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

  • @geeksahid3698
    @geeksahid3698 Місяць тому

    🤷🏻

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

  • @云从龙-z7k
    @云从龙-z7k 7 місяців тому

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

    Woah I’m dropping all kinds of comments

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

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

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

    stuffnthings

  • @Bomber-Trebor
    @Bomber-Trebor 3 місяці тому

    Commend XD

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

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

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

    Nice video

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

    Thanks

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

    thanks bro