package com.law;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
public class JButtonTest extends JFrame
{
public JButtonTest()
{
setTitle("JButton组件");
Container container=getContentPane();
container.setLayout(new GridLayout(3,2,5,5));
JButton jb1=new JButton("按钮");
jb1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"弹出对话框");
}
});
container.add(jb1);
setBounds(100,100,300,300);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new JButtonTest();
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。