import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JOptionPane; class 程序员撩妹对话框 extends JFrame { private final JButton yes; private final JButton no; private final JLabel textLabel1; private final JLabel textLabel2; private final JLabel imageLabel; Icon img = new ImageIcon("C:\\Users\\Jack Hwo\\Desktop\\0.png"); Icon emoji1 = new ImageIcon("C:\Users\Jack Hwo\Desktop\1.jpg"); Icon emoji2 = new ImageIcon("C:\Users\Jack Hwo\Desktop\2.jpg"); Icon emoji3 = new ImageIcon("C:\Users\Jack Hwo\Desktop\3.jpg"); public 程序员撩妹对话框() { super("来自对面的小哥哥"); setLayout(new FlowLayout()); textLabel1 = new JLabel("小姐姐我观察你很久了"); textLabel1.setFont(new Font("宋体", 22, 23)); add(textLabel1); textLabel2 = new JLabel("做我女朋友好不好?"); textLabel2.setFont(new Font("楷体", 33, 40)); add(textLabel2); imageLabel = new JLabel(img); imageLabel.setLocation(123, 124); add(imageLabel); yes = new JButton("好"); add(yes); no = new JButton("不好"); add(no); ButtonHandler1 handler1 = new ButtonHandler1(); yes.addActionListener(handler1); ButtonHandler2 handler2 = new ButtonHandler2(); no.addActionListener(handler2); } private class ButtonHandler1 implements ActionListener { @Override public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog(程序员撩妹对话框.this, String.format("目标拿下哈哈")); } } private class ButtonHandler2 implements ActionListener { private int flag = 0; @Override public void actionPerformed(ActionEvent event) { flag++; if (flag == 1) { JOptionPane.showMessageDialog(程序员撩妹对话框.this, String.format("房产证上写你名"), "做我女朋友好不好", JOptionPane.INFORMATION_MESSAGE, emoji1); flag++; } if (flag == 3) { JOptionPane.showMessageDialog(程序员撩妹对话框.this, String.format("保大"), "做我女朋友好不好", JOptionPane.INFORMATION_MESSAGE, emoji2); flag++; } if (flag == 5) { JOptionPane.showMessageDialog(程序员撩妹对话框.this, String.format("我妈会游泳"), "做我女朋友好不好", JOptionPane.INFORMATION_MESSAGE, emoji3); flag=0; } } } } public class TestDemo { public static void main(String[] args) { 程序员撩妹对话框 buttonFrame = new 程序员撩妹对话框(); buttonFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); buttonFrame.setResizable(false); buttonFrame.setFocusable(false); buttonFrame.setAlwaysOnTop(true); buttonFrame.setSize(600, 400); buttonFrame.setVisible(true); buttonFrame.setLocationRelativeTo(null); } }
附图:
网传"程序员撩妹"程序--Java实现
苟利国家生死以, 岂因祸福避趋之