From a5cdfd72ab80965522b6ce4b4ad18bd1a348b6f1 Mon Sep 17 00:00:00 2001 From: yuki Date: Sat, 23 Feb 2008 09:49:03 +0000 Subject: [PATCH] =?utf8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?utf8?q?=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://192.168.11.7/svn/repository/NicoBrowser@25 bdf3b611-c98c-6041-8292-703d9c9adbe7 --- src/nicobrowser/MainWindow.java | 85 ++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 57 deletions(-) diff --git a/src/nicobrowser/MainWindow.java b/src/nicobrowser/MainWindow.java index 477566d..b4c41fe 100644 --- a/src/nicobrowser/MainWindow.java +++ b/src/nicobrowser/MainWindow.java @@ -9,12 +9,12 @@ package nicobrowser; import java.awt.Component; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.List; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JTable; import javax.swing.JTextArea; @@ -30,6 +30,28 @@ import javax.swing.table.TableColumn; */ public class MainWindow extends javax.swing.JFrame { + private void setContents(List contList) { + int rowHeight = -1; + for (NicoContent cont : contList) { + Vector v = new Vector(); + ImageIcon icon = new ImageIcon(); + try { + icon = new ImageIcon(new URL(cont.getImageLink())); + if (rowHeight < 0) { + rowHeight = icon.getIconHeight(); + jTable1.setRowHeight(rowHeight); + } + } catch (MalformedURLException ex) { + Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, "画像未取得" + cont.getTitle()); + } + v.add(icon); + v.add(cont.getTitle()); + v.add(cont.getDescription()); + v.add(cont.getPageLink()); + tableModel.addRow(v); + } + } + private class MyTableModel extends DefaultTableModel { private MyTableModel(String[] COLUMN_NAMES, int i) { @@ -317,25 +339,7 @@ public class MainWindow extends javax.swing.JFrame { return; } List contList = NicoHttpClient.getInstance().loadMyList(no); - int rowHeight = -1; - for (NicoContent cont : contList) { - Vector v = new Vector(); - ImageIcon icon = new ImageIcon(); - try { - icon = new ImageIcon(new URL(cont.getImageLink())); - if (rowHeight < 0) { - rowHeight = icon.getIconHeight(); - } - } catch (MalformedURLException ex) { - Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); - } - v.add(icon); - v.add(cont.getTitle()); - v.add(cont.getDescription()); - v.add(cont.getPageLink()); - tableModel.addRow(v); - } - jTable1.setRowHeight(rowHeight); + setContents(contList); }//GEN-LAST:event_listLoadButtonActionPerformed private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButtonActionPerformed @@ -361,47 +365,14 @@ public class MainWindow extends javax.swing.JFrame { return; } NicoContent cont = NicoHttpClient.getInstance().loadMyMovie(no); - int rowHeight = -1; - Vector v = new Vector(); - ImageIcon icon = new ImageIcon(); - try { - icon = new ImageIcon(new URL(cont.getImageLink())); - if (rowHeight < 0) { - rowHeight = icon.getIconHeight(); - } - } catch (MalformedURLException ex) { - Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); - } - v.add(icon); - v.add(cont.getTitle()); - v.add(cont.getDescription()); - v.add(cont.getPageLink()); - tableModel.addRow(v); - jTable1.setRowHeight(rowHeight); - + List list = new ArrayList(); + list.add(cont); + setContents(list); }//GEN-LAST:event_unitLoadButtonActionPerformed private void loadDailyListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadDailyListButtonActionPerformed List contList = NicoHttpClient.getInstance().loadMyListDaily(); - int rowHeight = -1; - for (NicoContent cont : contList) { - Vector v = new Vector(); - ImageIcon icon = new ImageIcon(); - try { - icon = new ImageIcon(new URL(cont.getImageLink())); - if (rowHeight < 0) { - rowHeight = icon.getIconHeight(); - } - } catch (MalformedURLException ex) { - Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); - } - v.add(icon); - v.add(cont.getTitle()); - v.add(cont.getDescription()); - v.add(cont.getPageLink()); - tableModel.addRow(v); - } - jTable1.setRowHeight(rowHeight); + setContents(contList); }//GEN-LAST:event_loadDailyListButtonActionPerformed -- 2.11.0