• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Table Model for Java Beans

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have the URLyBird assignment, and I decided to create a "HotelRoom" bean since:

although the hope is that this interim step will give them a starting point for migrating the system to the web

.
It seems logical to have some decent data structures for the later migration.

The problem is when I got to the GUI, for my table model I created a ColumnMetaData inner class that contains the column name, the accesor Method for the property in the bean and the Class type of the property.

I'm trying to go with simplicity in the GUI because:

The IT director does not anticipate much reuse of the first Java technology system

but I'm not sure if reflection is simple enough.

Did any of you created a class for the hotel rooms, and if you did, how did you managed your JTable? Should I make my table model generic or just stick with the simplicity stuff?.


Regards
 
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created Hotel class, I used it because it is easier to send that object rather than sending String[].

When dealing by JTable,I use String[] to store the table header and ArrayList<String[]> to store the hotel record on each String[].

In my Hotel object I created a method to return a String[] of each field.


Good luck !!!


Jeffry Kristianto Yanuar (Java Instructor)
SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2) --> Waiting for the result
 
Martin Castellanos
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeffry,

I actually though about that since I also have a method that constructs the String array but I did not like it because since returns the values with the full length (Hotel Name 64, City 64..), it looks bad on the table and also I wanted to display a checkbox for the smoking column.

But now that I think about it, I can still do/fix those things with your approach and manage to avoid the extra complexity.

Thank you very much

Regards
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Martin, for this assignment, simplicity is the key, so I don't think using checkbox in smoking column is necessary.

Good luck and wish me luck too !!

Jeffry Kristianto Yanuar (Java Instructor)
SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2) --> Waiting for the result
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Martin,

I have B&S and decided to use my contractor value object everywhere including in my JTable's model.

I did not make my JTable's model generic; it only supports the one value object. As you said, there is no point putting too much working into a GUI that will be replaced.

I do not like DBMain so I use Data as an adapter to my new interface. This means Data is the only class that uses String[]; the rest all use the value object.

I have not uploaded my project yet, so I cannot tell you if SUN is going to like my approach - fingers crossed.

Good luck,
Karen Smrha
 
Martin Castellanos
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I decided to go with the String array also, how do you keep track of the record number? I added the record number as another string at the end of the String array.
Ex: ["Hotel Name", "City", "4", "Y", "$1", "2003/04/04", "0000001", "5"]

Regards and good luck to you both
reply
    Bookmark Topic Watch Topic
  • New Topic