import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
public class MainFrame extends JFrame implements ActionListener {
private JButton yes;
private JButton no;
private JButton close;
private int count;
public MainFrame() {
count = 0;
initFrame();
initLabel();
initButton();
}
public void initFrame() {
this.setLocation(500, 200);
this.setSize(300, 200);
this.setLayout(null);
this.setResizable(false);
this.setUndecorated(true);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void initLabel() {
JLabel textLabel = new JLabel("做我女朋友好吗?");
textLabel.setBounds(145, 70, 200, 40);
textLabel.setFont(new Font("宋体", Font.PLAIN, 20));
JLabel imgLabel = new JLabel(new ImageIcon("res/1.jpg"));
imgLabel.setBounds(0, 30, 130, 101);
this.add(textLabel);
this.add(imgLabel);
}
private void initButton() {
yes = new JButton("愿意");
no = new JButton("不愿意");
close = new JButton(new ImageIcon("res/close.png"));
//去除按钮背景
close.setContentAreaFilled(false);
//去除按钮边框
//close.setBorderPainted(false);
yes.setBounds(0, 160, 80, 40);
this.add(yes);
yes.addActionListener(this);
no.setBounds(220, 160, 80, 40);
this.add(no);
no.addActionListener(this);
close.setBounds(284, 0, 16, 16);
this.add(close);
close.addActionListener(this);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
if (obj == yes) {
JOptionPane.showMessageDialog(null, "好耶!!!!");
new SucceedFrame();
this.dispose();
} else if (obj == no) {
Random random = new Random();
this.setLocation(random.nextInt(0, 1200), random.nextInt(0, 600));
count++;
if (count > 5) {
JOptionPane.showMessageDialog(null, "不要挣扎了");
new Hahaha();
}
} else if (obj == close) {
JOptionPane.showMessageDialog(null, "关不掉哦的");
new CloseFrame();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
表白小工具,成功率百分百
共63个文件
sample:13个
class:5个
java:5个
需积分: 0 0 下载量 71 浏览量
2024-01-31
20:03:32
上传
评论
收藏 718KB ZIP 举报
温馨提示
用Java编写的GUI表白工具,表白我就用它
资源推荐
资源详情
资源评论
收起资源包目录
wouldYouLikeToBe.zip (63个子文件)
wouldYouLikeToBe
src
Hahaha.java 523B
MainFrame.java 2KB
Main.java 104B
CloseFrame.java 532B
SucceedFrame.java 538B
wouldYouLikeToBe.iml 433B
out
production
wouldYouLikeToBe
Hahaha.class 941B
SucceedFrame.class 962B
Main.class 387B
CloseFrame.class 953B
MainFrame.class 3KB
.git
index 2KB
HEAD 23B
refs
heads
master 41B
tags
remotes
origin
master 41B
COMMIT_EDITMSG 5B
objects
a1
a4b0d447c3502f243fdb0ef9859578f4667e4e 53B
56
b45788bc1445e7e18484dc49112ed616a21c13 177B
59
af21e0cb78a6659b2086b01d2e4e7081a7fecf 178B
94
57630c02bc2c46c54d3e11000f32eb6efbc490 30KB
07
bd6db8ec51cf71c4bd79f5b5c1cf591db42116 58B
a17260be34a637d539c8336de341e112f0fee4 283B
fc
416cca5e73583d006729928b9a5000172dc72d 278B
66
2954869c6e8e2aefbb0a0668ad4e40100abcf3 150B
86
d4f65d849b6e93d47f2c5fbf286aff23e0e626 119B
2a
3acf51040bb3eb64f31f366c926121adae18e1 284KB
eb
376f9b969875096d9ad4246a7dee8a8baacb5b 997B
3d
3c6c7db31f63c93a10bfe32845362b4933dd1b 256B
c9
0834f2d607afe55e6104d8aa2cdfffb713f688 263B
aa
b3aba74a867c67f89f32a559d9d6c6cf5738c2 284B
pack
87
4e3dcc2109f3be86139256b58f30b6f0d802fe 93B
af
3f5f110c855b8e8ecd2fbdac0d0c9500f7f1d5 17KB
b4
bf67284726ee159eca79e4e8e6b0e473e4b52b 613B
39
474f1958d11b19cfa347bca1412afca321f327 2KB
info
4e
13e06a8028945be65adf757e79e4c2cd22b2c8 8KB
92
fe791923451bad985ba52ff96660698aec73ae 164B
47
658513f36d978c3fae7c4ddb951d04966ed25f 595B
7a
31f4292c17d85b81b2287b26345c9dad677aa8 593B
b3
e6c88cb277851141800f35649d68122490c779 291B
description 73B
info
exclude 240B
logs
HEAD 148B
refs
heads
master 148B
remotes
origin
master 140B
hooks
post-update.sample 189B
prepare-commit-msg.sample 1KB
commit-msg.sample 896B
pre-receive.sample 544B
update.sample 4KB
pre-commit.sample 2KB
pre-rebase.sample 5KB
applypatch-msg.sample 478B
fsmonitor-watchman.sample 5KB
push-to-checkout.sample 3KB
pre-applypatch.sample 424B
pre-push.sample 1KB
pre-merge-commit.sample 416B
config 299B
res
2.jpg 8KB
1.jpg 17KB
close.png 239B
3.gif 63KB
4.gif 292KB
共 63 条
- 1
资源评论
愈辩已忘言
- 粉丝: 53
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功