Radio button in Java Program
Radio button in Java Program
import java.awt.*;
import javax.swing.*;
class RadioButtonTest
{
public Static void main(String args[])
{
JFrame frame =new JFrame();
Container cp =frame.getContentPane();
JPanel panel =new JPanel();
JLabel lab =new Jlabel("sampleText");
pane.add(lab);
ButtonGroup group =new ButtonGroup();
final JRadioButto small =new JRadioButton("small",false)
group.add(small);
panel.add(small);
final RadioButton big =new JRadioButton("big",true)
group.add(big);
panel.add(big);
ActionListener listener =new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int size=0;
if(small.isSelected())size=12;
if(big.isSelected())size=14;
lab.setFont(newFont("arial";Font.BOLD,size));
}
};
big.addActionListener(listener);
small.addActionListener(listener);
cp.add(panel);
frame.setSize(100,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
0 coment�rios:
Post a Comment