Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't make JTableHeader reorderingAllowed

 
Andreas Rutvik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody !

I am new to this forum and have also just started my SCJD. I have created a JTable where the cells are not editable. Previously, I was able to change the order of the columns of the table by "dragging" one column over to the other, and then they changed place. Now I can't do that.

Here is the "important" code :





Could someone please help me, since my GUI knowledges are on a really novice level.

Regards
/Andreas
 
Antonio Vieira
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andreas

I like your enthusiasm in trying to develop a highly usable UI, but is this even a requirement for the application?

I'm writing the URLyBird app and I don't recall coming across any sorting or repositioning functionality. I've been developing my UI and I've had to really fight my instincts to provide additional functionality, but to paraphrase the requirements "no additional credit will be provided for anything beyond the spec". This seems to keep me in check when I begin to stray.

Cool idea, but may it may not be worth the time if it's not being graded.

Antonio
 
Andreas Rutvik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Antonio,

You are right.There is no need for doing this and I won�t do it either because it�s unnecessary in this case. BUT, now I�m more curious on how this could be achieved if I would like to do it :=)

Best regards
/Andreas
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andreas,

Are you adding your JTable to a JScrollPane or explicitly setting the header to be visible?

Here's the code I used to test this:

Regards, Andrew
 
Andreas Rutvik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

Yes I'm adding my JTable to the JScrollPane as below :



I've also tried the code you supplied, and the result is the same there as well, i.e I can't change position of two columns.

Regards
/Andreas
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andreas,
I've also tried the code you supplied, and the result is the same there as well, i.e I can't change position of two columns.
Very strange. I can easily drag one column to another location:



Unfortunately I don't have time to look at this today, and tomorrow looks like being busy as well. Can somebody else run the sample code and see if it works for them?

Regards, Andrew
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andreas (and anyone else trying the code),

The only thing I changed for that screenshot was reducing the dimesion of the table viewport size to new Dimension(450,70).

Regards, Andrew
 
Andreas Rutvik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

I must have done something wrong previously, because now everything works perfect. Thanks for helping me out.

Regards
/Andreas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic