giozh
giozh

Reputation: 10068

JTable, disable user column dragging

I have declared my JTable as:

data_table = new JTable(info, header) {
    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }
};

But I've seen that at runtime it's possible to drag the columns with mouse. How can I disable that?

Upvotes: 77

Views: 57316

Answers (2)

fidzaccheus
fidzaccheus

Reputation: 21

To anyone having this problem using Netbeans IDE you can disable the user from dragging columns in the JTable by doing the following steps.

Customizer Dialog

  • Right click the table
  • Select Table contents
  • Click the columns tab
  • Uncheck the Allow to reorder columns by drag and drop

Upvotes: -1

user2577094
user2577094

Reputation:

data_table.getTableHeader().setReorderingAllowed(false); should do the job, unless you mean that the user can resize column headers.

Upvotes: 142

Related Questions