Cool bro! Thank you so much! I finally understand the things of gridWidth and gridHeight, insets and fill. God Bless you so much! You are just amazing at explaining things in a very simple and efficient way!
Thanks! The grid bag layout is peculiar, especially in regards to setting the width/height on components. I appreciate the straightforward tutorial to clear things up.
I wish you would have talked about the FIRST_LINE_END, LINE_END,…. and such. Those don't seem to work the way they are described. I have a JFrame using BorderLayout and add JPanel classes that use GridBagLayouts. I can't get the rows and columns to work right.
Great tutorial. 11:00 gbc.gridheight = 5 means that the height of button 1 should be 5 cells [0, 0 to 0, 4] but it is only showing up in 4 cells [0, 1 to 0, 4]. Why isn't button 1 showing up in cell 0,0?
At double speed, this was quite watchable. Thank you for this tutorial on the absolute basics of GridBagLayout. I'll need more to be able to properly use it, but it's a good start.
Very helpful video. make it in 1.5x though
Melhor vdeo com este conteudo que ja vi…..
Muito obrigado
Cool bro! Thank you so much! I finally understand the things of gridWidth and gridHeight, insets and fill. God Bless you so much! You are just amazing at explaining things in a very simple and efficient way!
1.75 speed
does it work only with buttons.
Asking because cant make it work
thanks for help
public void setPositionAdd(Component c, int gridx, int gridy) {
gbc.gridx = gridx;
gbc.gridy = gridy;
mainPanel.add(c,gbc);
}
this tutorial may be 8 years old but ty for saving me
thank you so much it helped me alot
Thanks! The grid bag layout is peculiar, especially in regards to setting the width/height on components. I appreciate the straightforward tutorial to clear things up.
I wish you would have talked about the FIRST_LINE_END, LINE_END,…. and such. Those don't seem to work the way they are described. I have a JFrame using BorderLayout and add JPanel classes that use GridBagLayouts. I can't get the rows and columns to work right.
Heres the whole code: import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Tutorial extends JPanel
{
JButton b1, b2, b3, b4, b5;
GridBagConstraints gbc = new GridBagConstraints();
public Tutorial2()
{
setLayout(new GridBagLayout());
gbc.insets = new Insets(5, 5, 5, 5);
b1 = new JButton("Button1");
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridheight = 5;
gbc.fill = GridBagConstraints.VERTICAL;
add(b1, gbc);
b2 = new JButton("Button2");
gbc.gridx = 1;
gbc.gridy = 1;
gbc.gridheight = 1;
add(b2, gbc);
b3 = new JButton("Button3");
gbc.gridx = 2;
gbc.gridy = 2;
gbc.gridheight = 1;
add(b3, gbc);
b4 = new JButton("Button4");
gbc.gridx = 3;
gbc.gridy = 3;
gbc.gridheight = 1;
add(b4, gbc);
b5 = new JButton("Button5");
gbc.gridx = 1;
gbc.gridy = 4;
gbc.gridheight = 1;
gbc.gridwidth = 3;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(b5, gbc);
}
public static void main(String[] args)
{
Tutorial t = new Tutorial();
JFrame jf = new JFrame();
jf.setTitle("Tutorial");
jf.setSize(500, 500);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
jf.add(t);
}
}
Great tutorial. 11:00 gbc.gridheight = 5 means that the height of button 1 should be 5 cells [0, 0 to 0, 4] but it is only showing up in 4 cells [0, 1 to 0, 4]. Why isn't button 1 showing up in cell 0,0?
Why is everything at the center of the Panel … How to do you compress the layout so that it is not centered??
GREAT video. I think gridbaglayout is the best option for buttons but it is a little complex. This video was of the perfect complexity and length
Very good Tutorial! Thank you very much.
Thanks so much. Regards from Zapopan, México. :')
At double speed, this was quite watchable. Thank you for this tutorial on the absolute basics of GridBagLayout. I'll need more to be able to properly use it, but it's a good start.
I've seen several tutorials about GribBagLayouts but this is the very first one which explains weigh and fill credentials in proper way. Thanks a lot.
Good tutorial. In speed 1.5