Java学习者论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java学习者论坛(https://www.javaxxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JAVA高级面试进阶视频教程Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程

Go语言视频零基础入门到精通

Java架构师3期(课件+源码)

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程 MySQL入门到精通教程
查看: 232|回复: 0

[Swing学习]浮动按扭

[复制链接]
  • TA的每日心情
    开心
    2021-3-12 23:18
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 2014-11-2 23:55:42 | 显示全部楼层 |阅读模式
    1. import java.awt.*;
    2. import java.awt.event.*;
    3. public class RemoveButton {
    4.   public static void main(String[] args) {
    5.     MyFrame frame = new MyFrame();
    6.     frame.setVisible(true);
    7.   }
    8. }
    9. class MyButton extends Button {
    10.     private int frameWidth;
    11.     private int frameHeight;
    12.     public MyButton(String label, int width, int height) {
    13.      super(label);
    14.      this.frameWidth = width;
    15.      this.frameHeight = height;
    16.      this.addMouseListener(new MouseAdapter() {
    17.        public void mouseEntered(MouseEvent e) {
    18.          int x = (int)(Math.random() * (frameWidth - getWidth()));
    19.         int y = (int)(Math.random() * (frameHeight - getHeight() - 30));
    20.         setLocation(x, y + 30); } });
    21.      }
    22.   }
    23.    class MyFrame extends Frame {
    24.      public MyFrame() {
    25.         this.setSize(500, 500);
    26.          // new qdmmy6.Custom().setCenter(this);
    27.        this.setLayout(new FlowLayout());
    28.        Label label = new Label("免费送你一本JAVA书,你要吗?");
    29.        MyButton submit = new MyButton("确 定", this.getWidth(), this.getHeight());
    30.        Button button = new Button("取 消");
    31.        this.add(label);
    32.        this.add(submit);
    33.        this.add(button);
    34.        button.addActionListener(new ActionListener() {
    35.         public void actionPerformed(ActionEvent evt) {
    36.          System.exit(0); } });
    37.    }
    38. }
    复制代码

      
      
       
      


    源码下载:http://file.javaxxz.com/2014/11/2/235541890.zip
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|Java学习者论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2025-2-25 16:01 , Processed in 0.343043 second(s), 34 queries .

    Powered by Discuz! X3.4

    © 2001-2017 Comsenz Inc.

    快速回复 返回顶部 返回列表