JPanel | Java Swing Tutorial for Beginners

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

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

  • @JavaCodeJunkie
    @JavaCodeJunkie  4 года назад +15

    Hope you enjoy the next video in the Java Swing tutorial series.

  • @conorohagan9947
    @conorohagan9947 9 месяцев назад +3

    this whole series is incredible, thank you so much. Ez sub

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

    This is the example I've been looking for Thank you so much

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

    Thank you. Great video.
    I have a question. When add component to the JFrame , I seen someone first get Content Pane and then add component to it. ( frame.getContentPane().add() ). You add component directly to the Frame. Can I know what is the different and what is your recommendation to use.
    Thank you.

    • @JavaCodeJunkie
      @JavaCodeJunkie  2 года назад +3

      @Kavishka Madhudhan - Thank you for the question! There is no difference between the two ways of adding a component to a JFrame. The frame.add(component) method is actually a convenience method that actually calls the getContentPane.add() method. If you check out the code of the JFrame class you will see how that is accomplished.
      Hope this helps.
      Cheers!

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

      @@JavaCodeJunkie yes it Helps and thank you very much...
      Cheers❤️

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

    I'm facing a problem. When I use Button and move the frame to my other monitor the buttons disappear. If I change to JButton this does not happen. But in one of the monitors the content text is cutted.

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

    Merci de la part de l’Algérie 🇩🇿

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

      @Nariman Salmi - C'est un plaisir et merci d'avoir regardé!

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

    How would you set a 'JPanel' invisible? I want the components within my JPanel to be invisible when I run the application(on default), but it's not working.
    My Code:
    'JPanel panel = new JPanel();
    panel.setBorder(new LineBorder(new Color(0, 0, 0)));
    panel.setBackground(Color.WHITE);
    panel.setBounds(0, 35, 118, 142);
    contentPane.add(panel);
    panel.setVisible(false);'

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

      @Adam Asimolowo - It works for me with the following change.
      getContentPane().add(panel) instead of
      contentPane.add(panel).
      Cheers!

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

      @@JavaCodeJunkie thabks

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

    Hello,
    thanks for the video! I m looking for a solution where theres a panel on top of another panel each taking full width of the window. How would you do that?

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

    subscribed! thanks for these java swing vid .

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

      @John Lj - Thank you for subscribing! I am glad that you like the Swing videos. I plan to continue the series so there is much more to come!

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

    Hi,
    you have not talked about the line 21, and you have not talk about it in the previous video as well, so what is line 21, these (10, 5);
    thank you!

    • @JavaCodeJunkie
      @JavaCodeJunkie  3 года назад +3

      @philip8989 - There are two constructors that you can use when creating an instance of BorderLayout.
      Constructors
      1. BorderLayout() - Constructs a new border layout with no gaps between components.
      2. BorderLayout​(int hgap, int vgap) - Constructs a border layout with the specified gaps between components.
      The line that you are referring to simply creates a new BorderLayout with a horizontal gap of 10 pixels nd a vertical gap of 5 pixels between any controls that are added to the JPanel.
      Cheers!

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

    Amazing video!!!

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

    It's my first time trying my hand at JFRAME, JPanel, and the like, I'm trying to create an installer for a doom mod I'm working on
    but I can't seem to get this code to run properly, I haven't coded in java in god knows how long, where should I throw public static void main(String[]args) {??? sorry if it seems like a very rookie mistake but it's quite literalyl my first time programming since high-school XD

  • @m.s.i3603
    @m.s.i3603 5 месяцев назад

    nice one, thanks man

  • @NadChel1
    @NadChel1 7 месяцев назад

    Thank you! 1:19 You didn't mention LayoutManagers in the second video, though

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

    good work.

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

      Thank you for the kind words! I appreciate you taking the time to comment! Cheers!

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

    Very nice Sir❤. Next please Sir. How to create X Y coordinates grid🙏

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

    Hello