import javax.swing.JFrame; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Test4 extends JFrame { private JButton btnExit = new JButton("退出"); public Test4() { setTitle("测试按钮"); setSize(400,300); getContentPane().add(btnExit); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); setVisible(true); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); new Test4(); } }
package welcome;import java.awt.Button; import java.awt.Frame; public class Hello extends Frame{ public Hello(){ Button t=new Button(); this.setLayout(null); t.setBounds(12,36,30,20); t.setLabel("按钮"); this.setVisible(true); this.add(t); this.setBounds(100,100,350,200); }
public static void main(String[] args){ new Hello();
} } 呵呵 简单吧,什么都没有!!
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author silence */ import javax.swing.JFrame; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Test4 extends JFrame { private JButton btnExit = new JButton("退出"); public Test4() { setTitle("测试按钮"); setSize(400,300); getContentPane().add(btnExit); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { new Test4(); } }); setVisible(true); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); new Test4(); } }
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Test4 extends JFrame
{
private JButton btnExit = new JButton("退出"); public Test4()
{
setTitle("测试按钮");
setSize(400,300);
getContentPane().add(btnExit);
btnExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
System.exit(0);
}
});
setVisible(true);
} public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
new Test4();
}
}
import java.awt.Frame;
public class Hello extends Frame{
public Hello(){
Button t=new Button();
this.setLayout(null);
t.setBounds(12,36,30,20);
t.setLabel("按钮");
this.setVisible(true);
this.add(t);
this.setBounds(100,100,350,200);
}
public static void main(String[] args){
new Hello();
}
} 呵呵 简单吧,什么都没有!!
* To change this template, choose Tools | Templates
* and open the template in the editor.
*//**
*
* @author silence
*/
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Test4 extends JFrame
{
private JButton btnExit = new JButton("退出"); public Test4()
{
setTitle("测试按钮");
setSize(400,300);
getContentPane().add(btnExit);
btnExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
new Test4();
}
});
setVisible(true);
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
new Test4();
}
}