【初心者】スレを立てる前にココで質問を【Part28】at GAMEDEV【初心者】スレを立てる前にココで質問を【Part28】 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト2:名前は開発中のものです。 16/05/29 10:16:04.07 jiO6jmYG.net リンクがかなり死んでるようだが、代わりがわからんのでそのまま 3:名前は開発中のものです。 16/05/30 01:31:43.57 wtPpkfk+.net おつかれさんですよ 4:名前は開発中のものです。 16/05/31 21:49:13.27 5XqNUbsR.net 前スレの992ありがとう。 何故か途中で切れてた。 String[] elementList = new String[]{"A", "B", "C", "D", "E", "F", "G", "H"}; int displaySize = 3; // 画面に表示するアイテム数 int currentChoice = 0;// 今選択中の要素番号インデックス int start = 0; // 表示要素の開始番号 // 表示はこんな感じ public void paintComponent(Graphics g) { for (int i = start; i < start + displaySize; i++) { g.drawString(elementList[i], 10, 10 * (i - start + 1)); } 5:名前は開発中のものです。 16/05/31 21:49:47.47 5XqNUbsR.net 続き public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { // 左クリックされた時 currentChoice--; if (currentChoice < start) { // when choice gets below the starting index start = currentChoice; if (currentChoice < 0) { // 一番上に来たら初期化 currentChoice = 0; start = 0; } } } else if (e.getButton() == MouseEvent.BUTTON3) { // 右クリックされた時 System.out.println("DOWN"); currentChoice++; if (currentChoice > displaySize - 1) { System.out.println(start + 1 + displaySize ); if (start + displaySize < elementList.length) { start++; } if (currentChoice > elementList.length - 1) { // 一番下に来た currentChoice = elementList.length - 1; } } } } 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch