Hari Surendran

Greenhorn
+ Follow
since Feb 09, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hari Surendran

I am assuming that you use a GridBag Layout and trying to resize the Window. Most other layouts are simple and have pre-designed UI behaviour.

The widgets are getting distorted because they themselves are getting resized. A text field can only shrink so much without losing its form. The things to consider are the spacing between UI controls, weights etc to optimize the resize behaviour.

That being said, if you resize beyond a point the controls will be distorted. That is where the scroll bars kick in. One trick is to identify the size where the controls starts getting distorted and using the scroll bars then onwards so that there is no more distortion.

If you look at a microsoft application, they typically always use scroll bars. There is no resizing of controls, only the window gets resized and the controls gets progressively hiddedn behind the scroll bars. Now you will need to scroll vertical or horizontal to view it.

Another option is to disable resizing. Of course, the individual requirements vary and that may not suit your design.
17 years ago
Since you need to have the same display values for two different drop down items, you need to use the objects instead of strings. To set a particular item on the dropdown using the data read from database, you can use the setselctedItem(Object obj) method. Just construct an object using the value read from database and call the setselctedItem(Object obj) method.

Since this newly constucted object is a different object(instance) from what is sitting inside your Jcombobox, you will have to implement an equals() method in the Vendor class in addition to the toString() method. This equals method will check whether the vendor IDs are equal.

Hope this will help.
17 years ago
I feel the Swing framework itself is built on MVC framework and hence there, without doubt, are controllers. A view object such as Jtree has a corresponding TreeModel. But the controller code typically, in such cases, is part of the view class itself.

However if we are talking about a serious UI application, you must consider the MVC pattern with separate Model, View and Controller classes. A view object will be a java class that extend a JPanel(of course with other jpanels and text boxes, Combo boxes etc embedded). The model will be a java class with variables(to hold model data) and their getters and setters. The controller will be a third java class that will have various listeners etc that will have the controller logic. The controller logic could include state management, keeping the data in sync between view objects and model etc in addition to the classic controller job of listening to the user interaction and handling the user interaction logic.
17 years ago