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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Column name not displayed!

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For display the Flight Info with JTable, I implemented the FlightModel as following:

Now the JTable can display all the data info correctly, except for the column not found. According to the debug info, the columnNames are retrieved exactly, but just not displayed. Anyone know the reason, any comment would be appreciated!
-Fox
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fox (know any good vixens?):
I'm analyzing your code and so far have not figured out why the column head is not displyed but will keep looking.
If you don't already have it, you need to download
Code Conventions for the JavaTM Programming Language
A lot of this code does not comply with those conventions and you will lose points on general considerations for that. Also you need to use one of the newer Collections in place of Vector.
Michael Morris
[ August 29, 2002: Message edited by: Michael Morris ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Fox"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fox,
I ran a test using your table model and the table headers displayed fine in the frame I created. Here's the simple frame I used:

There must be some other problem that you are missing.
Michael Morris
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To display headers, you must decorate your JTable with a JScrollPanel, or else the headers will not display.
 
Fox Shen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael
Thanks for your comments and code example. I think I now know the reason for that. Just as shown in your code and mentioned by George, the JTable must be decorated with a JScrollPane, or the header will not display. In my own code, I just put it into a JPanel, I think that's the problem.
Fox Shen
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,Michael:
I wrote code like Fox Shen too,why did you say

A lot of this code does not comply with those conventions and you will lose points on general considerations for that.


Could you please tell me how to modify this code to comply with java code conventions???
And another question:why can't use Vector here?Which Collections should I take???
[ August 30, 2002: Message edited by: ZhengQi Huang ]
[ August 30, 2002: Message edited by: ZhengQi Huang ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ZhengQi,
There are many code conventions that you should be aware of for this assignment. To view those conventions, click on the link of my first post.
To download the HTML version click the following link:
Java Code Conventions (Download HTML)
Here are some examples:
Don't do this:

Do this instead:


Don't do this:

Do this instead:

Never have lines over 80 characters. If you have to break up a long line of code, there are guidelines to where to break the line and many other items to make code very easy to read.


And another question:why can't use Vector here?Which Collections should I take???


Vector is one of the old Collections objects and the newer ones are now preferred. A good choice for a table model would be an ArrayList which has both the functionality of a dynamic array like Vector and implements the List interface. You could also use a HashMap by mapping a row to a record.
Hope this helps,
Michael Morris
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic