i have problem with JTextField, I cannot set its size. When I run program, it's showing me text field on whole screen. I want to make JTextField smaller. Do you know please where is the problem? (Sorry for my bad english)
My problem is that I've set size of JTextField but it doesn't work.
public class MyJFrame extends JFrame {
JLabel label;
String Time = "00:34:12.123";
JPanel MainPanel = new JPanel();
JPanel PINPanel = new JPanel();
JPanel MenuPanel = new JPanel();
JPanel CashPanel = new JPanel();
JPanel WaitPanel = new JPanel();
JPanel TimePanel = new JPanel();
JButton Cash = new JButton();
JButton Time1 = new JButton();
JButton ConfirmPIN = new JButton();
JButton ConfirmCash = new JButton();
JButton ConfirmWait = new JButton();
JLabel PIN = new JLabel();
JTextField EnterPIN = new JTextField(1);
CardLayout CL = new CardLayout();
public MyJFrame(){
super();
initUI();
placeComponents();
bindListeners();
}
private void initUI() {
this.setSize(385, 400);
this.setTitle("ITS class");
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setResizable(false);
}
private void placeComponents(){
PINPanel.setLayout(new BorderLayout());
MainPanel.setLayout(CL);
MainPanel.add(PINPanel, "1");
CL.show(MainPanel, "1");
ConfirmPIN.setText("Ok");
ConfirmPIN.setSize(1,1);
ConfirmPIN.setLocation(150,200);
PIN.setText("Please enter your PIN: ");
PIN.setLocation(20,100);
EnterPIN.setLocation(50,100);
EnterPIN.setSize (10, 10);
this.getContentPane().add(MainPanel);
PINPanel.add(ConfirmPIN);
PINPanel.add(PIN);
PINPanel.add(EnterPIN);