Hi - I am attempting to dump the GUI editor and code everything by hand - big task for me! I am setting up my JForm with 4 panels, 3 to hold my data and a 4th as a "parent" that will house everything before adding to the JForm.
Now my issue is, in the top most form, I have the positioning set to center for both the label and the text box and they appear on the same line. I want the text area to appear on the line BELOW the label and fill about half of that row.
How should this be altered so that takes place?
import javax.swing.*; import java.awt.*; public class Data { public static void main(String args[]) { JFrame frMain; JPanel pnlName; JPanel pnlCharacterSelect; JPanel pnlButtonHolder; JLabel lblCharaterSelect; JTextField txtName; JButton btnStartGame; JLabel lblWelcome; frMain = new JFrame(); pnlName = new JPanel(); pnlCharacterSelect = new JPanel(); pnlButtonHolder = new JPanel(); pnlName.setBackground(Color.WHITE); pnlName.setMaximumSize(( new Dimension( 1000, 100))); pnlName.setAlignmentX(Component.CENTER_ALIGNMENT); lblWelcome = new JLabel("Input Player Name:", SwingConstants.CENTER); txtName = new JTextField(SwingConstants.CENTER); pnlCharacterSelect.setBackground(Color.BLUE); pnlCharacterSelect.setMaximumSize(( new Dimension( 1000, 600))); pnlCharacterSelect.setAlignmentX(Component.CENTER_ALIGNMENT); pnlButtonHolder.setBackground(Color.GREEN); pnlButtonHolder.setMaximumSize(( new Dimension( 1000, 50))); pnlButtonHolder.setAlignmentX(Component.CENTER_ALIGNMENT); pnlName.add(lblWelcome); pnlName.add(txtName); JPanel holder = new JPanel(); holder.setLayout(new BoxLayout(holder, BoxLayout.Y_AXIS)); holder.add(pnlName); holder.add(pnlCharacterSelect); holder.add(pnlButtonHolder); frMain.add(holder, BorderLayout.CENTER); frMain.setSize(400,400); frMain.setVisible(true); } }