Re: Combo Box Problem
Re: Combo Box Problem
- Subject: Re: Combo Box Problem
- From: Eric Hermanson <email@hidden>
- Date: Wed, 26 Mar 2003 23:30:24 -0800
This is a known bug in WebObjects on Java 1.4.1. The only solution
I've found is to manually override the size of the combo box. I've
added code similar to the following in my EOApplication subclass.
Maybe there's an easier way, but I don't know?
private boolean resizeFirstComboBoxInContainer(Container container) {
int i, count;
Component components[];
boolean done = false;
components = container.getComponents();
count = (components != null) ? components.length : 0;
for(i = 0; ((i < count) && (done == false)); i++) {
Component component = components[i];
if(component instanceof JComboBox) {
JComboBox comboBox = (JComboBox)component;
if(comboBox.getPrototypeDisplayValue() == null) {
int itemIndex, itemCount;
Dimension preferredSize;
String prototypeDisplayString = null;
itemCount = comboBox.getItemCount();
for(itemIndex = 0; itemIndex < itemCount; itemIndex++) {
String string = (String)comboBox.getItemAt(itemIndex);
if((prototypeDisplayString == null) || (string.length() >
prototypeDisplayString.length())) {
prototypeDisplayString = string;
}
}
// resize component, and move it left by 1/2 of new width so it
stays centered.
// supplying a setPrototypeDisplayValue will cause the java 1.4.1
JComboBox to
// return a preferredSize based on the true size of it's contents
comboBox.setPrototypeDisplayValue(prototypeDisplayString); //
causes getPreferredSize to work...
preferredSize = comboBox.getPreferredSize();
comboBox.setLocation(((container.getWidth() - preferredSize.width)
/ 2), comboBox.getLocation().y);
comboBox.setSize(preferredSize);
}
// just adjust first combo box, and don't continue to next
done = true;
}
else if(component instanceof Container) {
// recursive...
done = this.resizeFirstComboBoxInContainer((Container)component);
}
}
return done;
}
/**
* Override superclass to fix entity picker combo box sizing bug.
*/
public void activeWindowDidChange(NSNotification notification) {
Window window;
EOWindowObserver observer;
super.activeWindowDidChange(notification);
observer = (EOWindowObserver)notification.object();
window = observer.activeWindow();
if((window != null) && (window instanceof Frame) &&
((((Frame)window).getTitle().equals("Query Window")) ||
(((Frame)window).getTitle().equals("Enumeration Window")))) {
this.resizeFirstComboBoxInContainer(window);
}
}
On Wednesday, March 26, 2003, at 11:14 PM, Buyung Pamungkas wrote:
Dear,
I have used Direct Java Application and have no
problem with combo box when I used j2se 1.3.
After I made some updates, like upgrade to j2se 1.4.1
and WO 5.2.1, I found the problem here (please view
the pdf picture attched with this mail to see the
details)
The problem is, combo box that generated by Web Object
to provide the table that I want to display is too
small. I have this problem on Windows platform too.
How to solve this problem ? Could I edit manually the
size of those combo box ?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
[demime 0.98b removed an attachment of type application/pdf which had
a name of comboBoxProblem.pdf]
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.