java代码播放视频文件 java 播放视频( 五 )


}
}
);*/
infor=new JMenuItem("软件简介");
aboutMenu.add(infor);
infor.addActionListener(this);
about=new JMenuItem("关于作者");
about.addActionListener(this);
aboutMenu.add(about);
//菜单栏设置完毕
panel=new JPanel();
panel.setLayout(new BorderLayout());
c.add(panel,BorderLayout.CENTER);
panelSouth=new JPanel();
panelSouth.setLayout(new BorderLayout());
c.add(panelSouth,BorderLayout.SOUTH);
icon=newImageIcon("icon\\Player.jpg");
label=new JLabel(icon);
panel.add(label);
popupMenu=new JPopupMenu();
del=new JMenuItem("删除");//鼠标右键弹出菜单对象实例化
popupMenu.add(del);
del.addActionListener(this);
delAll=new JMenuItem("全部删除");
popupMenu.add(delAll);
delAll.addActionListener(this);
reName=new JMenuItem("重命名");
popupMenu.add(reName);
reName.addActionListener(this);
scroll=new JScrollPane(list);//用于存放播放列表
listB=new JLabel(new ImageIcon("icon\\qingdan.gif"),SwingConstants.CENTER);
panelSouth.add(listB,BorderLayout.NORTH);
panelSouth.add(scroll,BorderLayout.CENTER);
dialog1=new DialogDemo(MediaPlayer.this,"软件说明");
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);//设定窗口关闭方式
//this.setTitle("d");编译通过,说明可以再次设定标题
this.setLocation(400,250);//设定窗口出现的位置
//this.setSize(350,320);//窗口大小
setSize(350,330);
this.setResizable(false);//设置播放器不能随便调大小
this.setVisible(true);//此句不可少,否则窗口会不显示
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==openItem)//getSource()判断发生时间的组键
{
//System.out.println("d");测试用
openFile();
//createPlayer();
//setTitle(title);
}
if(e.getSource()==openDirItem)//打开目录
{
openDir();
}
if(e.getSource()==closeItem)//推出播放器
{
exity_n();
//System.exit(0);
}
if(e.getSource()==about)
{
JOptionPane.showMessageDialog(this,"此简易播放器由计科0302\n"
+"harly\n"+"完成",
"参与者",
JOptionPane.INFORMATION_MESSAGE);
}
if(e.getSource()==del)
{
//index
//delPaintList(index);
fileName.removeElementAt(indexForDel);
dirName.removeElementAt(indexForDel);
numList.removeAllElements();//从三个容器里面移除此项
Enumeration enumFile=fileName.elements();
while(enumFile.hasMoreElements())
{
numList.addElement((numList.size()+1)+"."+enumFile.nextElement());
//numList添加元素,显示播放里表中
}
//list.setListData(fileName);
list.setListData(numList);
if(indexindexForDel)
list.setSelectedValue(numList.elementAt(index),true);
else
{
if(index==indexForDel);
else
if(index!=0)
list.setSelectedValue(numList.elementAt(index-1),true);
}
//list.setSelectedIndex(index);
}
if(e.getSource()==delAll)//全部删除
{
fileName.removeAllElements();
dirName.removeAllElements();
numList.removeAllElements();
list.setListData(numList);
}
if(e.getSource()==reName)//重命名
{
String name;//=JOptionPane.showInputDialog(this,"请输入新的名字");
try
{
name=reNames();
fileName.setElementAt(name,indexForDel);
numList.setElementAt((indexForDel+1)+"."+name,indexForDel);
}
catch(ReName e2)//自定义的异常
{
}
}
if(e.getSource()==infor)
{
dialog1.setVisible(true);
}
}
public static void main(String[] args)
{
final MediaPlayer mp=new MediaPlayer();

推荐阅读