import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.sound.midi.*;
import java.io.File;
class Meplay implements Runnable
{
private Thread runner;
private Sequence currentSound;
private Sequencer player;
private String[] songFile;
private int songToPlay;
public Meplay(String[] songs)
{
super();
songFile=songs;
}
public void play()
{
if(runner==null)
{ runner=new Thread(this);
runner.start();
}
}
public void stop()
{
if(runner!=null)
{ runner=null;}
}
public void run()
{
try{
player=MidiSystem.getSequencer();
}
catch(Exception e)
{ }
while(Thread.currentThread()==runner)
{
for(songToPlay=0;songToPlay<songFile.length;songToPlay++)
{ if(songFile[songToPlay]!=null)
{ try{
File song=new File(songFile[songToPlay]);
currentSound=MidiSystem.getSequence(song);
player.open();
player.setSequence(currentSound);
player.start();
while(player.isRunning()&&runner!=null)
{
try{
Thread.sleep(1000);
}
catch(InterruptedException e){}
}
player.close();
}
catch(Exception e)
{ break;
}
}
}
}
}
}
class SelectWindow extends Frame implements ActionListener
{
Meplay meplay;
private String[] midfile={"xlj.mid","xulijun.mid"};
Kaishi kaishi;
PersonSelected personSelected[];
InputPerson input;
SelectedPane select;
ResultArea show;
Button buttonInput,buttonSelect,buttonResult,reNew;
MenuBar menuBar;
Menu menu,meun1;
MenuItem item1,item2,item3,item4;
int max=5;
CardLayout card;
Panel center=new Panel(),
south=new Panel();
FileDialog filedialogsave;
SelectWindow()
{
meplay=new Meplay(midfile);
personSelected=new PersonSelected[1];
for(int k=0;k<personSelected.length;k++)
{ personSelected[k]=new PersonSelected("无名",0);
}
card=new CardLayout();
center.setLayout(card);
kaishi=new Kaishi();
input=new InputPerson(personSelected);
select=new SelectedPane(personSelected,max);
show=new ResultArea(personSelected);
menuBar=new MenuBar();
menu=new Menu("程序介绍");
meun1=new Menu("歌曲播放");
item3=new MenuItem("播放");
item4=new MenuItem("停止");
item1=new MenuItem("打开");
item2=new MenuItem("保存");
menuBar.add(menu);
menuBar.add(meun1);
menu.add(item1);
item1.addActionListener(this);
meun1.add(item3);
item3.addActionListener(this);
meun1.add(item4);
item4.addActionListener(this);
menu.add(item2);
setMenuBar(menuBar);
center.add("kaishi",kaishi);
center.add("input",input);
center.add("select",select);
center.add("show",show);
buttonInput=new Button("输入候选人界面");
buttonInput.addActionListener(this);
buttonSelect=new Button("统计选票界面,最多选"+max+"人");
buttonSelect.addActionListener(this);
buttonResult=new Button("查看得票界面");
buttonResult.addActionListener(this);
reNew=new Button("重新选举");
reNew.addActionListener(this);
south.add(buttonInput);
south.add(buttonResult);
south.add(buttonSelect);
south.add(reNew);
add(center,BorderLayout.CENTER);
add(south,BorderLayout.SOUTH);
filedialogsave=new FileDialog(this,"保存文件对话框",FileDialog.LOAD);
setSize(800,700);
setVisible(true);
setBackground(Color.pink);
validate();
}
public void actionPerformed(ActionEvent e)
{ if(e.getSource()==item1) { filedialogsave.setVisible(true);}
if(e.getSource()==item3) {meplay.play();}
if(e.getSource()==item4) {meplay.stop();}
Button b=(Button)e.getSource();
setTitle(b.getLabel());
if(b==buttonInput)
{ card.show(center,"input");
buttonInput.setEnabled(false);
}
if(b==buttonSelect)
{ personSelected=input.getPersonSelected();
select.setPersonSelected(personSelected);
select.init();
card.show(center,"select");
}
if(b==buttonResult)
{ personSelected=select.getPersonSelected();
show.setPersonSelected(personSelected);
card.show(center,"show");
}
if(b==reNew)
{ personSelected=new PersonSelected[1];
for(int k=0;k<personSelected.length;k++)
{ personSelected[k]=new PersonSelected("无名",0);
}
center.removeAll();
input=new InputPerson(personSelected);
select=new SelectedPane(personSelected,3);
show=new ResultArea(personSelected);
center.add("kaishi",kaishi);
center.add("input",input);
center.add("select",select);
center.add("show",show);
card.show(center,"kaishi");
buttonInput.setEnabled(true);
center.validate();
}
}
}
public class Example7_40
{ public static void main(String args[])
{ String output;
SelectWindow win=new SelectWindow();
win.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) { System.exit(0); }
});
output="谢谢光顾\n本人水平欠缺欢迎多多指教\n";
JOptionPane.showMessageDialog(null,output);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
xuanju.zip_java投票_xuanju_投票
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共38个文件
class:18个
mid:6个
java:6个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 95 浏览量
2022-09-24
01:50:43
上传
评论
收藏 15.13MB ZIP 举报
温馨提示
用Java编写的投票系统。主要是输入候选人,投票,统计票数,重新投票等部分
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 38 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/d600a32f29294db1a3be82ec9708491a_weixin_42651887.jpg!1)
weixin_42651887
- 粉丝: 81
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)