怎么把音乐放入java_怎么添加音乐文件的播放。

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

import java.awt.event.*;

import javax.swing.*;

import java.awt.FlowLayout;

public class eggtimer implements ActionListener

{

private JLabel ta;

private Timer t = new Timer(1000, this);

private JTextField min = new JTextField("8", 3);

private JTextField sec = new JTextField("10", 3);

private JLabel minute = new JLabel("分");

private JLabel second = new JLabel("秒");

private int i = Integer.parseInt(min.getText()) * 60

+ Integer.parseInt(sec.getText());

public eggtimer()

{

JFrame et = new JFrame("EggTimer");

JLabel tips=new JLabel("科学研究表示煮鸡蛋最佳时间为8分钟");

JLabel prompt = new JLabel("所以:点击开始后请在十秒内将生鸡蛋放入沸水中");

et.setLayout(new FlowLayout());

ta = new JLabel("\n");

et.add(tips);

et.add(prompt);

et.add(min);

et.add(minute);

et.add(sec);

et.add(second);

et.add(ta);

min.addActionListener(this);

sec.addActionListener(this);

JButton b1 = new JButton("开始");

et.add(b1);

b1.addActionListener(this);

JButton b2 = new JButton("退出");

et.add(b2);

b2.addActionListener(this);

et.setSize(320, 150);

et.setLocation(320, 150);

et.setVisible(true);

et.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args)

{

new eggtimer();

}

public void actionPerformed(ActionEvent e)

{

String co = e.getActionCommand();

if ("开始".equals(co))

{

i = Integer.parseInt(min.getText()) * 60

+ Integer.parseInt(sec.getText());

t.start();

}

else if ("退出".equals(co))

{

System.exit(1);

}

else

{

if(i%60>=10)

{

String temp ="0"+i % 3600 / 60 + ":" + i % 60;

i--;

ta.setText(temp);

}

else

{

if(i % 3600 / 60==0&i % 60==0)

{

!#!#@@¥##¥……%@¥……¥%&……%……&*&*&(

}

else

{

String temp="0"+i % 3600 / 60 + ":" + "0"+i % 60;

i--;

ta.setText(temp);

}

}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值