import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FrameDemo1
{
public static void main(String args[])
{
JFrame frame=new JFrame("My frame");
Container c=frame.getContentPane();
c.setLayout(new FlowLayout());
JLabel lb=new JLabel("FrameDemo");
JTextField tf=new JTextField("我是菜鸟 但我要飞!!!");
JButton bt1=new JButton("Botton1");
JButton bt2=new JButton("Botton2");
JButton jButton1=new JButton("Botton11");
jButton1.setBackground(Color.pink);
jButton1.setBorder(BorderFactory.createRaisedBevelBorder());
jButton1.setToolTipText("click me");
jButton1.setText("I have been changde ");
c.add(lb);
c.add(tf);
c.add(bt1);
c.add(bt2);
frame.setSize(400,100);
frame.show();
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
}
评论