[過去ログ] 【初心者】スレを立てる前にココで質問を【Part28】©2ch.net (1002レス)
上下前次1-新
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
4: 名前は開発中のものです。 [] 2016/05/31(火) 21:49:13.27 ID:5XqNUbsR(1/4) AAS
前スレの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: 名前は開発中のものです。 [] 2016/05/31(火) 21:49:47.47 ID:5XqNUbsR(2/4) AAS
続き
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;
}
}
}
}
7: 名前は開発中のものです。 [] 2016/05/31(火) 22:10:54.41 ID:5XqNUbsR(3/4) AAS
ごめん。縦書きっていうのはドラクエとかで
ーーーーーー
ルーラの杖 |
➡薬草 |
しもふり肉 |
あああああ |
いいいいい |
ーーーーーー
と表示させたいんだ。
11: 名前は開発中のものです。 [] 2016/05/31(火) 23:02:05.12 ID:5XqNUbsR(4/4) AAS
皆こんな感じで表示をしてるんかな?
if (currentChoice > start + displaySize - 1) {
であってるみたい。
多分アイテム表示はこれで出来たみたい。ありがとう!
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.038s