Home » » Border test in Java Program

Border test in Java Program

Border test in Java Program

Border test in Java Program

Border test in Java Program


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class BorderTest
{
public Static void main(String args[])
{
BorderFrame frame =new BorderFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fram.show();
}
}
class BorderFrame extends JFrame
{
public BorderFrame()
{
setTitle("BorderTest");
setSize(600,200);
demoPanel =new JPanel();
buttonPanel =new JPanel();
group =new ButtonGroup();
addRadioButton("lower level",BorderFactory.createLowerBevelBorder());
addRadioButton("Raised bevel",BorderFactory.createRaiseBevelBorder());
addRadioButton("Etched",BorderFactory.createEtchedBorder());
addRadioButton("Etched",BorderFactory.createLineBorder(color.BLUE));
add.RadioButton("Matte",BorderFactory.createMatteBorder(10,10,10,10,color.BLUE));
add.RadioButton("Empty",BorderFactory.createEmptyBorder());
Border etched=BorderFactory.createEtchedBorder();
Border titled=BorderFactory.createTitledBorder(etched,"Border types");
buttonPanel.setBorder(titled);
Container contentPane=getContentPane();
contentPane.setLayout(new GridLayout());
contentPane.add(buttonPanel);
contentPane.add(demoPanel);
}
public void addRadioButton(String button Name,final Border b)
{
JRadioButton button=new JRadioButton(buttonName);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
demoPanel.setBorder(b);
validate();
}
});
group.add(button);
buttonPanel.add(button);
}
privateJPanel demoPanel;
private JPanel buttonPanel;

private ButtonGroup group;

0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g