Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:44:51+00:00 2026-06-18T08:44:51+00:00

I work with the MVC pattern and I’ve a JTable like this : List<Enregistrement>

  • 0

I work with the MVC pattern and I’ve a JTable like this :

List<Enregistrement> desEnregistrements = dao.lireTousLesEnregistrements(1);
    
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Date Enregistrement");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Libellé");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Motif");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Date facture");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Mode de règlement");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Montant");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Solde");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Etat");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Modifier");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("RecDep");
    ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Anticipation");
    
    for (Enregistrement unEnregistrement : desEnregistrements) {
        ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addRow(new String[]{unEnregistrement.getDate(), unEnregistrement.getIdLibelle(), unEnregistrement.getMotif(), unEnregistrement.getDateFacture(), unEnregistrement.getModeReglement(), unEnregistrement.getMontant(), unEnregistrement.getNouveauSolde(), unEnregistrement.getIdEtat(),unEnregistrement.getId(), unEnregistrement.getRecetteDepense(), unEnregistrement.getAnticipation()});   
    }
    
    aspectJtable();

I would like to use a drag and move rows with this JTable so I implements this code : How do I drag and drop a row in a JTable?

But I don’t understand how i can implement the interface "Reorderable" to my TableModel.

When I run my project I can use the drag and move (I see the drag…) but there is no movement.

Next, I’ve this error :

java.lang.ClassCastException: vues.VueAfficherCompteCIO$1 cannot be cast to controleurs.Reorderable
at controleurs.TableRowTransferHandler.importData(TableRowTransferHandler.java:55)
at javax.swing.TransferHandler$DropHandler.drop(TransferHandler.java:1536)
at java.awt.dnd.DropTarget.drop(DropTarget.java:450)
at javax.swing.TransferHandler$SwingDropTarget.drop(TransferHandler.java:1274)
at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetContextPeer.java:537)
at sun.awt.X11.XDropTargetContextPeer.processDropMessage(XDropTargetContextPeer.java:184)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEvent(SunDropTargetContextPeer.java:851)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDropTargetContextPeer.java:775)
at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:48)
at java.awt.Component.dispatchEventImpl(Component.java:4716)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:4566)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4417)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

The 55 line is :

((Reorderable)table.getModel()).reorder(rowFrom, index);

Someone can help me, and explain how it’s work ?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:44:53+00:00Added an answer on June 18, 2026 at 8:44 am

    If I correctly understand the code in the sample to implement the interface Reorderable you simply should get the row which is placed at the fromIndex and inserts at the toIndex.

    Example:

    public class ReorderableTableModel extends DefaultTableModel implements Reorderable {
      public void reorder(int from, int to) {
        Object o = getDataVector().remove(from);
        getDataVector().add(to, o);
        fireTableDataChanged();
      }
    }
    

    Do not forget to set the instanceo of this table model to your table

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This piece of code used to work in MVC 1 but it does not
I work in a team of 25 developers. We use ExtJS MVC pattern of
I'm working with webapi, MVC 4 project. (using repository pattern and Unit of Work)
I am utilizing the Unit Of Work and Generic Repository pattern in my MVC
I am using asp.net mvc and nhibernate with the unit of work pattern. I
Before the MVC pattern I would include UX classes simply by including this at
At this moment I start work on small web application based on MVC. Now
few days ago i read tutorial about GenericRepository and Unit Of Work patterns http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
I've setup IIS6 to work with MVC, added a new virtual web site, entry
since the Sitemap of VS2008 does not work with MVC, I found MVC Sitemap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.