vishalonne 12 Junior Poster in Training

Hello
I am trying to bring label and textfield closer to each other but not getting the right way how to do it, my code is giving output with a big gap between label and textfield & label and passwordfield. I want some help on how can I remove this gap.
Here is the code

public login()
    {
        jPanelC=new JPanel();
        jlabel1=new JLabel("User ID");
        jlabel2=new JLabel("Password");
        jlabel3=new JLabel("Password");
        jid=new JTextField(15);
        jid.setPreferredSize(new Dimension(100, 100));
        jpass=new JPasswordField(15);
        jpass.setPreferredSize(new Dimension(100, 100));
        jbutton1=new JButton("Login");
        jbutton1.setPreferredSize(new Dimension(100, 100));

        jPanelC.setBackground(new java.awt.Color(204, 204, 255));
        jPanelC.setBorder(empty);
        int eb=5;
        jPanelC.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createEmptyBorder(eb, eb, eb, eb), // outer border
        BorderFactory.createLoweredBevelBorder()));      // inner border
        jPanelC.setSize(300, 150);

        jPanelC.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();

        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx = 0;
        c.gridy = 0;
        jPanelC.add(jlabel1,c);

        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx =1;
        c.gridy = 0;
        c.weightx=2;
        jPanelC.add(jid,c);

        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx = 0;
        c.gridy = 1;
        jPanelC.add(jlabel2,c);

        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx = 1;
        c.gridy = 1;
        jPanelC.add(jpass,c);

        c.fill = GridBagConstraints.HORIZONTAL; 
        c.gridx = 0;
        c.gridy = 2;      
        c.gridheight=1;
        c.gridwidth = 3;

       jPanelC.add(jbutton1,c);

        jPanelE=new JPanel();
        jPanelW=new JPanel();
        jPanelN=new JPanel();
        jPanelS=new JPanel();
        add(jPanelE,BorderLayout.EAST);
        add(jPanelW,BorderLayout.WEST);
        add(jPanelN,BorderLayout.NORTH);
        add(jPanelS,BorderLayout.SOUTH);       
        add(jPanelC,BorderLayout.CENTER);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Login Console");
        setBackground(new java.awt.Color(255, 255, 255));
        setSize(400, 300);
        this.setVisible(true);       
    }
    public static void main(String[] args)
    {
        login log=new login();
    }
}

I can't upload the output image because I am not getting File upload button/link here.

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.