老八秘制小汉堡

先来成品图:

package 老八汉堡;

import java.awt.*;

import javax.swing.*;

public class Window extends JPanel {
    JFrame frame;
    static JButton but[][] = new JButton[2][6];
    private String str[][] = { { "臭豆腐", "俘虏", "老干妈", "美汁汁儿", "底儿", "盖儿" },
            { "扒鸭屁股", "胡萝贝", "粑粑", "白带", "黄瓜丝儿", "柠檬" } };
    static final Image bg = new ImageIcon("images/背景.png").getImage();
    Hamburg hum = new Hamburg();
    /**
     *
     */
    public Window() {
        new Music("D://Java//老八汉堡//music//开场.mp3").start();
        frame = new JFrame("老八秘制小汉堡");
        frame.setSize(1000, 800);
        frame.setLocation(100, 100);
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(this);
        frame.setVisible(true);
        this.setLayout(null);
        Font f = new Font("微软雅黑", Font.BOLD, 30);

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 6; j++) {
                but[i][j] = new JButton(str[i][j]);
                but[i][j].setFont(f);
                but[i][j].setBounds(j * 166, i * 85 + 600, 166, 85);
                this.add(but[i][j]);
                but[i][j].addActionListener(hum);
            }
        }
        hum.setG(getGraphics());

    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        this.setBackground(Color.BLACK);// 背景色
        drawBg(g);
    }

    public static void main(String[] args) {
        new Window();
    }
    public static void drawBg(Graphics g){
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 4; j++)
                g.drawImage(bg, j * 300, i * 200, null);// 老八背景图
        g.setColor(new Color(0, 0, 0, 150));
        g.fillRect(0, 0, 1000, 600);
    }
}
package 老八汉堡;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;

import 老八汉堡.Music;

class Hamburg implements ActionListener {
    Graphics g;
    static final Image cdf = new ImageIcon("images/臭豆腐.png").getImage();
    static final Image fn = new ImageIcon("images/俘虏.png").getImage();
    static final Image lgm = new ImageIcon("images/老干妈.png").getImage();
    static final Image mzz = new ImageIcon("images/美汁汁儿.png").getImage();
    static final Image d = new ImageIcon("images/底儿.png").getImage();
    static final Image ge = new ImageIcon("images/盖儿.png").getImage();
    static final Image bypg = new ImageIcon("images/扒鸭屁股.png").getImage();
    static final Image hlb = new ImageIcon("images/胡萝贝.png").getImage();
    static final Image bb = new ImageIcon("images/粑粑.png").getImage();
    static final Image bd = new ImageIcon("images/白带.png").getImage();
    static final Image hgs = new ImageIcon("images/黄瓜丝.png").getImage();
    static final Image nm = new ImageIcon("images/柠檬.png").getImage();

    int h = 530+d.getHeight(null);
    boolean start=false;

    public Hamburg() {

    }

    public void setG(Graphics g) {
        this.g = g;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == Window.but[0][0]) {
            new Music("D://Java//老八汉堡//music//臭豆腐.mp3").start();
            h = h - cdf.getHeight(null);
            g.drawImage(cdf, 350, h, null);
        } else if (e.getSource() == Window.but[0][1]) {
            new Music("D://Java//老八汉堡//music//俘虏.mp3").start();
            h = h - fn.getHeight(null);
            g.drawImage(fn, 350, h, null);
        } else if (e.getSource() == Window.but[0][2]) {
            new Music("D://Java//老八汉堡//music//老干妈.mp3").start();
            h = h - lgm.getHeight(null);
            g.drawImage(lgm, 350, h, null);
        } else if (e.getSource() == Window.but[0][3]) {
            new Music("D://Java//老八汉堡//music//美汁汁.mp3").start();
            h = h - mzz.getHeight(null);
            g.drawImage(mzz, 350, h, null);
        } else if (e.getSource() == Window.but[0][4]&&start==false) {//底
            new Music("D://Java//老八汉堡//music//小汉堡.mp3").start();
            h = h - d.getHeight(null);
            g.drawImage(d, 350, h, null);
        } else if (e.getSource() == Window.but[0][5]) {
            new Music("D://Java//老八汉堡//music//汉堡行不行.mp3").start();
            h = h - ge.getHeight(null);
            g.drawImage(ge, 350, h, null);
            h = 530+d.getHeight(null);
            try {
                Thread.sleep(6000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
            Window.drawBg(g);
        } else if (e.getSource() == Window.but[1][0]) {
            new Music("D://Java//老八汉堡//music//扒鸭屁股.mp3").start();
            h = h - bypg.getHeight(null);
            g.drawImage(bypg, 350, h, null);
        } else if (e.getSource() == Window.but[1][1]) {
            new Music("D://Java//老八汉堡//music//胡萝卜.mp3").start();
            h = h - hlb.getHeight(null);
            g.drawImage(hlb, 350, h, null);
        } else if (e.getSource() == Window.but[1][2]) {
            new Music("D://Java//老八汉堡//music//粑粑.mp3").start();
            h = h - bb.getHeight(null);
            g.drawImage(bb, 350, h, null);
        } else if (e.getSource() == Window.but[1][3]) {
            new Music("D://Java//老八汉堡//music//白带.mp3").start();
            h = h - bd.getHeight(null);
            g.drawImage(bd, 350, h, null);
        } else if (e.getSource() == Window.but[1][4]) {
            new Music("D://Java//老八汉堡//music//黄瓜丝.mp3").start();
            h = h - hgs.getHeight(null);
            g.drawImage(hgs, 350, h, null);
        } else if (e.getSource() == Window.but[1][5]) {
            new Music("D://Java//老八汉堡//music//柠檬.mp3").start();
            h = h - nm.getHeight(null);
            g.drawImage(nm, 350, h, null);
        }

    }

}
package 老八汉堡;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.*;

class Music extends Thread {
    Player player;
    String music;

    public Music(String file) {
        this.music = file;
    }

    public void run() {
        try {
            play();
        } catch (FileNotFoundException | JavaLayerException e) {
            e.printStackTrace();
        }
    }

    public void play() throws FileNotFoundException, JavaLayerException {
        BufferedInputStream buffer = new BufferedInputStream(
                new FileInputStream(music));
        player = new Player(buffer);
        player.play();
    }

}

原谅我做的时候忍不住笑了..

原文地址:https://www.cnblogs.com/yanzi404/p/12207341.html

时间: 2024-11-05 13:35:00

老八秘制小汉堡的相关文章

秘制牛肉团队博客目录

秘制牛肉团队博客目录 一.Scrum Meeting 1. Alpha 团队第一次 # scrum meeting 团队第二次 # scrum meeting 团队第三次 # scrum meeting 团队第四次 # scrum meeting 团队第五次 # scrum meeting 团队第六次 # scrum meeting 团队第七次 # scrum meeting 团队第八次 # scrum meeting 团队第九次 # scrum meeting 团队第十次 # scrum me

老八系统简易调用AJAX

<script src="js/jquery-1.7.2.min.js"></script> <script> $(function(){ $("#txtaccount").blur(function(){ $.post("check.asp", { name:$(this).val(), type:"tjnickname" }, function(data,status){ if(data

BZOJ2631 tree(伍一鸣) LCT 秘制标记

这个题一看就是裸地LCT嘛,但是我wa了好几遍,这秘制标记...... 注意事项:I.*对+有贡献 II.先下传*再下传+(因为我们已经维护了+,不能再让*对+产生贡献)III.维护+用到size #include<cstdio> #include<cstring> #include<iostream> #define MAXN 100005 #define P 51061 using namespace std; inline unsigned int read()

Android老司机搬砖小技巧

作为一名Android世界的搬运工,每天搬砖已经够苦够累了,走在坑坑洼洼的道路一不小心就掉坑里了. SDK常用工具类 Android SDK中本身就拥有很多轮子,熟悉这些轮子,可以提高我们的搬砖效率. android.text.TextUtils 字符串操作常用方法:isEmpty() ,join(),split()等 if(!TextUtils.isEmpty(text)){ //do something } android.webkit.URLUtil 链接相关常用方法:isHttpUrl(

手把手教你做音乐播放器(八)桌面小工具(上)

第8节 桌面小工具 桌面小工具是可以放置在主界面的.快速控制应用的小助手.例如我们的音乐小工具,它可以帮助用户在桌面上就完成音乐的暂停.播放.切换等操作,而不需要启动应用本身. 在安卓系统中,我们也常常叫它App widget. 实现一个App widget要经过以下几个步骤, 创建一个App widget类,让它继承自AppWidgetProvider,例如AnddleMusicAppWidget类: 放在res\layout目录下,为App widget的界面定义一个布局,例如anddle_

iOS开发时间控件怎么强制24小时制(小技巧)

1)当你的format格式是 NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; // 这里是用大写的 HNSString* dateStr = [dateFormatter stringFromDate:date];你获得就是24小时制的.2)当你的format格式用的是[d

秘制 CSPS 模板

不定期更细中...... 声明1:由于js的问题导致VIEW CODE按钮只能点"I"附近才能展开代码 声明2:为了排版的美观,所有的解释以及需要留意的地方我都放在代码中了 声明3:以下所有代码均是已经AC的,请各位放心食用 STL类 堆 #include<bits/stdc++.h> using namespace std; int n; priority_queue<int,vector<int>,greater<int> >dui;

手把手教你做音乐播放器(八)桌面小工具(下)(完)

8.4 MusicService的改造 8.4.1 App widget触发MusicService 当App widget的按钮被点击后,会触发隐式定义的Intent发送给MusicService.例如当下一首按钮被点击后,携带action-MusicService.ACTION_PLAY_MUSIC_NEXT的Intent将触发MusicService的onStartCommand()函数. 我们可以在onStartCommand()函数当中接收到App widget要求的操作命令,进行相应

型菊挠列老孤秘卵陶

http://www.ebay.com/cln/nbzjhdhnt-txdxhhznp/-/137916587014http://www.ebay.com/cln/vjrbrxnzn-fdhtbtblh/-/138151741011http://www.ebay.com/cln/rbnzlrrtf-jndrdtpjt/-/137849672017http://www.ebay.com/cln/dzbzfnhxz-fpflnbtjv/-/137842963019http://www.ebay.co