Filling a Space with a Button

By default, the generated button adjusts its width based on the displayed content and does not fill any extra space.

To change the button so it fills the extra space:
  1. Create a customized button class which uses all the available layout space:
    public int getButtonWidth() {
    		//always use layout width to fill the space
    		if ( _layoutWidth  > 0 )
            {
                return _layoutWidth;
            }
    		return super.getButtonWidth();
    	}
    	
    	public void setLayoutWidth(int width) {
    				super.setLayoutWidth(width);
    		_layoutWidth = width;
    	}
    
  2. Use the new FillButton class in the generated gap class:
    // customize BOBScreenUpdate_Sales_order
    	protected Object createControlById(int ID) {
    		switch (ID) {
    		case BUTTON16:
    			//Create button "Submit"
    			Button localbutton16 = new FillButton(Field.FIELD_RIGHT
    					| Field.FIELD_VCENTER);
    
    			return localbutton16;
    		case BUTTON17:
    			//Create button "Cancel"
    			Button localbutton17 = new FillButton(Field.FIELD_LEFT
    					| Field.FIELD_VCENTER);
    
    			return localbutton17;
    		default:
    			break;
    		}
    
    		return super.createControlById(ID);
    	}