Tweet
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code="JRadioButtonDemo"width=300 height=50>
</applet>
*/
public class JRadioButtonDemo extends JApplet implements ActionListener
{
JTextField tf;
public void init()
{
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout());
JRadioButton b1=new JRadioButton("C");
b1.addActionListener(this);
contentPane.add(b1);
JRadioButton b2=new JRadioButton("Java");
b2.addActionListener(this);
contentPane.add(b2);
JRadioButton b3=new JRadioButton("C++");
b3.addActionListener(this);
contentPane.add(b3);
JRadioButton b4=new JRadioButton("HTML");
b4.addActionListener(this);
contentPane.add(b4);
JRadioButton b5=new JRadioButton("PHP");
b5.addActionListener(this);
contentPane.add(b5);
ButtonGroup bg=new ButtonGroup();
bg.add(b1);
bg.add(b2);
bg.add(b3);
bg.add(b4);
bg.add(b5);
tf=new JTextField(5);
contentPane.add(tf);
}
public void actionPerformed(ActionEvent ae)
{
tf.setText(ae.getActionCommand());
}
}
Java Radio Buttons using applet
Posted by
LAHAUL SETH
~
Java Radio Buttons using applet
2012-01-05T11:12:00+05:30
LAHAUL SETH
Java
|
Java Applet
|
Comments
Java Radio Buttons using applet
2012-01-05T11:12:00+05:30
LAHAUL SETH
Java
|
Java Applet
|