Rather than solid dataobjects, I've got a generic class that is used to by all of my data... rather than explicit getters and setters there is a getPropery("field") method that returns me what I want. Problem is on a JComboBox. I was using toString() when I was populating with solid objects. Now, toString() could mean anything. Is there a way to overide either the comboBox or the model to tell it to display what I want? To make it configureable? Thanks.
Hi Cy, As Dana said. A custom renderer is what u r looking for. Also as he suggested consider going back to classes/objects those real fundas of OOPS
The best teams have no specialists, only general contributors with special skills
Joined: Feb 19, 2003
Hi Cy Bird, Just wondering, have u considered going back to OOPS funda yet. The pattern that u r using is a "Singleton Pattern" and should be used when there should be a single instance of any class. Typically such classes r managers in the design. They manage resources and defines commn protocol betn different objects. Some e.g. :- A manager managing print services, ApplicationManager keeping registry of applications running in an multi Application environment. etc. Do u know doing this for every objects will be horrible to maintain large projects. The major prob with this pattern is that generally such classes object reference should be got thru a public static method. So to give subclasses change to override behaviour such classes should look up environment variable like System.getProperty("myclass") to initiate the instance. In ur case then all the classes should have to look up the environment. Hope u'll reconsider ur design decision. Sincerely, Ashish
Joined: Feb 18, 2003
Thanks for the replies... I ended up extending JComboBox. My new comobbox now holds a map of all my elements. The ID is the key, and the value is my my custom bean. Very similar to the hard objects, just a little lighter and more cusomizable. The only reason we're going this way (we're using DynaBeans btw) is for memory purposes. Our app has to run on really slow machines and we have a lot of gui-rich features. Just trying to eliminate some weight...