简单按钮

yuanfengo 2008-03-13 05:53:20
那个GG写个简单的按钮程序来看下
...全文
70 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
guofei_gf 2008-04-01
  • 打赏
  • 举报
回复
...?
xunfengkuohai 2008-04-01
  • 打赏
  • 举报
回复
/*
* 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();
}
}
bendanpanpan 2008-04-01
  • 打赏
  • 举报
回复
求购一个哈 按下一个按钮出来一个窗口啊 帮忙
wanglovehuang 2008-04-01
  • 打赏
  • 举报
回复
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();

}
}

呵呵 简单吧,什么都没有!!
zr_dixuexiongying 2008-04-01
  • 打赏
  • 举报
回复
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();
}
}

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧