In my program I have added one Label, two RadioButtons, one TextField and submit button to the Panel. My radiobuttons and submit button is not displaying in current window size because i have set their position below in the JFrame window. But the Scrollbars are not appearing in the window. Tell me where I'm Wrong.
Here is my code
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.*;
class SwingForm extends JFrame
{
SwingForm()
{
super();
Container c=getContentPane();
c.setLayout(new BorderLayout());
JPanel p=new JPanel();
p.setLayout(null);
JLabel l=new JLabel("First Name");
l.setBounds(50, 50, 70, 20);
JTextField j=new JTextField();
j.setBounds(150, 50, 70, 20);
JRadioButton j1=new JRadioButton("Male");
j1.setBounds(50, 300, 70, 50);
JRadioButton j2=new JRadioButton("Female");
j2.setBounds(170, 300, 70, 50);
JButton b=new JButton("Submit");
b.setBounds(100, 600, 100, 100);
ButtonGroup bg=new ButtonGroup();
bg.add(j1);
bg.add(j2);
p.add(l);
p.add(j);
p.add(j1);
p.add(j2);
p.add(b);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jp=new JScrollPane(p,v,h);
c.add(jp,BorderLayout.CENTER);
setVisible(true);
setSize(300,300);
}
public static void main(String args[])
{
new SwingForm();
}
}