Java LayeredPane 📚

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ม.ค. 2025

ความคิดเห็น • 57

  • @BroCodez
    @BroCodez  4 ปีที่แล้ว +22

    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.

  • @sushantlama9010
    @sushantlama9010 4 ปีที่แล้ว

    Nice video

  • @elvispontes4165
    @elvispontes4165 2 ปีที่แล้ว

    Muito bom como sempre!!!

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

  • @zari_723
    @zari_723 2 ปีที่แล้ว

    Love new music background :DDD

  • @programmer5834
    @programmer5834 2 ปีที่แล้ว

    Very easy think

  • @soumelee5661
    @soumelee5661 2 ปีที่แล้ว

    nice vid

  • @krishp2321
    @krishp2321 5 หลายเดือนก่อน +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 4 หลายเดือนก่อน +1

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

  • @musoxoshimov4908
    @musoxoshimov4908 3 ปีที่แล้ว

    best teacher, thank you 👍

  • @НікітаОрлов-с3ч
    @НікітаОрлов-с3ч 2 ปีที่แล้ว

    Thanks for lessons !!!!!!

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

  • @gharibarray
    @gharibarray 2 ปีที่แล้ว

    Thank you very mach bro 👍👋👍

  • @kemann3815
    @kemann3815 3 ปีที่แล้ว

    Exactly what i was looking for, thanks!❤

  • @greypray6106
    @greypray6106 4 ปีที่แล้ว +1

    Thank you!!! You're the best!

  • @nehalayaaz9406
    @nehalayaaz9406 4 ปีที่แล้ว +1

    Thanks✨

  • @henriquefelinimena3693
    @henriquefelinimena3693 3 ปีที่แล้ว

    thank you for the content

  • @alexshepel5599
    @alexshepel5599 4 ปีที่แล้ว

    Nice, bro!

  • @gunshybiscuit2855
    @gunshybiscuit2855 2 ปีที่แล้ว

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

  • @SLURPZZZ4461
    @SLURPZZZ4461 ปีที่แล้ว

    thanks

  • @angelcastineira2561
    @angelcastineira2561 4 ปีที่แล้ว +1

    thanks!

  • @mahdinemati8573
    @mahdinemati8573 2 ปีที่แล้ว

    THANK YOU Bro.

  • @majid1885
    @majid1885 3 ปีที่แล้ว

    thanks Brooooo

  • @ottttoooo
    @ottttoooo 3 ปีที่แล้ว

    thanks bro

  • @developerjunior446
    @developerjunior446 3 ปีที่แล้ว

    Thanks

  • @Daaninator
    @Daaninator 3 ปีที่แล้ว +1

    bro code... ur ma bro

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

  • @dhiyanabdurazack5257
    @dhiyanabdurazack5257 ปีที่แล้ว

    Yea!

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

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

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

  • @云从龙-z7k
    @云从龙-z7k 9 หลายเดือนก่อน

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

  • @JavaObjectException
    @JavaObjectException 3 ปีที่แล้ว

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

    • @Blackilykat
      @Blackilykat 3 ปีที่แล้ว +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

  • @geeksahid3698
    @geeksahid3698 3 หลายเดือนก่อน

    🤷🏻

  • @garevllevar4356
    @garevllevar4356 2 ปีที่แล้ว

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

  • @eugenezuev7349
    @eugenezuev7349 7 หลายเดือนก่อน

  • @SlothfulSage285
    @SlothfulSage285 11 หลายเดือนก่อน

    Woah I’m dropping all kinds of comments

  • @greeneggsandmushrooms9855
    @greeneggsandmushrooms9855 3 ปีที่แล้ว

    stuffnthings

  • @Bomber-Trebor
    @Bomber-Trebor 4 หลายเดือนก่อน

    Commend XD

  • @m7mmadomar
    @m7mmadomar 3 ปีที่แล้ว

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

  • @speklex779
    @speklex779 ปีที่แล้ว

    Nice video

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 2 ปีที่แล้ว

    thanks bro

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 ปีที่แล้ว

    Thanks