I try to make a calculator(GUI Only) with JText, JPanel and FlowLayout. When I run to test it the number are on the left side of JText. I want to make the number to stay in next line :
import java.awt.*;
import javax.swing.*;
public class Main{
public static void main(String[] args) {
Ex2();
}
}
public static void Ex2(){
JFrame f = new JFrame("Cal");
Container cp = f.getContentPane();
cp.setLayout(new FlowLayout());
JTextField t1 = new JTextField(20);
t1.setBounds(10, 10, 200, 25);
cp.add(t1);
JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.LEFT));
JButton b1 = new JButton("0");
p.add(b1);
JButton b2 = new JButton("1");
p.add(b2);
JButton b3 = new JButton("2");
p.add(b3);
JButton b4 = new JButton("3");
p.add(b4);
JButton b5 = new JButton("4");
p.add(b5);
JButton b6 = new JButton("5");
p.add(b6);
cp.add(p);
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}