home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.windows;
-
- import java.awt.Choice;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.FontMetrics;
- import java.awt.peer.ChoicePeer;
-
- class WChoicePeer extends WComponentPeer implements ChoicePeer {
- native void create(WComponentPeer var1);
-
- void initialize() {
- Choice opt = (Choice)super.target;
- int itemCount = opt.countItems();
-
- for(int i = 0; i < itemCount; ++i) {
- this.addItem(opt.getItem(i), i);
- }
-
- if (itemCount > 0 && opt.getSelectedIndex() >= 0) {
- this.select(opt.getSelectedIndex());
- }
-
- super.initialize();
- }
-
- public WChoicePeer(Choice target) {
- super(target);
- }
-
- public Dimension minimumSize() {
- FontMetrics fm = ((WComponentPeer)this).getFontMetrics(super.target.getFont());
- Choice c = (Choice)super.target;
- int w = 0;
-
- for(int i = c.countItems(); i-- > 0; w = Math.max(fm.stringWidth(c.getItem(i)), w)) {
- }
-
- return new Dimension(28 + w, Math.max(fm.getHeight() + 8, 15) + 3);
- }
-
- public native void addItem(String var1, int var2);
-
- public native void select(int var1);
-
- public native void remove(int var1);
-
- void handleAction(long time, int msgData, int index) {
- Choice c = (Choice)super.target;
- c.select(index);
- super.target.postEvent(new Event(super.target, 1001, c.getItem(index)));
- }
- }
-