Help with alignment
Here is my program, its like a 3 number hi-low game.
I am using JPANEL for the top, middle, and bottom rows. Then inside those panels I use gridlayout to layout the objects. I want to know if instead of them being in their respective grids on the left hand side, if they could be centered inside of their grid?
I tried using setAlignmentX and that didn't work. I don't really know how to go about it. I'll post a snippet of my code that is important.
EDIT: I drew what I want it to be like in paint... :D
//middle panel setup
JPanel middle = new JPanel();
middle.setLayout(new GridLayout(1, 3));
higher = new JButton("Higher");
or = new JLabel("OR");
lower = new JButton("Lower");
Hello and welcome to the forum.
JLabel has a constructor that allows you to set the position of the text in the label, i.e.,
Why not give this a try and let us know if it helps.
JLabel myLabel = new JLabel("Spamalot", SwingConstants.CENTER);
Lol wow you are a GOD. Thanks!
Nah, just someone who had the same problem as you some time in the past. Glad it helped and hope to see you around here again.
Originally Posted by firecat318