package numerical.project;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class NumericalProject {
public static void main(String[] args) {
JFrame frame= new JFrame("Numerical");
frame.setSize(400,100);
FlowLayout flow= new FlowLayout();
frame.setLayout(flow);
JLabel L1= new JLabel("Equation"); //label
JTextField T1= new JTextField(10); //textfield1
JLabel L2= new JLabel("A Value"); //label2
JTextField T2= new JTextField(5); //textfield2
T2.setEditable(false);
JLabel L3= new JLabel("B Value");
JTextField T3= new JTextField(5);
T3.setEditable(false);
JButton b1= new JButton("Calculate");
frame.add(L1);
frame.add(T1);
frame.add(b1);
frame.add(L2);
frame.add(T2);
frame.add(T3);
frame.add(L3);
frame.setVisible(true);
}
}
How do I put text fields and buttons under each other?
For example, I want to put the label equation next to it the first text field, the label A value next to it the 2nd text field, B value next to it the 3rd text field, and at the center the button.