前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >java写的一个简单的表白器

java写的一个简单的表白器

作者头像
逍遥子大表哥
发布2021-12-17 14:16:41
7650
发布2021-12-17 14:16:41
举报
文章被收录于专栏:kali blog

效果

java代码

代码语言:javascript
复制
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;

public class love extends JFrame {

    /**
     * 
     */
    private static final long serialVersionUID = 5430219520645185275L;
    private JPanel contentPane;
    protected Component frame;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    love frame = new love();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public love() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(null);
        
        JLabel label = new JLabel("小姐姐处对象吗?");
        label.setFont(new Font("幼圆", Font.PLAIN, 18));
        label.setBounds(147, 20, 211, 41);
        contentPane.add(label);
        
        JButton button = new JButton("好的");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                JOptionPane.showMessageDialog(null, "恭喜!成功拿下!", "表白幺~",JOptionPane.PLAIN_MESSAGE);  
            }
        });
        button.setBounds(98, 179, 93, 23);
        contentPane.add(button);
        
        JButton button_1 = new JButton("不行");
        button_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showConfirmDialog(null, "房子写你名", "表白~",JOptionPane.YES_NO_OPTION);
                JOptionPane.showConfirmDialog(null, "我会做饭", "表白~",JOptionPane.YES_NO_OPTION);
                JOptionPane.showConfirmDialog(null, "我会洗衣服", "表白~",JOptionPane.YES_NO_OPTION);
                JOptionPane.showMessageDialog(null, "现在可以成为我女票吗?", "表白幺~",JOptionPane.PLAIN_MESSAGE);
                JOptionPane.showMessageDialog(null, "恭喜!成功拿下!", "表白幺~",JOptionPane.PLAIN_MESSAGE);
                
            }
        });
        button_1.setBounds(251, 179, 93, 23);
        contentPane.add(button_1);
        
        JLabel lblNewLabel = new JLabel("");
        lblNewLabel.setIcon(new ImageIcon("love.png"));
        lblNewLabel.setBounds(157, 57, 114, 98);
        contentPane.add(lblNewLabel);
    }
}

附件下载

表白器.zip

版权属于:逍遥子大表哥

本文链接:https://cloud.tencent.com/developer/article/1920577

按照知识共享署名-非商业性使用 4.0 国际协议进行许可,转载引用文章应遵循相同协议。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 效果
  • java代码
  • 附件下载
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档