0
私のプログラムにはJList
があり、各インデックスをString
に設定する方法を知りたいと思います。私はそれをString
と正規表現の配列を使用してSQLデータベースを更新するために使用し、SQLデータベースの列に関連する3つの値に分割します。JListインデックスを文字列を区切るように設定
私はこれを行う方法について考えていますが、これを完了するにはもっと効率的な方法があると思います。
int indices = JList.getLastVisibleIndex();+1;
int stringnum = 0;
//getLastVisibleIndex returns the integer of items I have in the JList,
but if I have 5, the value is returned 4, etc, so I add 1.
A more efficient way of doing this is possible, I would also imagine?
while(stringnum<indices){
JList.setSelectedIndex(1);
String item = JList.getSelectedIndex();
//Where I use the string (I'm updating an SQL database using it)
remove(item);
//Remove is a method I have set up to remove the selected index
stringnum++;
}
私は実際に上記のコードをテストしていませんが、それはうまくいくと思います。私はちょうど誰かが私の問題に近づく方法を知っていたより良い方法があればここで尋ねると思った。御時間ありがとうございます。 :)