Hi
I having a problem with thsi code:
import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.ListSelectionModel; public class teste extends JApplet implements ActionListener { private JTextField t1; private JLabel l1, l2, l3, l4; private JPanel p1,p2,p3,p4, p5; private JRadioButton rb1, rb2; private JCheckBox cb1,cb2,cb3; private ButtonGroup grupo; private JTextArea ta1; private JButton bt1, bt2; public void init() { setLayout(new GridLayout(5,2)); //1º linha p1 = new JPanel(); p1.setLayout(new GridLayout(1,2)); l1 = new JLabel("Nome"); t1 = new JTextField(10); p1.add(l1); p1.add(t1); //2ª linha p2 = new JPanel(); p2.setLayout(new GridLayout(1,2)); l2 = new JLabel("Género"); rb1 = new JRadioButton("Maculino"); rb1.addActionListener(this); rb2 = new JRadioButton("Feminino"); rb2.addActionListener(this); p2.add(l2); p2.add(rb1); p2.add(rb2); ButtonGroup grupo=new ButtonGroup(); grupo.add(rb1); grupo.add(rb2); //3ª linha p3 = new JPanel(); p3.setLayout(new GridLayout(1,2)); l3 = new JLabel("Passatempos"); cb1 = new JCheckBox("Ler"); cb2 = new JCheckBox("Jogar"); cb3 = new JCheckBox("Viajar"); p3.add(l3); p3.add(cb1); p3.add(cb2); p3.add(cb3); //4ª Linha p4 = new JPanel(); p4.setLayout(new GridLayout(1,2)); l4 = new JLabel("Morada"); ta1 = new JTextArea(5,20); p4.add(l4); p4.add(ta1); //5ª linha p5 = new JPanel(); p5.setLayout(new GridLayout(1,2)); bt1 = new JButton("Limpar"); bt1.addActionListener(this); bt2 = new JButton("Ver +"); bt2.addActionListener(this); p5.add(bt1); p5.add(bt2); //Componentes na applet add(p1); add(p2); add(p3); add(p4); add(p5); } @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub } }
I want to have 5 rows and 2 columns and each cell has one component.
any help to resolve this issue?
regards