🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9339

Re: JTable, move selected rows using a mouse

#9339
From: Werner Moschina
Date: Mon, 17 Apr 2000 00:00
26 lines
1503 bytes
Hi Steve,

> If you drop a JTable into a JScrollPane so that you can see the
> column headers, these headers can be dragged around to re-order the
> colunms by default - no coding required.

I want to move *selected rows* to reorder a table, not the columns.

That's the way it should work:
1. Select one or more rows (SINGLE_INTERVALL_SELCETION)
2. Click on these seleted rows and hold mouse button
3. Reorder the rows on the fly depending on mouse movement upwards or
downwards

The first step is easy:

   DefaultListSelectionModel lsm;     
lsm.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

Step 2 is my problem. As soon as the selected rows are clicked the
selection is cleared, except for the clicked row. How can I avoid this
behaviour, which listener must be changed?

Due to my problems in step 2, I couldn't try step 3 yet.

Regards, Werner
Technical Details
Message-ID: <38FAF193.2BFFE952@stutensee.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38F6E0DB.B6552FDE@stutensee.net> <38FABF39.9BCA4B7B@cwcom.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,f0e52445185f02d8
X-Google-Attributes: gid111d45,public
From: Werner Moschina <wmo@stutensee.net>
Subject: Re: JTable, move selected rows using a mouse
Date: 2000/04/17
Message-ID: <38FAF193.2BFFE952@stutensee.net>
X-Deja-AN: 612184344
Content-Transfer-Encoding: 7bit
References: <38F6E0DB.B6552FDE@stutensee.net> <38FABF39.9BCA4B7B@cwcom.co.uk>
X-Accept-Language: de
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing