import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class SwingClass
{
JLabel Result;
SwingClass()
{
JFrame jfrm=new JFrame("Swing Example ");
jfrm.setLayout(new FlowLayout());
jfrm.setSize(220,90);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton ClickMe=new JButton("Click Me ");
ClickMe.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
Result.setText(" Welcome to Swing ");
}
});
Result=new JLabel("Press the Button",JLabel.CENTER);
jfrm.add(ClickMe);
jfrm.add(Result);
jfrm.setVisible(true);
}
public static void main(String args[])
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new SwingClass();
}
});
}
}
No comments:
Post a Comment