Swing/ListMouseSelection のバックアップの現在との差分(No.8)
TITLE:JListをマウスクリックのみで複数選択する
Posted by terai at 2011-07-18
JListをマウスクリックのみで複数選択する
JListをアイテムをマウスクリックだけで複数選択できるように設定します。-
category: swing
folder: ListMouseSelection
title: JListをマウスクリックのみで複数選択する
tags: [JList, MouseListener]
author: aterai
pubdate: 2011-07-18T17:21:18+09:00
description: JListをアイテムをマウスクリックだけで複数選択できるように設定します。
image:
hreflang:
href: https://java-swing-tips.blogspot.com/2012/04/select-multiple-items-in-jlist-by.html lang: en
概要
JList
をアイテムをマウスクリックだけで複数選択できるように設定します。
- &jnlp;
- &jar;
- &zip;
Screenshot
Advertisement
サンプルコード
#spanend
#spanadd
* サンプルコード [#sourcecode]
#spanend
#spanadd
#code(link){{
#spanend
JList list = new JList(model) {
private ClearSelectionListener listener;
@Override public void setSelectionInterval(int anchor, int lead) {
if(anchor==lead && lead>=0 && anchor>=0) {
if(listener.isDragging) {
if (anchor == lead && lead >= 0 && anchor >= 0) {
if (listener.isDragging) {
addSelectionInterval(anchor, anchor);
}else if(!listener.isInCellDragging) {
if(isSelectedIndex(anchor)) {
} else if (!listener.isInCellDragging) {
if (isSelectedIndex(anchor)) {
removeSelectionInterval(anchor, anchor);
}else{
} else {
addSelectionInterval(anchor, anchor);
}
listener.isInCellDragging = true;
}
}else{
} else {
super.setSelectionInterval(anchor, lead);
}
}
};
解説
- 左: Default
- 中: MouseEvent
- JList#processMouseEvent, JList#processMouseMotionEventをオーバーライドして、常にCtrlキーが押されている状態にする
- マウスでアイテムをドラッグしても選択状態は変わらない
- JListの空白部分をクリックした場合、アイテムの選択状態は変更せず(MouseEvent#consume())、フォーカスだけJListに移動
- 参考: Thread: JList where mouse click acts like ctrl-mouse click
解説
- 左:
Default
- Ctrlキーを押しながらマウスクリックでリストアイテムの複数選択が可能
- 中:
MouseEvent
-
JList#processMouseEvent
、JList#processMouseMotionEvent
をオーバーライドして常にCtrlキーが押されている状態に設定 - マウスでアイテムをドラッグしても選択状態は変化しない
-
JList
の空白部分をクリックした場合、アイテムの選択状態は変更せず(MouseEvent#consume()
)フォーカスだけJList
に移動 - 参考: Swing - JList where mouse click acts like ctrl-mouse click
JList list = new JList(model) { @Override protected void processMouseMotionEvent(MouseEvent e) { super.processMouseMotionEvent(convertMouseEvent(e)); } #spanadd #spanend @Override protected void processMouseEvent(MouseEvent e) { if(e.getID()==MouseEvent.MOUSE_PRESSED && !getCellBounds(0, getModel().getSize()-1).contains(e.getPoint())) { if (e.getID() == MouseEvent.MOUSE_PRESSED && !getCellBounds(0, getModel().getSize() - 1).contains(e.getPoint())) { e.consume(); requestFocusInWindow(); }else{ } else { super.processMouseEvent(convertMouseEvent(e)); } } #spanadd #spanend private MouseEvent convertMouseEvent(MouseEvent e) { //Thread: JList where mouse click acts like ctrl-mouse click //http://forums.oracle.com/forums/thread.jspa?messageID=5692411 // Swing - JList where mouse click acts like ctrl-mouse click // https://community.oracle.com/thread/1351452 return new MouseEvent( (Component) e.getSource(), e.getID(), e.getWhen(), //e.getModifiers() | InputEvent.CTRL_MASK, //select multiple objects in OS X: Command+click //pointed out by nsby e.getModifiers() | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); (Component) e.getSource(), e.getID(), e.getWhen(), // e.getModifiers() | InputEvent.CTRL_MASK, // select multiple objects in OS X: Command+click // pointed out by nsby e.getModifiers() | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); } };
-
- 右: SelectionInterval
- JList#setSelectionIntervalをオーバーライドして、ひとつのアイテムのセルを選択した場合は、JList#addSelectionInterval、JList#removeSelectionIntervalを使用するように変更
- マウスでアイテムをドラッグすると、選択状態になる
- 右:
SelectionInterval
-
JList#setSelectionInterval
をオーバーライドしてひとつのアイテムのセルを選択した場合、JList#addSelectionInterval
、JList#removeSelectionInterval
を使用するように変更 - マウスでアイテム上をドラッグすると選択状態になる
- ひとつのアイテムのセル内でのドラッグでは、選択状態を変更しない
- 参考: Thread: JList where mouse click acts like ctrl-mouse click
- JListの空白部分をクリックした場合、アイテムの選択状態をすべてクリア(JListの選択を解除)
-
JList
の空白部分をクリックした場合、アイテムの選択状態をすべてクリア
-
参考リンク
参考リンク
コメント
- OSX(snow leopard)では、MouseEventは複数選択が出来ません。キーボードを使っても(command+クリック)無理でした。 -- nsby?
- ご指摘ありがとうございます。OSXでは「command+クリック」で複数選択でしたっけ? InputEvent.CTRL_MASK決め打ちではなく、Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()に修正した方がいいのかもしれません(ソースなどを更新しましたが、正常に動作するかは確認していません…)。 -- aterai
- Web Startでもう一度実行してみましたが、やはり出来ませんでした。MouseEventで複数選択ha -- nsby?
- あ、変な所で切れてしまいました。すみません。あらためて、MouseEventで複数選択出来るのは、Shift+クリックで選択した場合のみです。それ意外はダメでした。(Cntl+クリックとかでもダメ) -- nsby?
- Web Startのキャッシュは、…関係なさそうですね。src.zipをダウンロードしてJList#processMouseEvent(...)内で、System.out.println(e);したりsuper.processMouseEvent(convertMouseEvent(e));だけにしてみるとどうなるでしょうか? -- aterai
- MouseEvent eを出力してみました ちゃんと処理してるように見えるんですが・・・ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() : 0x04 InputEvent.CTRL_MASK : 0x02 [ただのクリック] java.awt.event.MouseEvent[MOUSE_PRESSED,(57,4),absolute(971,484),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY\ =0.0,border=,flags=50331944,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$Sy\ stemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x10 java.awt.event.MouseEvent[MOUSE_RELEASED,(57,4),absolute(971,484),button=1,modifiers=Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0.0,border=,flags=5\ 0331944,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=39,\ g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x10 java.awt.event.MouseEvent[MOUSE_CLICKED,(57,4),absolute(971,484),button=1,modifiers=Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0.0,border=,flags=50\ 331944,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=39,g\ =118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x10 [Cntl + クリック] java.awt.event.MouseEvent[MOUSE_PRESSED,(57,40),absolute(971,520),button=1,modifiers=?+Button1,extModifiers=?+Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,align\ mentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFacto\ ry$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x12 java.awt.event.MouseEvent[MOUSE_RELEASED,(57,40),absolute(971,520),button=1,modifiers=?+Button1,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0\ .0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$Syst\ emColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x12 java.awt.event.MouseEvent[MOUSE_CLICKED,(57,40),absolute(971,520),button=1,modifiers=?+Button1,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0.\ 0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$Syste\ mColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x12 [Command + クリック] java.awt.event.MouseEvent[MOUSE_PRESSED,(56,72),absolute(970,552),button=1,modifiers=?+Button1+Button3,extModifiers=?+Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0\ .0,alignmentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaIm\ ageFactory$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x14 java.awt.event.MouseEvent[MOUSE_RELEASED,(56,72),absolute(970,552),button=1,modifiers=?+Button1+Button3,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alig\ nmentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFact\ ory$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x14 java.awt.event.MouseEvent[MOUSE_CLICKED,(56,72),absolute(970,552),button=1,modifiers=?+Button1+Button3,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,align\ mentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFacto\ ry$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x14 ちなみに e.getModifiers() | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), を e.getModifiers() | 0x01 , #0x01 はShift とかに無理矢理するとクリックだけでShiftと同じ動作になるんですけどね・・・ もう意味が分かりません -- nsby?
- あら見づらくなりすみません。 -- nsby?
- ようするに、convertMouseEvent内のe.getModifiers() に 0x02/0x04をorしてもOSXでは無視されてるようです。なぜなんでしょう? -- nsby?
コメント
-
OSX(snow leopard)
では、MouseEvent
は複数選択が出来ません。キーボードを使っても(command+クリック)無理でした。 -- nsby- ご指摘ありがとうございます。
OSX
では「command+クリック」で複数選択でしたっけ?InputEvent.CTRL_MASK
決め打ちではなく、Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
に修正した方がいいのかもしれません(ソースなどを更新しましたが、正常に動作するかは確認していません…)。 -- aterai
- ご指摘ありがとうございます。
-
Web Start
でもう一度実行してみましたが、やはり出来ませんでした。MouseEvent
で複数選択ha -- nsby - あ、変な所で切れてしまいました。すみません。あらためて、
MouseEvent
で複数選択出来るのは、Shift+クリックで選択した場合のみです。それ意外はダメでした。(Ctrl+クリックとかでもダメ) -- nsby-
Web Start
のキャッシュは、…関係なさそうですね。src.zip
をダウンロードしてJList#processMouseEvent(...)
内で、System.out.println(e);
したりsuper.processMouseEvent(convertMouseEvent(e));
だけにしてみるとどうなるでしょうか? -- aterai
-
-
MouseEvent e
を出力してみました。ちゃんと処理してるように見えるんですが・・・
#spanend
#spanadd
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() : 0x04 InputEvent.CTRL_MASK : 0x02
#spanend
#spanadd
[ただのクリック]
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_PRESSED,(57,4),absolute(971,484),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY
#spanend
#spanadd
=0.0,border=,flags=50331944,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$Sy
#spanend
#spanadd
stemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x10
#spanend
#spanadd
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_RELEASED,(57,4),absolute(971,484),button=1,modifiers=Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0.0,border=,flags=5
#spanend
#spanadd
0331944,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=39,
#spanend
#spanadd
g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x10
#spanend
#spanadd
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_CLICKED,(57,4),absolute(971,484),button=1,modifiers=Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0.0,border=,flags=50
#spanend
#spanadd
331944,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=39,g
#spanend
#spanadd
=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x10
#spanend
#spanadd
#spanend
#spanadd
[Cntl + クリック]
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_PRESSED,(57,40),absolute(971,520),button=1,modifiers=?+Button1,extModifiers=?+Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,align
#spanend
#spanadd
mentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFacto
#spanend
#spanadd
ry$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x12
#spanend
#spanadd
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_RELEASED,(57,40),absolute(971,520),button=1,modifiers=?+Button1,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0
#spanend
#spanadd
.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$Syst
#spanend
#spanadd
emColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x12
#spanend
#spanadd
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_CLICKED,(57,40),absolute(971,520),button=1,modifiers=?+Button1,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alignmentY=0.
#spanend
#spanadd
0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$Syste
#spanend
#spanadd
mColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x12
#spanend
#spanadd
#spanend
#spanadd
[Command + クリック]
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_PRESSED,(56,72),absolute(970,552),button=1,modifiers=?+Button1+Button3,extModifiers=?+Button1,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0
#spanend
#spanadd
.0,alignmentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaIm
#spanend
#spanadd
ageFactory$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x14
#spanend
#spanadd
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_RELEASED,(56,72),absolute(970,552),button=1,modifiers=?+Button1+Button3,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,alig
#spanend
#spanadd
nmentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFact
#spanend
#spanadd
ory$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x14
#spanend
#spanadd
#spanend
#spanadd
java.awt.event.MouseEvent[MOUSE_CLICKED,(56,72),absolute(970,552),button=1,modifiers=?+Button1+Button3,extModifiers=?,clickCount=1] on example.MainPanel$1[,0,0,106x193,alignmentX=0.0,align
#spanend
#spanadd
mentY=0.0,border=,flags=50332008,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFacto
#spanend
#spanadd
ry$SystemColorProxy[r=39,g=118,b=218],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0] e.getModifiers() : 0x14
#spanend
#spanadd
- ちなみに
e.getModifiers() | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
をe.getModifiers() | 0x01
,#0x01
は Shiftとかに無理矢理するとクリックだけでShiftと同じ動作になるんですけどね・・・。もう意味が分かりません。 -- nsby - あら見づらくなりすみません。 -- nsby
- ようするに、
convertMouseEvent
内のe.getModifiers()
に0x02/0x04
をor
してもOSX
では無視されてるようです。なぜなんでしょう? -- nsby- ログ(勝手にすこし整形しました)どうもです。たしかにうまくいっているっぽいのに、不思議な感じですね。
もうすこし調べてみます。 -- ateraiInputEvent.CTRL_DOWN_MASK
とInputEvent.CTRL_MASK
の違い? -
Java 8
で修正されているかも? Bug ID: JDK-7170657 macosx - There seems to be no keyboard/mouse action to select non-contiguous items in List -- aterai - 追記:
Java 10
でToolkit#getMenuShortcutKeyMask()
(Event.CTRL_MASK:2
を返す)は非推奨になり、Toolkit.html#getMenuShortcutKeyMaskEx()を使用すれば、例えばWindows
環境ではInputEvent.CTRL_DOWN_MASK:128
、macOS
環境ではInputEvent.META_DOWN_MASK
が取得できるようになった
- ログ(勝手にすこし整形しました)どうもです。たしかにうまくいっているっぽいのに、不思議な感じですね。
- メモ: Tailoring Java Applications for Mac OS X -- aterai
- ドラッグによる
JList
の複数選択は、JListのアイテムを範囲指定で選択を使用する方法もあります。 -- aterai