• 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

NX: JTable and dbfile questions

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
i managed to start a gui and have some questions on the JTable and the content of the dbfile given by Sun.
1. Some of the columns in the table are cut off (you see ... at the end of the column) and not the appropiate length, what to do about this and how to solve this problem (how can i give them the correct size automatically)?
2. Further in two of the records i see in the owner column a 0... What to do with this, there is no owner as far as i'm concerned. Does this mean no other users can book these hotels?
Thanks a lot for the help!!!
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Theo

Originally posted by Theo van Loon:
Hello all,
i managed to start a gui and have some questions on the JTable and the content of the dbfile given by Sun.
1. Some of the columns in the table are cut off (you see ... at the end of the column) and not the appropiate length, what to do about this and how to solve this problem (how can i give them the correct size automatically)?

I am assuming when you say length of the column, its at the bottom of the panel. If that is the problem, you can try by using a scrollpane. Also you can use scrollpane for both horizontal and vertical movements if the table is not fully seen.

2. Further in two of the records i see in the owner column a 0... What to do with this, there is no owner as far as i'm concerned. Does this mean no other users can book these hotels?

Well, I really do not understand the question to answer. It seems two of the records already have a owner or something. If its the case, then depending on your implementation you can either unbook the record, and allow to book or you can simply allow booking for records which are not booked. I'm just curious, my db file don't have any owners in any of the records. Are you sure you did not change the owner field? Because we are supposed to send the original given unchanged db file to them right? You can ignore this, if you got the file like that only.

Thanks a lot for the help!!!


Good Luck
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satish Avadhanam:
Originally posted by Theo van Loon:
Hello all,
i managed to start a gui and have some questions on the JTable and the content of the dbfile given by Sun.
1. Some of the columns in the table are cut off (you see ... at the end of the column) and not the appropiate length, what to do about this and how to solve this problem (how can i give them the correct size automatically)?
I am assuming when you say length of the column, its at the bottom of the panel.
No i don't mean the scrollbar at the bottom of the panel. I mean the size of the different columns in the table. How can i make them the size of the content of the column?
2. Further in two of the records i see in the owner column a 0... What to do with this, there is no owner as far as i'm concerned. Does this mean no other users can book these hotels?

It is the original file given by Sun, so two of my hotel already have owners.
How to solve this ?

 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Theo,

Originally posted by Theo van Loon:
1. Some of the columns in the table are cut off (you see ... at the end of the column) and not the appropiate length, what to do about this and how to solve this problem (how can i give them the correct size automatically)?
2. Further in two of the records i see in the owner column a 0... What to do with this, there is no owner as far as i'm concerned. Does this mean no other users can book these hotels?


1. What happens when you maximize your window? Are column values still cut off when you do this? Two ways to solve this problem: a good way and a quick way. For the good way, check out JTable in the Java API documentation, follow the link to How to Use Tables in The Java Tutorial and check out the Setting and Changing Column Widths section, specifically you will want to look at the code in TableRenderDemo.java.
The quick way is to add a horizontal scrollbar to the ScrollPane containing the JTable and allow the user to resize the column widths. Note: this is not the good way, your user will not sing your praises for doing it this way. You can search for "horizontal scroll" in this forum for the details of how to do this.
2. I guess that's possible. Before coming to that conclusion I would double-check your database file processing code to make sure you are reading everything correctly (especially look at the lengths of fields). It looks like you might have a one-off error.
If you're reading the file correctly and the records are already booked, then I guess they're already booked. What I mean is that you'll just have to deal with that situation. You need to decide whether you want to show booked records to the user in the JTable (I would say yes), whether you will allow another user to book the already booked record (again I would say yes). Everyone has to answer these questions about booked records whether or not they've received a database file that already had booked records. So if you're satisfied that you're really reading the database file correctly, I wouldn't worry about it. Most people's database files haven't had booked records in them originally, but maybe that's changed recently. It really shouldn't make a difference.
[ March 09, 2004: Message edited by: George Marinkovich ]
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,
thanks for the reply i'm going to check the tutorial!!
Regarding the lengths of the fields they all seem ok. I've checked it all and can't find an error in the handling of the db file perhaps i should post a question if other people having the same dbfile db-2x2.db have the same "problem"?
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Theo,

Originally posted by Theo van Loon:

Regarding the lengths of the fields they all seem ok. I've checked it all and can't find an error in the handling of the db file perhaps i should post a question if other people having the same dbfile db-2x2.db have the same "problem"?


Well, then you might be seeing the first known example of an actual customer ID (that is, a customer ID that comes from Sun in the database file). Can you answer a question about these customer IDs? Are they really 8 digits in length?
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The customer id just resembles a 0, so it's not 8 digits in length. So this makes me wonder if i 'm not making a mistake. All the other information seems to be correct. I checked the fieldnames and their appropiate length and they all seem to be correct. Perhaps i'm missing out on the 2 byte flag, but then how come all the other information is correct and i only see an owner in 2 occasions....
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved i missed out on the 2 byte flag that's wher i went wrong...
:roll:
 
reply
    Bookmark Topic Watch Topic
  • New Topic