I'm new to using swing and jframe components in java, and I've been working on making a console for a game. I'm trying to align the elements of the console like so:
_______________________________
| _____________________ |
| | | |
| | Output | |
| |___________________| |
| |
| _______ |
| |_Input_| |
|_____________________________|
My current program, shown below, displays the input and output boxes next to each other, rather than above and below each other.
import javax.swing.*;
import java.awt.*;
public class GUI{
public static void main(String[] args) {
SwingUtilities.invokeLater(GUI::startUp);
}
private static void startUp() {
JFrame frame = new JFrame("AoA");
frame.setLayout(new BoxLayout(frame, BoxLayout.Y_AXIS));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1020,760);
frame.setBackground(Color.LIGHT_GRAY);
frame.setResizable(false);
frame.setLayout(new FlowLayout());
JTextArea jta = new JTextArea(30,60);
jta.setEditable(false);
jta.setBackground(Color.WHITE);
frame.add(new JScrollPane(jta));
JTextField jta2 = new JTextField();
jta2.setPreferredSize(new Dimension(200,70));
jta2.setHorizontalAlignment((int) JTextField.CENTER_ALIGNMENT);
frame.add(new JScrollPane(jta2));
frame.setVisible(true);
jta.append("Test");
}
}
How could I set the alignment of these components so that they match the intended result?