📄 websearchdialog.java
字号:
.addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(artistJT, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(titleJT, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(search, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(info) .addGroup(layout.createSequentialGroup() .addComponent(connect) .addGap(87, 87, 87) .addComponent(save) .addGap(18, 18, 18) .addComponent(jButton3)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(fileName, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(artistJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(titleJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(search)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(info) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jsp, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(fileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(save) .addComponent(jButton3) .addComponent(connect)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: this.dispose(); }//GEN-LAST:event_jButton3ActionPerformed private void searchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchActionPerformed // TODO add your handling code here: doSearch();}//GEN-LAST:event_searchActionPerformed private void tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseClicked // TODO add your handling code here: if (evt.getClickCount() == 2) { doSave(); } }//GEN-LAST:event_tableMouseClicked private void saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveActionPerformed // TODO add your handling code here: doSave(); }//GEN-LAST:event_saveActionPerformed private void tableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseReleased // TODO add your handling code here: int index = table.getSelectedRow(); if (index != -1) { index = sorter.convertRowIndexToModel(index); SearchResult result = list.get(index); fileName.setText(result.getArtist() + " - " + result.getTitle() + ".lrc"); } }//GEN-LAST:event_tableMouseReleased private void titleJTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_titleJTActionPerformed // TODO add your handling code here: doSearch(); }//GEN-LAST:event_titleJTActionPerformed private void artistJTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_artistJTActionPerformed // TODO add your handling code here: doSearch(); }//GEN-LAST:event_artistJTActionPerformed private void doSave() { info.setText(Config.getResource("WebSearchDialog.downloading")); new Thread() { public void run() { doSave0(); } }.start(); } private void doSave0() { int index = table.getSelectedRow(); String path = fileName.getText(); if (path == null || path.trim().equals("")) { JOptionPane.showMessageDialog(this, Config.getResource("WebSearchDialog.fileNamenotEmpty")); return; } if (index != -1) { try { File file = new File(Config.HOME, "Lyrics/" + path); if (file.isFile() && file.exists()&&!Config.getConfig().isAutoOverWriteExistFile()) { int i = JOptionPane.showConfirmDialog(this, Config.getResource("WebSearchDialog.existingFile") + file.getPath() + "\n" + Config.getResource("WebSearchDialog.confirmOverwrite"), Config.getResource("WebSearchDialog.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (i != JOptionPane.YES_OPTION) { return; } }// save.setEnabled(false);// table.setEnabled(false); index = sorter.convertRowIndexToModel(index); SearchResult result = list.get(index); result.save(path); info.setText(Config.getResource("WebSearchDialog.downloadSuccess")+file.getPath()); Lyric lyric = new Lyric(result.getContent(), item); File temp = item.getLyricFile(); lp.setLyric(lyric); lp.getPlayer().setLyric(lyric); if (connect.isSelected()) { item.setLyricFile(file); } else { item.setLyricFile(temp); } } catch (IOException ex) { info.setText(Config.getResource("WebSearchDialog.saveLyricFailure") + path); save.setEnabled(true); table.setEnabled(true); } } else { JOptionPane.showMessageDialog(this, Config.getResource("WebSearchDialog.selectLyricToDownload")); } } private void doSearch() { search.setEnabled(false); table.setEnabled(false); save.setEnabled(false); artistJT.setEnabled(false); titleJT.setEnabled(false); info.setText(Config.getResource("WebSearchDialog.searching")); new Thread() { public void run() { doSearch0(); } }.start(); } private void doSearch0() { String artist = artistJT.getText(); String title = titleJT.getText(); if (artist == null) { artist = ""; } if (title == null) { title = ""; } list.clear(); list.addAll(Util.getSearchResults(artist, title)); table.revalidate(); sorter.allRowsChanged(); if (list.size() > 0) { table.setEnabled(true); save.setEnabled(true); } search.setEnabled(true); artistJT.setEnabled(true); titleJT.setEnabled(true); info.setText(Config.getResource("WebSearchDialog.selectLyricToDownload")); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { WebSearchDialog dialog = new WebSearchDialog(new javax.swing.JDialog(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField artistJT; private javax.swing.JCheckBox connect; private javax.swing.JTextField fileName; private javax.swing.JLabel info; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; private javax.swing.JScrollPane jsp; private javax.swing.JButton save; private javax.swing.JButton search; private javax.swing.JTable table; private javax.swing.JTextField titleJT; // End of variables declaration//GEN-END:variables}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -