Java LayeredPane 📚

Sdílet
Vložit
  • čas přidán 26. 07. 2024
  • Java JLayeredPane tutorial,
    #java #layeredpane #jlayeredpane #tutorial
    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);
    }
    }
  • Věda a technologie

Komentáře • 53

  • @BroCodez
    @BroCodez  Před 4 lety +19

    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 Před rokem

      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 Před 3 lety +7

    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 Před 2 lety +1

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

  • @elvispontes4165
    @elvispontes4165 Před 2 lety

    Muito bom como sempre!!!

  • @joshdyer1688
    @joshdyer1688 Před 10 měsíci

    Many thanks for producing these excellent tutorials with clear explanations.

  • @kemann3815
    @kemann3815 Před 2 lety

    Exactly what i was looking for, thanks!❤

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 Před rokem +1

    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

  • @greypray6106
    @greypray6106 Před 4 lety +1

    Thank you!!! You're the best!

  • @user-yz9cp6fp4k
    @user-yz9cp6fp4k Před rokem

    Thanks for lessons !!!!!!

  • @musoxoshimov4908
    @musoxoshimov4908 Před 3 lety

    best teacher, thank you 👍

  • @leonardovillalobos5277
    @leonardovillalobos5277 Před 4 lety +2

    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  Před 4 lety +1

      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 Před 4 lety +1

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

  • @nehalayaaz9406
    @nehalayaaz9406 Před 4 lety +1

    Thanks✨

  • @zari_723
    @zari_723 Před rokem

    Love new music background :DDD

  • @henriquefelinimena3693

    thank you for the content

  • @alexshepel5599
    @alexshepel5599 Před 3 lety

    Nice, bro!

  • @angelcastineira2561
    @angelcastineira2561 Před 4 lety +1

    thanks!

  • @gharibarray
    @gharibarray Před 2 lety

    Thank you very mach bro 👍👋👍

  • @mahdinemati8573
    @mahdinemati8573 Před rokem

    THANK YOU Bro.

  • @Drowe71
    @Drowe71 Před rokem

    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?

  • @sushantlama9010
    @sushantlama9010 Před 3 lety

    Nice video

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Před 2 lety

    Thanks

  • @SLURPZZZ4461
    @SLURPZZZ4461 Před rokem

    thanks

  • @ottttoooo
    @ottttoooo Před 3 lety

    thanks bro

  • @majid1885
    @majid1885 Před 2 lety

    thanks Brooooo

  • @gunshybiscuit2855
    @gunshybiscuit2855 Před 2 lety

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

  • @programmer5834
    @programmer5834 Před 2 lety

    Very easy think

  • @kizuffy3338
    @kizuffy3338 Před rokem

    Maybe i can use this in making a GUI library

  • @dhiyanabdurazack5257
    @dhiyanabdurazack5257 Před rokem

    Yea!

  • @mariannerohrens5615
    @mariannerohrens5615 Před 2 lety

    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

  • @Healthyroutines.
    @Healthyroutines. Před 4 lety +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  Před 4 lety +2

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

  • @anandv7900
    @anandv7900 Před 3 lety

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

  • @Daaninator
    @Daaninator Před 3 lety +1

    bro code... ur ma bro

  • @soumelee5661
    @soumelee5661 Před rokem

    nice vid

  • @user-mj8gd7eh2x
    @user-mj8gd7eh2x Před 3 měsíci

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

  • @eugenezuev7349
    @eugenezuev7349 Před 2 měsíci

  • @JavaObjectException
    @JavaObjectException Před 3 lety

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

    • @Blackilykat
      @Blackilykat Před 2 lety +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

  • @garevllevar4356
    @garevllevar4356 Před 2 lety

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

  • @SlothfulSage285
    @SlothfulSage285 Před 6 měsíci

    Woah I’m dropping all kinds of comments

  • @greeneggsandmushrooms9855

    stuffnthings

  • @smrtfasizmu6161
    @smrtfasizmu6161 Před 2 lety +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.

  • @m7mmadomar
    @m7mmadomar Před 3 lety

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

  • @speklex779
    @speklex779 Před 8 měsíci

    Nice video

  • @developerjunior446
    @developerjunior446 Před 3 lety

    Thanks

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 Před 2 lety

    thanks bro