I wrote the code below:
public class Information extends JFrame{
private JComboBox comboBox1;
private JComboBox comboBox2;
private JTextField textField[];
private JTextField jtextField;
private JLabel label[];
public Information()
{
setLayout(new flowlayout());
Box box = Box.createVerticalBox();
for(int i = 0; i < 20; i++)//textfield
{
textField = new JTextField[20];
box.add(Box.createRigidArea(new Dimension(5,5)));
textField[i] = new JTextField(2);
textField[i].setAlignmentX(2f);
textField[i].setAlignmentY(2f);
box.add(textField[i]);
}
for(int i = 0; i < 22; i++ )//lable
{
}
add(box);
}
}
I want that text field showed in my favorite size, but it fills the whole screen.
I used
textField[i].setAlignmentX(2f);
textField[i].setAlignmentY(2f);
and setcolum()
, but it didn't resize the text field. How can I decrease my text fields' sizes?
I use from
setMaximumSize(new Dimension(80, 70));
setPreferredSize(new Dimension(50, 50));
their resize the textfield but change it's location but i don't want to change their
location.is there any manner than i change textfield position?
i use from setlocation but it didn't work!!.