Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't make JTableHeader reorderingAllowed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
this is supposed to be a surprise, but it smells like a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic