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 8180201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:09:52+00:00 2026-06-07T00:09:52+00:00

I have a JTable on which Components can be dropped. Some of those components

  • 0

I have a JTable on which Components can be dropped. Some of those components can be dropped ONLY as an insert in the table (so not on an already existing cell).

My question is how I can disallow dropping on cells for these components. I tried something like:

JTable table = new JTable();
table.setDropMode(DropMode.ON_OR_INSERT_COLS);
table.setTransferHandler(new ExampleTransferHandler());
boolean onlyColumnInsert = true;

private class ExampleTransferHandler extends TransferHandler{
    public boolean canImport(TransferSupport support){
        if(onlyColumnInsert){
            return table.getDropLocation().isInsertColumn();
        }else{
            return true;
        }
    }
}

but that doesn’t work, because isInsertColumn() is only set after the drop completes. Is there any other way to detect whether a drop will result in a column insert from the canImport() method in TransferHandler?

Thanks!

  • 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-07T00:09:54+00:00Added an answer on June 7, 2026 at 12:09 am

    I found a workaround to this issue, by casting the DropLocation that the TransferSupport carries to a JTable.DropLocation:

    private class ExampleTransferHandler extends TransferHandler{
      public boolean canImport(TransferSupport support){
        if(onlyColumnInsert){
            return ((JTable.DropLocation)support.getDropLocation()).isInsertColumn();
        }else{
            return true;
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JTable using a custom DefaultTableModel which has some Booleans in the
I have the following JTable which uses a table model: http://s17.postimage.org/7zfh3l4lr/Screen_Shot_2012_03_10_at_15_11_31.png Instead of using,
We have a Java Swing application which contains components like JTable, JCombobox, JTextArea and
I have a jTable which currently displays and allows editing of a database table,
In Java Swing I have created a JTable which uses a table model class
I have a standalone application in which I have a Jtable. In my table,
I have a JTable which is loaded from a data-structure using table model.The data-structure
I have one JTable which show list of book and it can be filtered
I have a JTable . One column holds a JPanel which contains some JLabels
I have a JTable which is connected to sqlite. The db table looks like

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.