could not view components....

this is a code which i wrote using swing ....
CODE:
----------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TextFieldDemo1 extends JFrame  {
    public Container container;
    JTextField textfield1,textfield2;

    public TextFieldDemo1()  {
        container= this.getContentPane();
container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS));
textfield1=new JTextField("",20);
textfield1.addActionListener(new TextFieldListener());
textfield1.setBorder(BorderFactory.createLineBorder(Color.black));

 textfield2=new JTextField();
textfield2.setBorder(BorderFactory.createLineBorder(Color.black));

        JButton button=new JButton("Clear");
        button.addActionListener(new ButtonListener());

        container.add(Box.createVerticalGlue());
        container.add(textfield1);
        container.add(Box.createVerticalGlue());
        container.add(textfield2);
        container.add(Box.createVerticalGlue());
        container.add(button);
        container.add(Box.createVerticalGlue());
    }//end constructor

    class TextFieldListener implements ActionListener{
        public void actionPerformed(ActionEvent e){
            textfield2.setText(e.getActionCommand());
        }
    }

    class ButtonListener implements ActionListener{
        public void actionPerformed(ActionEvent e){
            textfield1.setText("");
            textfield1.requestFocus();
            textfield2.setText("");
        }
    }


    public static void main(String args[]){

        TextFieldDemo1 text=new TextFieldDemo1();
text.addWindowListener(new WindowAdapter() {
 public void windowClosing(WindowEvent e) {
               System.exit(0);
            }
        });
        text.setTitle("Text Field Demo");
        text.setSize(300,400);
        text.setVisible(true);
    }//end main
}
----------------------------------
now the problem is that even if i have given the
createVerticalGlue() ...... it does not give any space between the textfields .. which results in a  very wide textfields ....
how can i leave some space in between the textfields and button...???
    thanx ..subhro
and
subhroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vladi21Commented:
       container.add(textfield1);
        container.add(Box.createRigidArea(new Dimension(0,5)));
        container.add(textfield2);
        container.add(Box.createRigidArea(new Dimension(0,5)));

or specify size for textfields
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
subhroAuthor Commented:
thanx ... actually that is what i did after i had posted the question .. it did work ... but the question still remains why .. createVerticalGlue does not work ....
anyways thanx .... subhro
0
vladi21Commented:
its work when textarea have fixed size
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.