package 娱乐.百度排行;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Vector;
import javax.swing.*;
public class Test extends JFrame {
URL url;
private JEditorPane area;
InputStream in;
String gequ[] = new String[40];
int aa = 0;
private BufferedReader reader;
private String string = "";
public JList jl1, jl2, jl3, jl4, jl5, jl6;
Vector quanbu, xinge, geshou, jinqu, dz, wav;
String yy;
String music1, music2;
JTextField sousou;
String didi;
String mimi;
JLabel jlb;
JButton jb = new JButton("播放");
JButton xiazai = new JButton("下载");
JButton sous = new JButton("搜索");
JButton tance = new JButton("探测");
String zhuanyong;
JTextField baocunlujin = new JTextField();;
public Test() {
Container c = getContentPane();
c.setLayout(new GridLayout(2, 1));
JPanel jp = new JPanel();
JPanel jpp = new JPanel();
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JPanel jp3 = new JPanel();
JPanel jp4 = new JPanel();
JPanel jp5 = new JPanel();
JPanel jp6 = new JPanel();
area = new JEditorPane();
jp.setLayout(new GridLayout(1, 4));
quanbu = new Vector();
xinge = new Vector();
geshou = new Vector();
jinqu = new Vector();
dz = new Vector();
wav = new Vector();
dudu();
jl1 = new JList(quanbu);
jl1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JLabel jb1 = new JLabel("歌曲TOP10");
jp1.setLayout(new BorderLayout());
jp1.add(jb1, BorderLayout.NORTH);
jp1.add(new JScrollPane(jl1), BorderLayout.CENTER);
jl2 = new JList(xinge);
jl2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JLabel jb2 = new JLabel("新歌TOP10");
jp2.setLayout(new BorderLayout());
jp2.add(jb2, BorderLayout.NORTH);
jp2.add(new JScrollPane(jl2), BorderLayout.CENTER);
jl3 = new JList(geshou);
jl3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JLabel jb3 = new JLabel("中文金曲榜");
jp3.setLayout(new BorderLayout());
jp3.add(jb3, BorderLayout.NORTH);
jp3.add(new JScrollPane(jl3), BorderLayout.CENTER);
jl4 = new JList(jinqu);
jl4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JLabel jb4 = new JLabel("经典老歌");
jp4.setLayout(new BorderLayout());
jp4.add(jb4, BorderLayout.NORTH);
jp4.add(new JScrollPane(jl4), BorderLayout.CENTER);
jp.add(jp1);
jp.add(jp2);
jp.add(jp3);
jp.add(jp4);
c.add(jp);
jpp.setLayout(new BorderLayout());
jl5 = new JList();
jl5.setFixedCellWidth(550);
// jl5.setFixedCellHeight(16);
jl5.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jl6 = new JList();
jl6.setFixedCellWidth(550);
jl6.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JLabel jb5 = new JLabel("试听地址");
JLabel jb6 = new JLabel("下载地址");
JPanel jp7 = new JPanel();
jp7.setLayout(new GridLayout(2, 1));
jp5.add(jb5, BorderLayout.NORTH);
jp5.add(new JScrollPane(jl5));
jp6.add(jb6, BorderLayout.NORTH);
jp6.add(new JScrollPane(jl6));
jp7.add(jp5);
jp7.add(jp6);
jpp.add(jp7, BorderLayout.CENTER);
JPanel jp8 = new JPanel();
jp8.setLayout(new GridLayout(3, 1));
JPanel jp1_1 = new JPanel();
JPanel jp1_2 = new JPanel();
JPanel jp1_3 = new JPanel();
jp1_3.setLayout(new BorderLayout());
sousou = new JTextField(10);
jp1_1.add(jb);
jp1_2.add(xiazai);
jp1_2.add(tance);
jp1_3.add(sousou, BorderLayout.CENTER);
jp1_3.add(sous, BorderLayout.SOUTH);
jp8.add(jp1_3);
jp8.add(jp1_1);
jp8.add(jp1_2);
jpp.add(jp8, BorderLayout.EAST);
c.add(jpp);
jl1.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.getClickCount() == 2) {
if (jl1.getSelectedIndex() >= 0) {
yy = (String) quanbu.get(jl1.getSelectedIndex());
String dizhi = "http://mp3.gougou.com/search?search="
+ yy;
dengdeng(dizhi);
}
}
}
});
jl2.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.getClickCount() == 2) {
if (jl2.getSelectedIndex() >= 0) {
yy = (String) xinge.get(jl2.getSelectedIndex());
String dizhi = "http://mp3.gougou.com/search?search="
+ yy;
dengdeng(dizhi);
}
}
}
});
jl3.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.getClickCount() == 2) {
if (jl3.getSelectedIndex() >= 0) {
yy = (String) geshou.get(jl3.getSelectedIndex());
String dizhi = "http://mp3.gougou.com/search?search="
+ yy;
dengdeng(dizhi);
}
}
}
});
jl4.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.getClickCount() == 2) {
if (jl4.getSelectedIndex() >= 0) {
yy = (String) jinqu.get(jl4.getSelectedIndex());
String dizhi = "http://mp3.gougou.com/search?search="
+ yy;
dengdeng(dizhi);
}
}
}
});
jl5.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.getClickCount() == 2) {
if (jl5.getSelectedIndex() >= 0) {
yy = ((String) dz.get(jl5.getSelectedIndex())).replace(
" ", "%20");
mp3(yy);
Runtime ss = Runtime.getRuntime();
try {
Process p = ss.exec("cmd /c start iexplore.exe "
+ yy);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
});
jl6.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.isMetaDown()) {
if (jl6.getSelectedIndex() >= 0) {
yy = ((String) wav.get(jl6.getSelectedIndex()))
.replace(" ", "%20");
writeToSysClipboard(yy);
}
}
if (event.getClickCount() == 2) {
if (jl6.getSelectedIndex() >= 0) {
yy = ((String) wav.get(jl6.getSelectedIndex()))
.replace(" ", "%20");
Runtime ss = Runtime.getRuntime();
try {
Process p = ss.exec("cmd /c start iexplore.exe "
+ yy);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
});
jb.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (jl5.getSelectedIndex() >= 0) {
yy = ((String) dz.get(jl5.getSelectedIndex())).replace(" ",
"%20");
Runtime ss = Runtime.getRuntime();
try {
Process p = ss.exec("cmd.exe /c start "
+ "iexplore.exe " + yy);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
});
sous.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
String dizhi = "http://mp3.gougou.com/search?search="
+ sousou.getText();
sousou.setText("");
qudizhi(dizhi);
mp3(didi);
}
});
sousou.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String dizhi = "http://mp3.gougou.com/search?search="
+ sousou.getText();
sousou.setText("");
qudizhi(dizhi);
mp3(didi);
}
});
xiazai.addMouseListener(new MouseAdapter() {