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.
@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!
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.
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);'
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?
@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!
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
Hope you enjoy the next video in the Java Swing tutorial series.
this whole series is incredible, thank you so much. Ez sub
This is the example I've been looking for Thank you so much
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.
@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!
@@JavaCodeJunkie yes it Helps and thank you very much...
Cheers❤️
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.
Merci de la part de l’Algérie 🇩🇿
@Nariman Salmi - C'est un plaisir et merci d'avoir regardé!
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);'
@Adam Asimolowo - It works for me with the following change.
getContentPane().add(panel) instead of
contentPane.add(panel).
Cheers!
@@JavaCodeJunkie thabks
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?
subscribed! thanks for these java swing vid .
@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!
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!
@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!
Amazing video!!!
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
nice one, thanks man
Thank you! 1:19 You didn't mention LayoutManagers in the second video, though
good work.
Thank you for the kind words! I appreciate you taking the time to comment! Cheers!
Very nice Sir❤. Next please Sir. How to create X Y coordinates grid🙏
Hello