あーあ、俺も電脳ペット飼いてぇなぁ!!
みんなー!クライアントづくりが始まるよー!クライアントづくりを読むときは、なるべく現実から離れて明るい気持ちで読んでねー!!
仏の逢うたら仏を殺さナイト。どうものろくです。
とりあえずpublictimelineを取得して表示してみるでござるの巻。上のに追加な。
import java.net.URL; import java.net.MalformedURLException; class CommentListPanel extends JPanel{ /** * 発言の並んだJPanelを作るクラス */ protected Twitter ptwitter; protected java.util.List<OneComment> comlist = new LinkedList<OneComment>(); protected JPanel timelinepanel = new JPanel(); CommentListPanel(Twitter twitter){ OneComment com; ptwitter = twitter; java.util.List<Status> statuses = new LinkedList<Status>(); // Timeline取得 try{ statuses = this.ptwitter.getPublicTimeline(); }catch(Exception ex){ ex.printStackTrace(); } for (Status status : statuses) { comlist.add(new OneComment(status)); } timelinepanel.setLayout(new BoxLayout(timelinepanel, BoxLayout.PAGE_AXIS)); for (OneComment comment : comlist) { timelinepanel.add(comment); } JScrollPane sp = new JScrollPane(); sp.getViewport().setView(timelinepanel); this.add(sp); } } class OneComment extends JPanel { /** * 一発言を整形するクラス */ OneComment(Status status){ JLabel label; try{ URL url = new URL("http://www.xxxx.xxx/fox.png"); ImageIcon icon = new ageIcon(status.getUser().getProfileImageURL()); label = new JLabel(icon); this.add(label); }catch(MalformedURLException e){ e.printStackTrace(); } label = new JLabel(status.getUser().getName() + ":" + status.getText()); this.add(label); // add textbox for post } }
これで表示されるこたー表示されるんですが、センタリングされてて見辛いのがなんとも。左揃えの方法を探している最中だとか。JPanel上にあるJPanelの左揃えってどうやるんですか。教えてバーニィ。嘘だと言ってバーニィ。