⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 websearchdialog.java

📁 java+eclipse做的TTPlayer
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * WebSearchDialog.java * * Created on 2007年12月23日, 下午2:20 */package com.hadeslee.yoyoplayer.lyric;import com.hadeslee.yoyoplayer.playlist.PlayListItem;import com.hadeslee.yoyoplayer.util.Config;import com.hadeslee.yoyoplayer.util.Util;import java.io.File;import java.io.IOException;import java.text.Collator;import java.util.ArrayList;import java.util.List;import java.util.Locale;import java.util.logging.Logger;import javax.swing.JDialog;import javax.swing.JOptionPane;import javax.swing.ListSelectionModel;import javax.swing.table.AbstractTableModel;import javax.swing.table.DefaultTableColumnModel;import javax.swing.table.TableColumn;import javax.swing.table.TableColumnModel;import javax.swing.table.TableModel;import javax.swing.table.TableRowSorter;/** * * @author  Admin */public class WebSearchDialog extends javax.swing.JDialog {    private static Logger log = Logger.getLogger(WebSearchDialog.class.getName());    private PlayListItem item;//用来初始化的播放项    private List<SearchResult> list = new ArrayList<SearchResult>();//搜到的结果列表    private TableRowSorter<TableModel> sorter;    private LyricPanel lp;//显示歌词的面板    /** Creates new form WebSearchDialog */    private WebSearchDialog(JDialog parent, boolean modal) {        super(parent, modal);        initComponents();        initTable();    }    public WebSearchDialog(PlayListItem item, LyricPanel lp) {        this(Config.getConfig().getLrcWindow(), true);        this.item = item;        this.lp = lp;        initOther();        this.setLocationRelativeTo(Config.getConfig().getLrcWindow());    }    private void initTable() {//        list.add(new SearchResult("artist", "titel", null));//        list.add(new SearchResult("满文军", "想你", null));//        list.add(new SearchResult("郑智化", "大国民", null));//        list.add(new SearchResult("刘要", "你的生日", null));        TableColumnModel model = new DefaultTableColumnModel();        TableColumn c1 = new TableColumn(0, 100);        TableColumn c2 = new TableColumn(1, 100);        c1.setHeaderValue(Config.getResource("WebSearchDialog.artist"));        c2.setHeaderValue(Config.getResource("WebSearchDialog.title"));        model.addColumn(c1);        model.addColumn(c2);        MyTableModel tm = new MyTableModel();        sorter = new TableRowSorter<TableModel>(tm);        table.setModel(tm);        table.setColumnModel(model);        table.setRowSorter(sorter);        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);    }    private void initOther() {        artistJT.setText(item.getArtist());        titleJT.setText(item.getTitle());        fileName.setText(item.getFormattedName() + ".lrc");    }    private class MyTableModel extends AbstractTableModel {        public int getRowCount() {            return list.size();        }        public int getColumnCount() {            return 2;        }        public Object getValueAt(int rowIndex, int columnIndex) {            SearchResult result = list.get(rowIndex);            switch (columnIndex) {                case 0:                    return new GBKString(result.getArtist());                case 1:                    return new GBKString(result.getTitle());                default:                    return new GBKString("");            }        }        @Override        public Class<?> getColumnClass(int columnIndex) {            return GBKString.class;        }    }    private class GBKString implements Comparable<GBKString> {        private final String content;        public GBKString(String s) {            if (s == null) {                s = "";            }            this.content = s;        }        public int compareTo(WebSearchDialog.GBKString o) {            return Collator.getInstance(Locale.CHINESE).compare(content, o.content);        }        public String toString() {            return content;        }    }    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jLabel1 = new javax.swing.JLabel();        artistJT = new javax.swing.JTextField();        jLabel2 = new javax.swing.JLabel();        titleJT = new javax.swing.JTextField();        search = new javax.swing.JButton();        info = new javax.swing.JLabel();        jsp = new javax.swing.JScrollPane();        table = new javax.swing.JTable();        save = new javax.swing.JButton();        jButton3 = new javax.swing.JButton();        jLabel4 = new javax.swing.JLabel();        fileName = new javax.swing.JTextField();        connect = new javax.swing.JCheckBox();        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);        setTitle("在线搜索歌词");        setResizable(false);        jLabel1.setText(Config.getResource("WebSearchDialog.artist")); // NOI18N        artistJT.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                artistJTActionPerformed(evt);            }        });        jLabel2.setText(Config.getResource("WebSearchDialog.title")); // NOI18N        titleJT.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                titleJTActionPerformed(evt);            }        });        search.setText(Config.getResource("WebSearchDialog.search")); // NOI18N        search.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                searchActionPerformed(evt);            }        });        info.setText(Config.getResource("WebSearchDialog.selectLyricToDownload")); // NOI18N        table.getTableHeader().setReorderingAllowed(false);        table.addMouseListener(new java.awt.event.MouseAdapter() {            public void mouseClicked(java.awt.event.MouseEvent evt) {                tableMouseClicked(evt);            }            public void mouseReleased(java.awt.event.MouseEvent evt) {                tableMouseReleased(evt);            }        });        jsp.setViewportView(table);        save.setText(Config.getResource("WebSearchDialog.downLoad")); // NOI18N        save.setEnabled(false);        save.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                saveActionPerformed(evt);            }        });        jButton3.setText(Config.getResource("WebSearchDialog.close")); // NOI18N        jButton3.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton3ActionPerformed(evt);            }        });        jLabel4.setText(Config.getResource("WebSearchDialog.saveAs")); // NOI18N        connect.setSelected(true);        connect.setText(Config.getResource("WebSearchDialog.relativeWithFile")); // NOI18N        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addContainerGap()                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jsp, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addGroup(layout.createSequentialGroup()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -