button USE_ALL_WIDTH

Hi there, new to blackberry programming so forgive me if this is the wrong format/space for that matter.

In any case, I just want to put the 4 buttons in a vertical row, each of which is the width of the screen. However, his USE_ALL_WIDTH not recognizing. I use a verticalFieldManager for this. Could someone tell me please the more simple so he can do? (Keep in mind, I am a rookie programmer very) Thank you!

USE_ALL_WIDTH is our instruction on the ground. Surprisingly, ButtonField does not take into account these instructions. More surprising, she pays tribute to her own getPreferredWidth (as illogical as it may seem).

Then drop this USE_ALL_WIDTH and describe your ButtonField like this:

ButtonField testButton = new ButtonField("Test Button") {
    public int getPreferredWidth() {
        return Display.getWidth();
    }
};

Tags: BlackBerry Developers

Similar Questions

  • String following line - Style field list button

    Hi all

    Below I have attached two images of liststylebuttonfield,

    1. in the first picture

    True line-'connected to 3 organization... ". ', display line-'connected to 3 organization... ". »

    the remaining letters are present in the background of the image.

    I give the width = totalwidth - lefticon.getwidth ();

    2. in the second picture

    True line-'connected to 3 organization... ". ', display line-"Connected to eveniment 3.

    the remaining letters are hiding.

    I give the width = totalwidth - lefticon.getwidth () - balloonIcon.getwidth () - actionIcon.getwidth ();

    How to give to the next line of width/auto for this problem.

    Below I attach my code for your reference...

    package com.samples.toolkit.ui.component;
    
    import java.util.Calendar;
    
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Characters;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.TouchEvent;
    import net.rim.device.api.ui.Touchscreen;
    import net.rim.device.api.ui.Ui;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.LabelField;
    
    public class TestFeedListStyleField extends Field {
        Font myFont = Font.getDefault().derive(Font.SERIF_STYLE,5, Ui.UNITS_pt);
        Font myFont1 = Font.getDefault().derive(Font.BOLD,5, Ui.UNITS_pt);
        public static int DRAWPOSITION_TOP = 0;
        public static int DRAWPOSITION_BOTTOM = 1;
        public static int DRAWPOSITION_MIDDLE = 2;
        public static int DRAWPOSITION_SINGLE = 3;
        private static final int CORNER_RADIUS = 18;
        private static final int HPADDING = Display.getWidth() <= 320 ? 6 : 8;
        private static final int VPADDING = 4;
    
        private static final int COLOR_BACKGROUND = 0xFFFFFF;
        private static final int COLOR_BORDER = 0xBBBBBB;
        private static final int COLOR_BACKGROUND_FOCUS = 0x186DEF;
         public MyLabelField _labelField,_labelField1, _labelField2,_labelField3;
    
         private Bitmap _caret;
         private int _rightOffset;
            private int _leftOffset;
            private int _labelHeight,_labelHeight1,_labelHeight2,_labelHeight3;
            private Bitmap _leftIcon;
            private Bitmap _actionIcon;
            private Bitmap _ballon;
            private int _drawPosition = -1;
            private String _labelField1test;
    
        public TestFeedListStyleField(Bitmap icon,String label, String label1, String lable2,String lable3, Bitmap balloon,Bitmap caret,
                long style) {
             super( USE_ALL_WIDTH | Field.FOCUSABLE );
            _leftIcon = icon;
             _labelField = new MyLabelField(label, style );
             _labelField1 = new MyLabelField(label1, style );
             _labelField2=new  MyLabelField(lable2,style);
            _labelField3=new  MyLabelField(lable3,style);
            _ballon=balloon;
            _actionIcon=caret;
            _labelField1test=label1;
            _labelField.setFont(myFont);
            _labelField1.setFont(myFont);
            _labelField2.setFont(myFont1);
            _labelField3.setFont(myFont);
    //      Imagelistner imglistner = new Imagelistner();
    //      _actionIcon.
        }
    
        public TestFeedListStyleField(String label, String label1, String lable2,Bitmap caret,
                long style) {
             super( USE_ALL_WIDTH | Field.FOCUSABLE );
             _labelField = new MyLabelField(label, style );
             _labelField1 = new MyLabelField(label1, style );
             _labelField2=new  MyLabelField(lable2,style);
            _actionIcon=caret;
            _labelField1test=label1;
            _labelField1.setFont(myFont);
            _labelField2.setFont(myFont);
    //      Imagelistner imglistner = new Imagelistner();
    //      _actionIcon.
        }
    
        public void setDrawPosition( int drawPosition )
        {
            _drawPosition = drawPosition;
        }
         public String toString()
            {
                return _labelField.toString();
            }
    
        protected void layout(int width, int height) {
            if( Touchscreen.isSupported() ) {
            }
    
            _leftOffset = HPADDING;
            if( _leftIcon != null ) {
                _leftOffset += _leftIcon.getWidth() + HPADDING;
            }
    
            _rightOffset = HPADDING;
            if( _caret != null ) {
                _rightOffset += _caret.getWidth() + HPADDING;
            }
            _labelField.layout( width - _leftOffset - _rightOffset, height );
            _labelHeight = _labelField.getHeight();
            int labelWidth = _labelField.getWidth();
    
            _labelField1.layout( width - _leftOffset - _rightOffset, height );
            _labelHeight1 = _labelField1.getHeight();
            int labelWidth1 = _labelField1.getWidth();
    
            _labelField2.layout( width - _leftOffset - _rightOffset, height );
            _labelHeight2 = _labelField2.getHeight();
            int labelWidth2 = _labelField2.getWidth();
    
            _labelField3.layout( width - _leftOffset - labelWidth1 - _rightOffset, height );
            _labelHeight3 = _labelField3.getHeight();
            int labelWidth3 = _labelField3.getWidth();
    
            if( _labelField.isStyle( DrawStyle.HCENTER ) ) {
                _leftOffset = ( width - labelWidth ) / 2;
            } else if ( _labelField.isStyle( DrawStyle.RIGHT ) ) {
                _leftOffset = width - labelWidth - HPADDING - _rightOffset;
            }
    
            if( _labelField1.isStyle( DrawStyle.HCENTER ) ) {
                _leftOffset = ( width - labelWidth1 ) / 2;
            } else if ( _labelField.isStyle( DrawStyle.RIGHT ) ) {
                _leftOffset = width - labelWidth1 - HPADDING - _rightOffset;
            }
            if( _labelField2.isStyle( DrawStyle.HCENTER ) ) {
                _leftOffset = ( width - labelWidth2 ) / 2;
            } else if ( _labelField.isStyle( DrawStyle.RIGHT ) ) {
                _leftOffset = width - labelWidth2 - HPADDING - _rightOffset;
            }
    
            int extraVPaddingNeeded = 0;
    //      if( _labelHeight < _targetHeight ) {
    //          // Make sure that they are at least 1.5 times font height
    //          extraVPaddingNeeded =  ( _targetHeight - _labelHeight ) / 2;//( _targetHeight - _labelHeight ) / 2;
    //      }
            if( _leftIcon != null ) {
                  if( _labelHeight+_labelHeight1 < _leftIcon.getHeight() ) {
                      // Make sure that they are at least 1.5 times font height
                      extraVPaddingNeeded =  _leftIcon.getHeight();//( _targetHeight - _labelHeight ) / 2;
                  }
                  else if( _labelHeight+_labelHeight1 > _leftIcon.getHeight() ){
                    extraVPaddingNeeded =  _labelHeight+_labelHeight1;
                  }
            }
            else{
                if( _labelHeight+_labelHeight1 < _actionIcon.getHeight() ) {
                      // Make sure that they are at least 1.5 times font height
                      extraVPaddingNeeded =  _leftIcon.getHeight();//( _targetHeight - _labelHeight ) / 2;
                  }
                  else if( _labelHeight+_labelHeight1 > _actionIcon.getHeight() ){
                    extraVPaddingNeeded =  _labelHeight+_labelHeight1;
                  }
            }
    
          setExtent( width,  (int) (extraVPaddingNeeded*1.1) );
    
        }
          public void setText( String text )
            {
                _labelField.setText( text );
                updateLayout();
            }
    
        protected void paint(Graphics g) {
    
            // Left Bitmap
            if( _leftIcon != null ) {
                g.drawBitmap( HPADDING, VPADDING, (int) (_leftIcon.getWidth()*2), (int) (_leftIcon.getHeight()*3), _leftIcon, 0, 0 );
            }
    
    //        // Text  ( getHeight() - _labelHeight ) / 2, ( getHeight() - _actionIcon.getHeight() ) / 2,  //(int) (VPADDING*.5)
            try {
                g.pushRegion( _leftOffset, (int) (VPADDING*.5), getWidth() - _leftOffset - _rightOffset, _labelHeight, 0, 0 ); //getWidth() - _leftOffset - _rightOffset
                _labelField.paint( g );
            } finally {
                g.popContext();
            }
    
            try {
                g.pushRegion(  (int) (getWidth() - _leftIcon.getWidth()*.6 ), (int) (VPADDING*.5), getWidth() - _leftOffset - _labelField1.getWidth()- _rightOffset, _labelHeight3, 0, 0 ); //getWidth() - _leftOffset - _rightOffset
                _labelField3.paint( g );
            } finally {
                g.popContext();
            }
    
            try {
                g.pushRegion(_leftOffset, _labelHeight, getWidth() - _leftOffset - _rightOffset, _labelHeight1, 0, 0 ); //getWidth() - _leftOffset - _rightOffset
    //            String test6=_labelField1test.charAt(0)+" ".toString();
    //
    //            if(test6.trim().equals("0")){
    ////                 Dialog.alert("Success....");
    //             }
    //             else{
    //               Dialog.alert("Failure....");
                    _labelField1.paint( g );
    //             }
            } finally {
                g.popContext();
            }
    
            if( _leftIcon != null ) {
                try {
                    g.pushRegion((int) (HPADDING+_leftIcon.getWidth()), (int) (_labelHeight*1.5+_labelHeight1), getWidth() - (_leftIcon.getWidth()*2 ), (int) ((_leftIcon.getHeight()-_labelHeight-_labelHeight1)*.9),5, 5 ); //getWidth() - _leftOffset - _rightOffset
    //              g.pushRegion((int) (HPADDING+_leftIcon.getWidth()*1.1), (int) (_labelHeight*1.5+_labelHeight1), (int) (getWidth() - _leftIcon.getWidth()- _ballon.getWidth()- _actionIcon.getWidth()), (int) ((_leftIcon.getHeight()-_labelHeight-_labelHeight1)*.9), 0, 0 ); //getWidth() - _leftOffset - _rightOffset
                    _labelField2.paint( g );
                } finally {
                    g.popContext();
                }
            }
            // Right (Action) Bitmap
            if( _actionIcon != null ) {
                g.drawBitmap(  (int) (getWidth() - _leftIcon.getWidth()*.6 ), (int) (VPADDING*7.8), _ballon.getWidth(), _ballon.getHeight(), _ballon, 0, 0 );
                g.drawBitmap( getWidth() - HPADDING - _actionIcon.getWidth(), (int) (VPADDING*7), _actionIcon.getWidth(), _actionIcon.getHeight(), _actionIcon, 0, 0 );
            }
    
            // BootomGrid
    //        g.drawBitmap( (int) (HPADDING+_leftIcon.getWidth()*1.3), _labelHeight+_labelHeight1, 0, 0, _actionIcon, _drawPosition, _drawPosition );
    //        g.drawBitmap( (int) (HPADDING+_leftIcon.getWidth()*1.3), _labelHeight+_labelHeight1,  0, 0, _actionIcon, _drawPosition, _drawPosition );
    //        g.drawBitmap( (int) (HPADDING+_leftIcon.getWidth()*1.3), _labelHeight+_labelHeight1,  0, 0, _actionIcon, _drawPosition, _drawPosition );
    //        g.drawBitmap( (int) (HPADDING+_leftIcon.getWidth()*1.3), _labelHeight+_labelHeight1,  0, 0, _actionIcon, _drawPosition, _drawPosition );
    //        g.drawBitmap( (int) (HPADDING+_leftIcon.getWidth()*1.3), _labelHeight+_labelHeight1,  0, 0, _actionIcon, _drawPosition, _drawPosition );
    //
        }
    
        protected void paintBackground( Graphics g )
        {
            if( _drawPosition < 0 ) {
                // it's like a list field, let the default background be drawn
                super.paintBackground( g );
                return;
            }
    
            int oldColour = g.getColor();
    
            int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? COLOR_BACKGROUND_FOCUS : COLOR_BACKGROUND; //COLOR_BACKGROUND_FOCUS
            try {
                if( _drawPosition == 0 ) {
                    // Top
                    g.setColor( background );
                    g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
                    g.setColor( COLOR_BORDER );
                    g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
                    g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
                } else if( _drawPosition == 1 ) {
                    // Bottom
                    g.setColor( background );
                    g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
                    g.setColor( COLOR_BORDER );
                    g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
                } else if( _drawPosition == 2 ) {
                    // Middle
                    g.setColor( background );
                    g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
                    g.setColor( COLOR_BORDER );
                    g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
                    g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
                } else {
                    // Single
                    g.setColor( background );
                    g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
                    g.setColor( COLOR_BORDER );
                    g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
                }
            } finally {
                g.setColor( oldColour );
            }
        }
    
        protected void drawFocus( Graphics g, boolean on )
        {
            if( _drawPosition < 0 ) {
                super.drawFocus( g, on );
            } else {
                boolean oldDrawStyleFocus = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS );
                try {
                    if( on ) {
                        g.setDrawingStyle( Graphics.DRAWSTYLE_FOCUS, true );
                    }
                    paintBackground( g );
                    paint( g );
                } finally {
                    g.setDrawingStyle( Graphics.DRAWSTYLE_FOCUS, oldDrawStyleFocus );
                }
            }
        }
    
        protected boolean keyChar( char character, int status, int time )
        {
            if( character == Characters.ENTER ) {
                clickButton();
                return true;
            }
            return super.keyChar( character, status, time );
        }
    
        protected boolean navigationClick( int status, int time )
        {
            if (status != 0) clickButton();
            return true;
        }
    
        protected boolean trackwheelClick( int status, int time )
        {
            if (status != 0)
            clickButton();
            return true;
        }
    
        //#ifndef VER_4.1.0 | 4.0.0
            protected boolean invokeAction( int action )
            {
                switch( action ) {
                    case ACTION_INVOKE: {
                        clickButton();
                        return true;
                    }
                }
                return super.invokeAction( action );
            }
        //#endif        
    
        /**
         * A public way to click this button
         */
        public void clickButton()
        {
            fieldChangeNotify( 0 );
        }
    
    //#ifndef VER_4.6.1 | VER_4.6.0 | VER_4.5.0 | VER_4.2.1 | VER_4.2.0
        protected boolean touchEvent( TouchEvent message )
        {
            int x = message.getX( 1 );
            int y = message.getY( 1 );
            if( x < 0 || y < 0 || x > getExtent().width || y > getExtent().height ) {
                // Outside the field
                return false;
            }
            switch( message.getEvent() ) {
    
                case TouchEvent.UNCLICK:
                    clickButton();
                    return true;
            }
            return super.touchEvent( message );
        }
    //#endif 
    
        public void setDirty( boolean dirty ) {}
        public void setMuddy( boolean muddy ) {}
    
         private static class MyLabelField extends LabelField
            {
    
                public MyLabelField( String text, long style )
                {
                    super( text, style );
                }
    
                public void layout( int width, int height )
                {
                    super.layout( width, height );
                }   
    
                public void paint( Graphics g )
                {
                    super.paint( g );
                }
            }
         class Imagelistner implements FieldChangeListener {
                public void fieldChanged(Field field, int context) {
    
                }
    
                }
    

    Thank you...

    Hi all
    I solved this problem... Thank you for watching my problem...
    And I create the component 'Image + String + box' with search (like the single selection) If you need it please send mail...
    Kind regards
    NGO

  • Listener Button problem

    This is my first attempt at development for the BB storm, and I use JDE 4.7.

    I started with a Hello World application, I found and I modified to add a simple button that says RED. When you click on I tried the wallpaper turn RED and change the button to say BLUE, when that is clicked on it turns BLUE changes back to RED button again.

    I've implemented this, use a standard listener ButtonField (which I call bhandler in my code). The program type of works, with the odd effect only on the Simulator is that when I click the button, the background color changes but a little menu appears. Anyone else seen this problem of menu? I don't expect to see a menu and I have not coded anything to ask for a menu appear when I click on this button.

    Here is my source code. The Manager is in bold. All the answers that I see not why only a menu would be most appreciated... Thank you.

    /**
    * HelloWorld.java
    * Copyright (C) 2001-2003 research In Motion Limited. All rights reserved.
    */
    package com.rim.samples.helloworld;

    Net.rim.device.api.ui import. *;
    Net.rim.device.api.ui.component import. *;
    Net.rim.device.api.ui.container import. *;
    Net.rim.device.api.system import. *;
    Net.rim.device.api.ui.decor import. *;

    /*
    * BlackBerry applications that provide a user interface
    * must extend UiApplication.
    */
    SerializableAttribute public class HelloWorld extends UiApplication
    {
    Public Shared Sub main (String [] args)
    {
    create a new instance of the application
    and launch the application on the event thread
    HelloWorld APP = new HelloWorld();
    theApp.enterEventDispatcher ();
    }
    public HelloWorld()
    {
    a new screen
    pushScreen (new HelloWorldScreen());
    }
    }

    create a new screen that covers the screen, which provides
    standard behavior by default for BlackBerry applications
    final HelloWorldScreen class extends screen
    {
    public HelloWorldScreen()
    {

    call the constructor of the screen
    Super();

    Add a title to the screen
    LabelField title = new LabelField ("HelloWorld example", LabelField.ELLIPSIS
    | LabelField.USE_ALL_WIDTH);
    setTitle (title);

    Add the text "Hello World!" to the screen
    Add (new RichTextField ("Hello World!"));
                    
    First define the button handler
                    FieldChangeListener bhandler = new FieldChangeListener()
    {
    ' Public Sub fieldChanged (field field, int context)
    {
    ButtonField buttonField = field (ButtonField);
    If (buttonField.getLabel () is 'RED')
    {
    Bottom newback = BackgroundFactory.createSolidBackground (Color.RED);
    getMainManager () .setBackground (newback);
    buttonField.setLabel ("BLUE");
    }
    on the other
    {
    Bottom newback = BackgroundFactory.createSolidBackground (Color.BLUE);
    getMainManager () .setBackground (newback);
    buttonField.setLabel ("RED");
    }
    }
    };

    Define the button itself use Manager above, this one called RED
    ButtonField buttonField = new ButtonField ("RED");     Create a RED button
    buttonField.setChangeListener (bhandler);               Implement the handler for button defined above
                     
    Add (buttonField);  Adds the button to the screen.

    }

    Override the onClose() method to display a dialog to the user
    with "Goodbye!" when the application is closed
    public boolean onClose()
    {
    Dialog.Alert ("Goodbye!");
    System.Exit (0);
    Returns true;
    }
    }

    Solved in Java development.

  • Button in the pop-up screen problem

    Hi all

    I did a pop-up screen in which there are two buttons and an EditField. Now, I am faced with very weird problem. First button that I added in my code doesnot seem to work. It doesnot clicking and the second button is working well, why is it so can any body help out me of this.

    I provided the code here: -.

    public class PinPopup extends PopupScreen{
    public static  EditField texts;
    static String _userName=null;
    
    PinPopup()
        {
        super(new HorizontalFieldManager());
        Font f = Font.getDefault().derive(Font.BOLD, 16);
        setFont(f);
        texts=new EditField("","",200,Field.EDITABLE);
    
        ButtonField sendButton = new ButtonField(" Send  "){
            protected boolean navigationClick(int status, int time) {
                   Dialog.inform("Send");
                return true;
                }
        };
    
        ButtonField cancelButton = new ButtonField("Cancel"){
             protected boolean navigationClick(int status, int time) {
                   Dialog.inform("Cancel");
                return true;
                }
        };
    
        VerticalFieldManager _fieldManagerContext = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.USE_ALL_HEIGHT)
            {
    
                public void sublayout(int width,int height) {
                    //super.sublayout(width, height);
                    int xpos = 0;
                    int ypos = 0;
                    Field field = getField(0);
                    layoutChild(field, 280, 50);
                    setPositionChild(field, xpos, ypos);
                    Field field1 = getField(1);
                    layoutChild(field1, 280, 50);
                    setPositionChild(field1, xpos+20, ypos+80);
                    Field field2 = getField(2);
                    layoutChild(field2, 280, 50);
                    setPositionChild(field2, xpos+145, ypos+80);
                    setPosition(150, 220);
                    setExtent(300, 220); 
    
                   }
                    public void paint(Graphics graphics)
                    {
                        //graphics.setColor(Color.WHITE);
                        Font f = Font.getDefault().derive(Font.BOLD, 16);
                        graphics.setFont(f);
                        graphics.drawText("SEND PIN",90, 20,0,200);
                        graphics.drawText( _userName,110,40,0,200);
                        graphics.setColor(Color.WHITE);
                        super.paint(graphics);
                    }
    
            }; 
    
                  _fieldManagerContext.add(texts);
                  _fieldManagerContext.add(cancelButton);
                  _fieldManagerContext.add(sendButton);
                  add(_fieldManagerContext);
    
        }
    
    }
    

    Hi Please help me in this

    Thanks in advance

    Why do you not use Horizontalfieldmanager for horizontal alignment.

    This is the code and it works fine.

    package com.winit.mobiads.ui.screens;

    Import net.rim.device.api.ui.Color;
    Import net.rim.device.api.ui.Field;
    Import net.rim.device.api.ui.Font;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.component.Dialog;
    Import net.rim.device.api.ui.component.EditField;
    Import net.rim.device.api.ui.container.HorizontalFieldManager;
    Import net.rim.device.api.ui.container.PopupScreen;

    SerializableAttribute public class PinPopup extends PopupScreen {}
    public static EditField texts;
    public static String _userName = null;

    PinPopup()
    {
    Super (new HorizontalFieldManager());
    Police f = Font.getDefault () .derive (Font.BOLD, 16);
    setFont (f);
    texts = new EditField("","",200,Field.EDITABLE);
           
    ButtonField sendButton = new ButtonField ("send") {}
    protected boolean navigationClick (int status, int time) {}
    Dialog.Inform ("Send");
    Returns true;
    }
    };
         
    ButtonField cancelButton = new ButtonField ("Cancel") {}
    protected boolean navigationClick (int status, int time) {}
    Dialog.Inform ("Cancel");
    Returns true;
    }
    };

    HorizontalFieldManager _fieldManagerContext = new HorizontalFieldManager (USE_ALL_WIDTH)
    {
               
    ' public void sublayout (int width, int height) {}
    Super.sublayout (width, height);
    int xPos = 0;
    int yPos = 0;
    Field = getField (0);
                       
    setPositionChild (field, xpos, ypos);
    layoutChild (field, 280, 50);
                       
    Field Field1 = getField (1);
                       
    setPositionChild (Field1, xpos ypos + 80 + 20);
    layoutChild (Field1, 100, 50);

    Field Field2 = getField (2);
                       
    setPositionChild (Field2, xpos ypos + 80 + 145);
    layoutChild (Field2, 100, 50);
                       
    setPosition (150, 220);
    setExtent (width, height);
                        
    }
    public void paint (Graphics graphics)
    {
    graphics.setColor (Color.WHITE);
    Police f = Font.getDefault () .derive (Font.BOLD, 16);
    graphics.setFont (f);
    graphics.drawText ("SEND PIN", 90, 20,0,200);
    graphics.drawText (_userName, 110, 40, 0, 200);
    graphics.setColor (Color.WHITE);
    Super.Paint (Graphics);
    }
             
    };

    _fieldManagerContext.Add (texts);
    _fieldManagerContext.Add (CancelButton);
    _fieldManagerContext.Add (sendButton);
    Add (_fieldManagerContext);
                     
    }

    }

  • selection of object button switch

    Hello, master... Please help me, I have two button options object code... How to swap button A button B and vice versa...

    String[] objects1 ={"Indonesia","English","Chinese"};
    String[] objects2 ={"Indonesia","English","Chinese"};
    
    ChoiceB1 = new ObjectChoiceField("From:", objects1,0,0)
                {
                    public int getPreferredHeight()
                    {
                        return 10;
                    }
    
                    public int getPreferredWidth()
                    {
                        return 240;
                    }
    
                    public void layout(int width, int height)
                    {
                        setExtent(getPreferredWidth(), getPreferredHeight());
                        super.layout(getPreferredWidth(), getPreferredHeight());
                    }
                };
                ChoiceB2 = new ObjectChoiceField("   To:", objects2,0,0)
                {
                    public int getPreferredHeight()
                    {
                        return 10;
                    }
    
                    public int getPreferredWidth()
                    {
                        return 240;
                    }
    
                    public void layout(int width, int height)
                    {
                        setExtent(getPreferredWidth(), getPreferredHeight());
                        super.layout(getPreferredWidth(), getPreferredHeight());
                    }
                };  
    
                HorizontalFieldManager fieldmanager = new HorizontalFieldManager(USE_ALL_WIDTH);
                fieldmanager.add(ChoiceB1);
                fieldmanager.add(ChoiceB2);
    
                    this.add(fieldmanager);
    

    One way you can do it like this,

     ChoiceB2 = new ObjectChoiceField("   To:", objects1,0,0)
     {
           public int getPreferredHeight()
            {
                return 10;
            }
            public int getPreferredWidth()
            {
                return 240;
            }
            public void layout(int width, int height)
            {
                setExtent(getPreferredWidth(), getPreferredHeight());
                super.layout(getPreferredWidth(), getPreferredHeight());
            }
       };
     HorizontalFieldManager fieldmanager = new HorizontalFieldManager(USE_ALL_WIDTH);
      fieldmanager.add(ChoiceB1);
      fieldmanager.add(ChoiceB2);
      this.add(fieldmanager);
      ChoiceB2.setEnabled(false);
      ChoiceB1.setChangeListener(new FieldChangeListener()
      {
        public void fieldChanged(Field field, int context)
        {
            ChoiceB2.setEnabled(true);
            }
    });
    
  • button would not update if you touch

    Hello

    Here is the screen of my problem:

    I can get the 'Run' button with the trackpad, and then click / touch and it works, but I would like to acquaire focus and get clicked just by the same touch to it she not currently have focus. Any way to achieve this?

    My constructor code:

    super(Screen.NO_VERTICAL_SCROLL);
    
            try
            {
                _odcSettings = new Settings();
    
                // Manager to lay out checkboxes
                ManagerSets vfm = new ManagerSets(USE_ALL_WIDTH);
                this.add(vfm);
    
                _iciNumbersField = new LabelField("I.C.I. Numbers: ");
                _iciNumbers011Field = new CheckboxField("011", _odcSettings.getPrefix1().length() > 0);
                _iciNumbersP1Field = new CheckboxField("+1", _odcSettings.getPrefix2().length() > 0);
    
                _autorunField = new LabelField("Autorun: ");
                _autorunGroup = new RadioButtonGroup();
                _autorunFieldOn = new RadioButtonField("Yes", _autorunGroup, _odcSettings.isAutostart());
                _autorunFieldOff = new RadioButtonField("No", _autorunGroup, !_odcSettings.isAutostart());
    
                _autosendField = new LabelField("Autosend password: ");
                _autosendGroup = new RadioButtonGroup();
                _autosendFieldOn = new RadioButtonField("Yes", _autosendGroup, _odcSettings.isSendDtmf());
                _autosendFieldOff = new RadioButtonField("No", _autosendGroup, !_odcSettings.isSendDtmf());
    
                _pwdField = new LabelField("Password: ");
                _pwdTextField = new PasswordEditField("", _odcSettings.getDtmf(), 16, PasswordEditField.FILTER_NUMERIC);
    
                _runField = new ButtonField("Run", Field.FIELD_HCENTER);
                _runField.setChangeListener(this);
    
                vfm.add(_iciNumbersField);
                vfm.add(_iciNumbers011Field);
                vfm.add(_iciNumbersP1Field);
                vfm.add(_autorunField);
                vfm.add(_autorunFieldOn);
                vfm.add(_autorunFieldOff);
                vfm.add(_autosendField);
                vfm.add(_autosendFieldOn);
                vfm.add(_autosendFieldOff);
                vfm.add(_pwdField);
                vfm.add(_pwdTextField);
                vfm.add(_runField);
    
            }  catch (Exception e) {
    
                e.printStackTrace();
            }
    

    Thank you!

    good tip.

    It worked for me:

      protected boolean touchEvent(TouchEvent event)    {     try       {         int index = vfm.getFieldAtLocation(event.getX(1), event.getY(1));
    
              switch(event.getEvent())          {             case TouchEvent.CLICK:                    if (vfm.getField(index) == _runField)                 {                     _runField.setFocus();                     _runField.forceClick();                   }             return true;           }
    
          } catch (Exception e) {           // TODO Auto-generated catch block            e.printStackTrace();      }
    
          return super.touchEvent(event);   }
    
  • Fields button

    Hi, I have the following code, in which case I would have some button fields made visible within the application. My code is as follows:

    This is a replacement code that corrects a number of problems with your code.  I suggest you compare that with your code and see if you understand what the parties are trying to do.

    You will find a reference very valuable.

    http://supportforums.BlackBerry.com/T5/Java-development/MainScreen-explained/Ta-p/606644

    Import net.rim.device.api.system.Bitmap;
    Import net.rim.device.api.system.Display;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.component.BitmapField;
    Import net.rim.device.api.ui.component.LabelField;
    Import net.rim.device.api.ui.container.MainScreen;
    Import net.rim.device.api.ui.container.VerticalFieldManager;
    Net.rim.device.api.ui import. *;
    SerializableAttribute public class AppLogoMainscreen extends form {}
    public AppLogoMainscreen() {}
    Bitmap logoBitmap = Bitmap.getPredefinedBitmap (Bitmap.EXCLAMATION);
    BMF BitmapField = new BitmapField (logoBitmap, BitmapField.FOCUSABLE)
    {
    protected boolean navigationClick (int status, int time)
    {
    createAndDisplayMainMenu();
    Close();
    Returns true;
    }
    };
    Add (BMF);
    }
    public void createAndDisplayMainMenu() {}
    Screen newScreen = new MainScreen(Manager.NO_VERTICAL_SCROLL |) Manager.NO_VERTICAL_SCROLLBAR);
    VerticalFieldManager backgroundManager = VerticalFieldManager(Manager.USE_ALL_WIDTH | nouveau Manager.USE_ALL_HEIGHT)
    {
    Bitmap logoBitmap2 = Bitmap.getPredefinedBitmap (Bitmap.EXCLAMATION);
    int imgWidth = logoBitmap2.getWidth ();
    int imgHeight = logoBitmap2.getHeight ();
    int imgXPos = 5;
    int imgYPos = 15;
    int imgTop = 0, imgLeft = 0;
    public void paint (Graphics graphics)
    {
    graphics.setBackgroundColor (Color.PALEGREEN);
    Graphics.Clear;
    graphics.setColor (Color.FORESTGREEN);
    graphics.fillRect (0, 0, 480, 80);
    graphics.fillRect (0.0, 20, 360);
    graphics.fillRect (460, 0, 20, 360);
    graphics.fillRect (0, 340, 480, 20);
    graphics.drawBitmap (imgXPos, imgYPos, imgWidth, imgHeight, logoBitmap2, imgLeft, imgTop);
    imgXPos = 425;
    graphics.drawBitmap (imgXPos, imgYPos, imgWidth, imgHeight, logoBitmap2, imgLeft, imgTop);
    Super.Paint (Graphics);
    }
    };
    ButtonField premierButton;
    ButtonField champButton;
    ButtonField div1Button;
    ButtonField div2Button;
    ButtonField confButton;
    premierButton = new ButtonField ("Premiership", ButtonField.CONSUME_CLICK);
    champButton = new ButtonField ("Champtionship", ButtonField.CONSUME_CLICK);
    div1Button = new ButtonField ("L1", ButtonField.CONSUME_CLICK);
    div2Button = new ButtonField ("Leauge 2", ButtonField.CONSUME_CLICK);
    confButton = new ButtonField ("Conférence", ButtonField.CONSUME_CLICK);
    backgroundManager.add (premierButton);
    backgroundManager.add (champButton);
    backgroundManager.add (div1Button);
    backgroundManager.add (div2Button);
    backgroundManager.add (confButton);
    LabelField labelField = new LabelField();
    backgroundManager.add (labelField = new LabelField ("Football Ground App", Field.FIELD_HCENTER)
    {
    protected void paint (Graphics g) {}
    int prevColor = g.getColor ();
    g.setColor (Color.WHITE);
    Super.Paint (g);
    g.setColor (prevColor);
    }
    });
    Font myFont = Font.getDefault (.derive(Font.BOLD |)) Font.ITALIC, 11, Ui.UNITS_pt);
    labelField.setFont (myFont);
    backgroundManager.add (labelField = new LabelField ("For BlackBerry", Field.FIELD_HCENTER)
    {
    protected void paint (Graphics g) {}
    int prevColor = g.getColor ();
    g.setColor (Color.WHITE);
    Super.Paint (g);
    g.setColor (prevColor);
    }
    });
    labelField.setFont (myFont);
    newScreen.add (backgroundManager);
    UiApplication.getUiApplication () .pushScreen (newScreen);
    }
    }

    Good luck...

  • Put 2 buttons side by side

    Hello

    I would like to put 2 buttons side by side on the same line in my GUI.

    I tried to do the following, but it didn't work:

    m_Button1 = new ButtonField(  "Back", FOCUSABLE | DrawStyle.ELLIPSIS |
                                  ButtonField.CONSUME_CLICK |
                                  FIELD_RIGHT);
    m_Button1.setChangeListener(this);
    
    m_Button2 = new ButtonField(  "Next", FOCUSABLE | DrawStyle.ELLIPSIS |
                                  ButtonField.CONSUME_CLICK |
                                  FIELD_LEFT);
    m_Button2.setChangeListener(this);
    
    HorizontalFieldManager mgrHrz = new HorizontalFieldManager();
    VerticalFieldManager mgrVertA = new VerticalFieldManager()
                       {
                            public int getPreferredWidth() {
                                return Display.getWidth() / 2;
                       }
                            };
    VerticalFieldManager mgrVertB = new VerticalFieldManager()
                       {
                            public int getPreferredWidth() {
                                return Display.getWidth() / 2;
                            }
                       };
    mgrVertA.add(m_Button1);
    mgrVertB.add(m_Button2);
    mgrHrz.add(mgrVertA);
    mgrHrz.add(mgrVertB);
    add(mgrHrz);
    

    Anyone know what I am doing wrong?

    THX.

    robybd wrote:

    Hello

    I would like to put 2 buttons side by side on the same line in my GUI.

    I tried to do the following, but it didn't work:

    Does anyone know what i am doing wrong?

    Thx.

    getPreferredWidth() do not get used the way you'd expect it.  You can override the sublayout() of these VFMs and USE_ALL_WIDTH.  Like this:

    ... = new VerticalFieldManager(USE_ALL_WIDTH) {
        protected void sublayout(int w, int h) {
            super.sublayout(Math.min(w, Display.getWidth() / 2), h);
        }
    };
    

    It should work better - try it!

  • Several buttons and a listener?

    Hello everyone, I basically have 3 buttons I need to have different actions. I tried to use separate listeners for each, but failed due to the error Illegalstateexception. Now, I tried to use if statements, but nothing happens when I click on them! Here is my code:

    import com.samples.toolkit.ui.container.VerticalButtonFieldSet;

    Import net.rim.device.api.ui.Field;
    Import net.rim.device.api.ui.FieldChangeListener;
    Import net.rim.device.api.ui.UiApplication;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.container.MainScreen;

    /**
    * A class that extends the class screen, which offers default standard
    * BlackBerry GUI applications behavior.
    */
    / public final class screen extends StartScreen
    {
    /**
    * Creates a new object StartScreen
    */
    public StartScreen()
    {
    Set the displayed title of the screen
    setTitle ("start screen");
    VerticalButtonFieldSet buttonSetOne = new VerticalButtonFieldSet (USE_ALL_WIDTH);
    buttonSetOne.setMargin (15,15,15,15);
            
    final ButtonField newButton = new ButtonField ("New revision Guide", ButtonField.CONSUME_CLICK);
    final openButton ButtonField = new ButtonField ("existing Open Guide", ButtonField.CONSUME_CLICK ");
    final exitButton ButtonField is new ButtonField ("Quit the Application", ButtonField.CONSUME_CLICK);.
            
    newButton.setMargin (5,5,5,5);
    openButton.setMargin (5,5,5,5);
    exitButton.setMargin (5,5,5,5);
            
    buttonSetOne.add (newButton);
    buttonSetOne.add (openButton);
    buttonSetOne.add (exitButton);
            
    Add (buttonSetOne);
            
    buttonSetOne.setChangeListener (new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    If (field is (newButton))
    {
    UiApplication.getUiApplication () .pushScreen (new ChooseLayout());
    }
    ElseIf (field == (openButton))
    {
    UiApplication.getUiApplication () .pushScreen (new GuideList());
    }
    If (field is (exitButton))
    {
    Close();
    }
    }
    } );
    }
    }

    When I tried to search for this problem, I saw that others had to make paintings for the buttons? Sorry, I'm just a beginner, and I have no idea what to change.

    Oh wow I didn't expect to be that simple! Right, so the three keys need to be addressed then, not the game real button... Thank you very much, Mr President!

  • Adding fields to a Manager different button clicks

    if (field == buttonField && label.equals("First")) {
                LabelField label = new LabelField("1");
            add(label);
            buttonField.setLabel("Last");}
    else if (field == buttonField && label.equals("Last")) {
            buttonField.setLabel("First");
            labelField2 = new LabelField("2");
            add(labelField2);
            labelField3 = new LabelField("3");
            add(labelField2);
    }
    

    Here is an example of my FieldChangeListener. It is clear what he does (even for me clear ). It simply adds fields - a field to the first button clicks - and two others to the second click.

    What I want to do is to add these fields to a manager - regardless of the vertical or horizontal, I just need to get the concept of how it should be done. The idea is to build a manager at the first click on a button and add labelField. When the second click occurs, I need this Manager to add an other field (s), for example as in my example code.

    Could you please indicate the way to do this? It might be very obvious of sth, yet lack me.

    EDIT: spelling errors, sorry...

    Edit2: Can it be reached via setter/getter?

    Setter / getter did the trick.

    if (field == buttonField && label.equals("First")) {
                getHFM();
                    LabelField label = new LabelField("1");
            setHFM().add(label);
            buttonField.setLabel("Last");
    }
    else if (field == buttonField && label.equals("Last")) {
            buttonField.setLabel("First");
            labelField2 = new LabelField("2");
            setHFM().add(labelField2);
            labelField3 = new LabelField("3");
            setHFM().add(labelField2);
    }
    
    public HorizontalFieldManager getHFM(){
            hfm = new HorizontalFieldManager(USE_ALL_WIDTH);
            add(hfm);
            return hfm;
    }
    public HorizontalFieldManager setHFM() {
            return hfm;
    }
    
  • Problems of creation of custom buttons

    Hello, I'm trying to create three custom buttons here in my application's main window.  I did a CustomButtonField class to try to change around the colors and size, but when I run my application no buttons appear in my application?  What I am doing wrong?

    Help, please.

    The main window class.

    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.FontFamily;
    import net.rim.device.api.ui.MenuItem;
    import net.rim.device.api.ui.Ui;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.Menu;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.decor.Background;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    
    public class MainPage_Recipes extends MainScreen
    {
    
        private VerticalFieldManager _manager ;
        CustomButtonField findButton;
        CustomButtonField submitButton;
        CustomButtonField aboutButton;
    
        public MainPage_Recipes()
        {
    
            try
            {
    
                 FontFamily Global = FontFamily.forName("BBGlobal Serif");
                 Font appFont = Global.getFont(Font.PLAIN, 8, Ui.UNITS_pt);
                 setFont(appFont);
    
                 Bitmap labelImage =  Bitmap.getBitmapResource("chef2.png");
    
                 add(new CustomLabelField ("Find A Recipe", Color.WHITE, 0xff0000, labelImage, Field.USE_ALL_WIDTH));
    
                 _manager = (VerticalFieldManager)getMainManager();
    
                 Background bg = BackgroundFactory.createSolidBackground(0x00DDDDDD);
                 _manager.setBackground(bg);
    
                 FieldChangeListener findCan = new FieldChangeListener()
                    {
                        public void fieldChanged(Field field, int context)
                        {
                            findRecipe find = new findRecipe();
                            UiApplication.getUiApplication().pushScreen(find);
                        }
                    };
                 FieldChangeListener submitCan = new FieldChangeListener()
                    {
                        public void fieldChanged(Field field, int context)
                        {
                            submitRecipe submit = new submitRecipe();
                            UiApplication.getUiApplication().pushScreen(submit);
                        }
                    };
                 FieldChangeListener aboutCan = new FieldChangeListener()
                    {
                        public void fieldChanged(Field field, int context)
                        {
                            aboutApp about = new aboutApp();
                            UiApplication.getUiApplication().pushScreen(about);
                        }
                    };
    
                 findButton = new CustomButtonField(" Find Recipe ", Color.WHITE, Color.BLACK, Field.FIELD_HCENTER);
                 findButton.setChangeListener(findCan);
                 submitButton = new CustomButtonField(" Submit Recipe ", Color.WHITE, Color.BLACK, Field.FIELD_HCENTER);
                 submitButton.setChangeListener(submitCan);
                 aboutButton = new CustomButtonField(" About ", Color.WHITE, Color.BLACK, Field.FIELD_HCENTER);
                 aboutButton.setChangeListener(aboutCan);
    
                 _manager.add(findButton);
                 _manager.add(submitButton);
                 _manager.add(aboutButton);
    
                 add(_manager);
    
            }
            catch(Exception e)
            {
    
            }
        }
        protected void makeMenu(Menu menu, int instance)
        {
    
            menu.add(_close);
            menu.add(_cancel);
    
        }
        private MenuItem _close = new MenuItem("Close", 110, 10)
        {
            public void run()
            {
    
                Dialog.alert("Goodbye!");
    
                System.exit(0);
    
            }
        };
        private MenuItem _cancel = new MenuItem("Cancel", 110, 10)
        {
            public void run()
            {
    
            }
        };
    
    }
    

    Class CustomButtonField:

    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Graphics;
    
    public class CustomButtonField extends Field
    {
        private String label;
        private int backgroundColor;
        private int foregroundColor;
    
        public CustomButtonField(String label, int foregroundColor,
                int backgroundColor, long style)
        {
            super(style);
            this.label = label;
            this.foregroundColor = foregroundColor;
            this.backgroundColor = backgroundColor;
    
        }
        public int getPreferredHeight()
        {
            return getFont().getHeight() + 8;
        }
    
        public int getPrefferedWidth()
        {
            return getFont().getAdvance(label) + 8;
        }
    
        protected void layout(int width, int height)
        {
            setExtent(Math.min(width, getPreferredWidth()), Math.min
                    (height, getPreferredHeight()));
    
        }
        protected void paint(Graphics graphics)
        {
            graphics.setColor(backgroundColor);
            graphics.fillRoundRect(1, 1, getWidth()-2, getHeight()-2, 12, 12);
            graphics.setColor(foregroundColor);
            graphics.drawText(label, 4, 4);
        }
        public boolean isFocusable()
        {
            return true;
        }
    }
    

    Help, please.

    Thank you

    Scientist

    Hi, I discovered very pblm is

    This.getPrefferedWidth usage and height, I think you will get it.

    protected void layout(int width, int height)     {     // TODO Auto-generated method stub        this.setExtent(this.getPrefferedWidth(),this.getPreferredHeight());   }
    

    Concerning

    Rakesh Shankar.P

  • editable text field and button is not editable when added to the Manager of the Horizontal

    I find layout, when I added the button and EditField horizontally, Manager, I'm not able to write something in the EditField and not able to click on the button

    public class MyStorySearch extends MainScreen
    {
    
        private VerticalFieldManager mainManager;
        private VerticalFieldManager subManager;
        private Bitmap _backgroundBitmap = Bitmap.getBitmapResource("a.png");
        private int deviceWidth = Display.getWidth();
        private int deviceHeight = Display.getHeight();
        LabelField lbl;
        ButtonField gobtn= new ButtonField("Go");
        HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.FOCUSABLE|Manager.EDITABLE);
        private Field editfild;
        Bitmap bitmapImage = Bitmap.getBitmapResource("storysearch.png");
        BitmapField fieldDemo;
    
        public MyStorySearch()
        {
            super(NO_VERTICAL_SCROLL);
            //this manager is used for the static background image
            mainManager = new VerticalFieldManager(
                              Manager.NO_VERTICAL_SCROLL |
                              Manager.NO_VERTICAL_SCROLLBAR )
            {
                public void paint(Graphics graphics)
                {
                    graphics.clear();
                    graphics.drawBitmap(0, 0, deviceWidth,
                             deviceHeight, _backgroundBitmap, 0, 0);
                    super.paint(graphics);
                }
            };
    
            //this manger is used for adding the componentes
            subManager = new VerticalFieldManager(
                             Manager.VERTICAL_SCROLL |
                             Manager.VERTICAL_SCROLLBAR )
            {
                protected void sublayout(int maxWidth, int maxHeight)
                {
                    int displayWidth = deviceWidth;
                    int displayHeight = deviceHeight;
    
                    super.sublayout( displayWidth, displayHeight);
                    setExtent( displayWidth, displayHeight);
                }
            };
    
            //add your component to this subManager
            lbl = new LabelField("SUNRAYS SEARCH", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            Font myFont = Font.getDefault().derive(Font.PLAIN, 10, Ui.UNITS_pt);
            lbl.setFont(myFont);
            subManager.add(lbl);
            subManager.add(new SeparatorField());
    
            editfild = new EditField(){
                protected void layout(int width, int height) {
                    setExtent(width*85/100, 30);
    
                };
            };
            editfild.setBorder( BorderFactory.createSimpleBorder( new XYEdges(2, 2, 2, 2),
                    new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK), Border.STYLE_SOLID));
            editfild.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
    
            hfm.add(editfild);
            hfm.add(gobtn);
    
            subManager.add(hfm);
    
            //add subManager over the mainManager
            mainManager.add(subManager);
    
            //finally add the mainManager over the screen
            this.add(mainManager);
        }
    }
    

    The following code shows an EditField and a button, and I can type in the EditField and click the button.  It is not perfect, but at least it works.

    I don't know what the problem is with your code.  I suggest review you my code, review your code and investigate things that are different.

    Two areas I would focus on your layout and the sublayout.  As stated in a previous post, if you must code a setExtent in a layout, then you should really think about creating your own Manager - I gave you links to do this several times.  And if you plan to use a standard field and to make it work properly, you must use the sublayout.  Here is a link to help you create custom fields:

    http://supportforums.BlackBerry.com/T5/Java-development/create-custom-fields/Ta-p/444962

    Edit:

    Thanks for the update of these discussions.

    And I'm sorry.   I forgot to paste the code...  Here, it is now...

            EditField editfild = new EditField(){
                protected void layout(int width, int height) {
                    super.layout(width*85/100, height);
                };
            };
            editfild.setBorder( BorderFactory.createSimpleBorder( new XYEdges(2, 2, 2, 2),
                    new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK), Border.STYLE_SOLID));
            editfild.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
            ButtonField gobtn= new ButtonField("Go") {
                protected boolean navigationClick(int status, int time){
                    Status.show("button clicked");
                    return true;
                }
            };
            HorizontalFieldManager hfm = new HorizontalFieldManager();
            hfm.add(editfild);
            hfm.add(gobtn);
            this.add(hfm);
    
  • two positioning buttons

    Hello

    I have a horizontalFieldManager h1 which USE_ALL_WIDTH, insidie this h1 is a verticalfieldManager with FIELD_BOTTOM style v1, this v1 has an another horizontalFieldManager h2 that contains two buttons, how can I do first button on the extreme left and the second button on the far right of h2, as shown in the following image

    feniljain wrote:

    You can set the Position of the two buttons in the sublayout of the Manager to add using setPositionChild.

    ... which means 'create your custom manager '. This is exactly what I suggested - but the example of "Advanced UI" has excellent examples of these managers. Study this code will teach you how to create these managers on your own. Moreover, one of the managers that I named is required to provide you with a solution.

  • Newbie question (button Bitmap/field/LabelField)

    Hi all

    I am creating a simple application 9700 which has a bitmap (480 * 360) as the image background, title, two separate labels and two buttons (side-by-side) but centered to the base of the form

    Code so far:

    Bitmap borderBitmap = Bitmap.getBitmapResource ("Background.png");
    VerticalFieldManager m = new VerticalFieldManager();
    m.setBorder (BorderFactory.createBitmapBorder (new XYEdges (1,1,1,1), borderBitmap));
          
           
    LabelField lf = new LabelField ("my title here," DrawStyle.HCENTER | ") LabelField.USE_ALL_WIDTH);
    FontFamily fontFamily [] = FontFamily.getFontFamilies ();
    Do police = fontFamily [1].getFont(FontFamily.CBTF_FONT |) Font.BOLD, 40);
    lf.setFont (do);

    LabelField lf1 = new LabelField ("\n1st line of text here.\n\n", DrawStyle.HCENTER: ") LabelField.USE_ALL_WIDTH);
    Police fnt1 = fontFamily [1].getFont(FontFamily.CBTF_FONT |) Font.BOLD, 36);
    LF1. SetFont (fnt1);
           
    Lff LabelField = new LabelField ("second line of text ici\n", DrawStyle.HCENTER: ") LabelField.USE_ALL_WIDTH);
    Police fontFamily = fnt2 [1].getFont(FontFamily.CBTF_FONT |) Font.BOLD, 36);
    lff.setFont (fnt2);
           
    Lf2 LabelField = new LabelField ("\n\n", DrawStyle.HCENTER |) LabelField.USE_ALL_WIDTH);
    Police fnt3 = fontFamily [1].getFont(FontFamily.CBTF_FONT |) Font.BOLD, 36);
    LF1. SetFont (fnt3);
           
    Add (m);
    m.Add (LF);
    m.Add (LF1);
    m.Add (LFF);
    m.Add (LF2);

    BFM HorizontalFieldManager = new HorizontalFieldManager (Manager.HORIZONTAL_SCROLL);
    ButtonField acroos is new ButtonField ("Yes", Field.FIELD_HALIGN_MASK);.
    ButtonField bNo = new ButtonField ("No.", Field.FIELD_HALIGN_MASK);
    BFM. Add (bYes);
    BFM. Add (BNO);
    Add (BFM);

    ------------------------------

    The problem I have is that the basis of the bitmap is missing. The buttons to remain on the left of the dialog box, but the base of the peak is not displayed as the background of the horizontal field Manager is not transparent.

    Click on the button I want to display a dialog box with a label text, which will be just Dialog.Alert ("Some Text");

    How do I change the color of the text of the title, 1 & 2 lines of text, please?

    Also, does anyone have examples of code for a splash screen before loading the dialog box above? I need to have the home screen display a logo which will be 480 * 100 pixels. Have seen an example of a startup but can't seem to get by (too new to the coding).

    Thanks in advance

    To center the buttons at the bottom and let the background show through, try this:

    HorizontalFieldManager bfm = new HorizontalFieldManager(FIELD_HCENTER);
    ButtonField bYes = new ButtonField("Yes");
    ButtonField bNo = new ButtonField("No");
    bfm.add(bYes);
    bfm.add(bNo);
    VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_WIDTH);
    vfm.add(bfm);
    Background trans = BackgroundFactory.createSolidTransparentBackground(0,0);
    bfm.setBackground(trans);
    vfm.setBackground(trans);
    add(vfm);
    

    To change the color of text, you can use a RichTextField place a LabelField, or you can create a subclass LabelField.

  • Buttons and landscape Manager

    Hello

    I would like to align two buttons again to each other using the HorizontalFieldManager.

    The button one must be on the side more to the left of the screen, another on the right side most of the screen.

    I tried this code, but the two buttons are on the left, attached to each other:

         HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
         hfm.add(new ButtonField("Left Button",ButtonField.FIELD_LEFT));
         hfm.add(new ButtonField("Right Button",ButtonField.FIELD_RIGHT));
         add(hfm);
    

    The 'left' button has style: ButtonField.FIELD_LEFT, it should be left.

    The button "right" as the style of ButtonField.FIELD_LEFT and should be on the right - but is not.

    Can someone help me on this?

    Thank you.

    Three frames just to put two buttons seems a bit excessive.

    private class MyHorizontalFieldManager extends HorizontalFieldManager {
    
        private ButtonField leftButton;
        private ButtonField rightButton;
    
        public MyHorizontalFieldManager() {
    
            super( USE_ALL_WIDTH );
    
            ButtonField leftButton = new ButtonField( "Left" );
            setLeftButton( leftButton );
            add( leftButton );
    
            ButtonField rightButton = new ButtonField( "Right" );
            setRightButton( rightButton );
            add( rightButton );
        }
    
        protected void sublayout( int maxWidth, int maxHeight ) {
    
            super.sublayout( maxWidth, maxHeight );
    
            int width = getWidth();
    
            //            ButtonField leftButton = getLeftButton();
            //            if (leftButton != null && equals( leftButton.getManager() )) {
            //
            //                int x = 0;
            //                int y = 0;
            //                setPositionChild( leftButton, x, y );
            //            }
    
            ButtonField rightButton = getRightButton();
            if (rightButton != null && equals( rightButton.getManager() )) {
    
                int x = width - rightButton.getWidth();
                int y = 0;
                setPositionChild( rightButton, x, y );
            }
        }
    
        private ButtonField getLeftButton() {
    
            return leftButton;
        }
    
        private void setLeftButton( ButtonField leftButton ) {
    
            this.leftButton = leftButton;
        }
    
        private ButtonField getRightButton() {
    
            return rightButton;
        }
    
        private void setRightButton( ButtonField rightButton ) {
    
            this.rightButton = rightButton;
        }
    }
    

Maybe you are looking for

  • How can I stop mail that is NOT marked as spam to be sent to my Junk folder?

    How can I stop mail that is NOT marked as spam to be sent to my Junk folder? In some cases, it's the messages that were once reported as junk that I scored is NOT undesirable. in other cases, it's the messages that have never been reported as spam, b

  • U2713HM, grilled?

    Hi guys, I bought a Dell U2713HM monitor exactly 1 month ago. I used it regularly without problems until this. When I turned on the screen today, there is no display at all, just a black screen with a grey ring important along the border of the scree

  • Flash Builder 4.7, Flex 4.9.1 and AIR 3.4 for Playbook?

    Hello IM, develop an application using Flash Builder 4.7, Flex 4.9.1 and AIR 3.4 for multiple platforms. My question is when I deploy to Playbook, is mentioned the configuration can cause problems or not? What should I do to ensure that my apps runni

  • Error code: 0x8007232B - cannot activate Windows.

    I'm not... Despite having windows activation product key & using the product key, it is not working.it that says "error code: 0x8007232B" & "DNS name does not exist. I'm not... Despite having windows activation product key & using the product key, it

  • Red eye tool

    Red eye not showing in the patch tool tool, reset defaults only shows always do not