开发者

BlackBerry ChoiceField button size

开发者 https://www.devze.com 2023-03-12 03:44 出处:网络
I am using smaller buttons in my design and I want a ChoiceField with a smaller button.The button technique does not work as I expect on the ChoiceField. I am able to change the size but the button is

I am using smaller buttons in my design and I want a ChoiceField with a smaller button. The button technique does not work as I expect on the ChoiceField. I am able to change the size but the button is rendered incorrecly. How can I change size of the button in a ChoiceField?

ChoiceField choiceMode = 
    new ChoiceField(
        searchModel.getPickerLabel(SearchOptions.PICK开发者_C百科ER_MODE),modes.length,0) {
            public Object getChoice(int index) throws IllegalArgumentException {
                return modes[index];
            }

            public int getPreferredHeight() {
                return 40;
            }

            protected void layout(int width, int height) {
                super.layout(width, 40);
                setExtent(width, 40);
            }
        };


I use this class ::

    public class JOChoiceField extends ObjectChoiceField {
        int setWidth;
        int setHeight;

        public JOChoiceField (String text, Object[] choices, long setStyle, int initIndex, int pSetWidth, int pSetHeight) {
            super(text, choices, initIndex, setStyle);
            setWidth = pSetWidth;
            setHeight = pSetHeight;
        }           
        public int getPreferredWidth() {
            return setWidth;
        } 
        public int getPreferredHeight() {
            return setHeight;
        }           
        public void getFocusRect(XYRect rect) {        
          rect.set(getFont().getAdvance(getLabel()), 0, setWidth, setHeight);    
        }    
        protected void layout(int width, int height) {
            int useWidth;
            int useHeight;

            useWidth = getPreferredWidth();
            useHeight = getPreferredHeight();

            setExtent(setWidth, setHeight);
            super.layout(useWidth, useHeight);          
        }                   
};

--

MyCustomChoiceField= new JOCChoiceField("",MyArrayofItems,ObjectChoiceField.FIELD_LEFT|ObjectChoiceField.FOCUSABLE,0,100,50);           
MyCustomChoiceField.setChangeListener(this);                
MyCustomChoiceField.setFont(Font.getDefault().derive(Font.BOLD,6,2));       
add(MyCustomChoiceField);
0

精彩评论

暂无评论...
验证码 换一张
取 消