ObjectListField with VerticalFieldManager

I hv parsed xml and data related to the objectlistfield... get m o/p as lines... I want columnwise... How do I? I wana create 10 columns...

Resolved

Tags: BlackBerry Developers

Similar Questions

  • ObjectListField, with the help of needed managers

    Hey guys, so this is what I have:

    I have a screen that adds a VerticalFieldManager which adds an ObjectFieldList where the elements are managers. each Manager has a BitmapField and 3 LabelFields (can change to RichTextFields, I doubt that it changes anything however).

    now, the result of adding this just ObjectListField gives me lines of '. com.rim.packages'package_name ".". " "Manager_name'" instead of view manager itself

    I don't know if I have to manually draw the frames with the function drawListRow or I am doing something wrong

    any help, suggestions, comments are much appreciated!

    ObjectListField is a convinience ListField, who can take any list objects and provides basic drawing functionality. The text to be included must come from the toString() method of the object.

    So what you're trying to do, will not work with the ObjectListField.

    You should take a look in the knowledge base and research for an article titled something like "how to implement the interface user advanced". That comes with a lot of fields to improve and code of field managers.

  • Static background with VerticalFieldManager

    Hello, I would like to set up a background image for my application, where it must not move even when the user scrolls... I found the following code on the internet for this type of Manager:

    package com.kruger.workflow.gui;
    
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class BGVerticalFieldManager extends VerticalFieldManager {
        Bitmap mBgBitmap = null;
        int mBgWidth = -1;
        int mBgHeight = -1;
        int mBgX = -1;
        int mBgY = -1;
    
        public BGVerticalFieldManager(Bitmap background) {
            super(USE_ALL_WIDTH | USE_ALL_HEIGHT | VERTICAL_SCROLL
                    | VERTICAL_SCROLLBAR);
            mBgBitmap = background;
            mBgWidth = mBgBitmap.getWidth();
            mBgHeight = mBgBitmap.getHeight();
            mBgX = (Display.getWidth() - mBgWidth) >> 1;
            mBgY = (Display.getHeight() - mBgHeight) >> 1;
    
        }
    
        protected void paintBackground(Graphics graphics) {
            paintBackgroundBitmap(graphics);
            invalidate();
        }
    
        private void paintBackgroundBitmap(Graphics graphics) {
            if (null != mBgBitmap) {
    
                int x = mBgX
                        + getHorizontalScroll();
    
                int y = mBgY
                        + getVerticalScroll();
                 graphics.drawBitmap(x, y, mBgWidth, mBgHeight, mBgBitmap, 0, 0);
            }
        }
    }
    

    However, does not work... I get the following results:

    As you can see the image begins to scroll backwards...

    The use of this Manager is:

    Bitmap bitmap = Bitmap.getBitmapResource("1.jpg");
            add(mContainer = new BGVerticalFieldManager(bitmap));
            for (int i = 0; i < 100; i++) {
                mContainer.add(new LabelField("List item #" + String.valueOf(i)));
                mContainer.add(new SeparatorField());
            }
    

    Although no result so far... When debugging the code, I noticed that this line:

    if (null != mBgBitmap) {
    
                int x = mBgX
                        + getHorizontalScroll();
    
                int y = mBgY
                        + getVerticalScroll();
                 graphics.drawBitmap(x, y, mBgWidth, mBgHeight, mBgBitmap, 0, 0);
            }
    

    Always returns 0 for both a XY is not assumed that getVerticalScroll or getHorizontalScroll must return aware of gap between the container Manager.? How can I fix this?

    Thank you very much.

    I use a VOR with USE_ALL_HEIGHT and NO_VERTICAL_SCROLL and set the background image to it (using the BackgroundFactory since 5.0)

    in this optimization of resources, I put a second, but it work with VERTICAL_SCROLL. The listfield (or any content) is put there.

  • problem with verticalfieldmanager?

    _vmanager[0]=new VerticalFieldManager();
             row[0]=new HorizontalFieldManager();
            _lablefield[0]=new CustomLableFeild("Account No:");
            _vmanager[0].add(_lablefield[0]);
            _vmanager[0].add(new CustomManager(0));
            _lablefield[25]=new CustomLableFeild("(If Applicable)");
            _vmanager[0].add(_lablefield[25]);
            row[0].add(_vmanager[0]);
            row[0].add(new SpacerField(0,0));
            _vmanager[1]=new VerticalFieldManager();
            _textbox[0]=new TextBoxField(118,28);
            _vmanager[1].add(_textbox[0]);
            row[0].add(_vmanager[1]);
    

    I am trying to add textfield for this account only, but it did not add.

    pls help me if anyone knows?

    He could have added. If either CustomLableFeild or CustomManager uses the full display width, then _vmanager [0] uses the full display width. In this case, the rest of the fields of _row [0] is positioned beyond the right edge of the screen. Without horizontal scrolling, it's almost as if these fields were not there.

    What classes CustomLableFeild and CustomManager extend? What style value when they are built?

  • Strange: Objectchoicefield and ObjectListField in Gridfieldmanager - navigation problem

    Hi @all,

    I have a very strange problem, because running Simulator runs as I would have liked, but the device, the navigation is bad:

    running OS 5.0.0.42 3 on device (BB9700) and the Simulator

    1. the building screen

    2. put verticalfieldmanager on it that contains the background image

    3. put gridscreenmanager (with a column - the problem is with more then one column, too) on the first position of the vfm

    4. turn objectchoicefield with 5 points on the 1st row of the gsm

    5. put the objectlistfield with 5 points on the second line of gsm

    Program running in the Simulator:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    I can scroll up and down, and everything's fine.

    Program running on the device:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    So far so good:

    When I scroll down to the olf, all things are working properly. For example, point 4 a now focus.

    Now, if I try to go back in the OLF, it should go back to article 3 of the olf, but this is the leap into objectchoicefield. After that, if I try to go back to the objectlistfield, it jumps directly to point 4, which he came before.

    If I don't put the objectchoicefield in the first row, everything works fine.

    What can I do?

    I did something wrong?

    All ideas are very appeciated.

    Thanks in advance.

    CUA

    Michael

    Well, I found it.

    I made a mistake in the application of my own gridfieldmanager navigationmovement method.

    What is already strange: I used the same gridfieldmanager within 2 screens in my application. First screen was working fine, the second one was bad. Same content in both screens.

    Sorry for that.

    Thank you for all.

    CUA

    Michael

  • ObjectListField separators

    I have an ObjectListField with a few dozen items in the list. I want to have a thin line that separates each item, similar to display it contacts and messages. What is the right way to do this?

    To come back to this a few weeks late.  I had to replace graphics and add the following line of code:

    graphics.drawLine(0, y, Display.getWidth(), y);
    
  • Too many Threads exception

    Hello everyone, hope you can help me in this question since I'm having a time really bad when using threads on my request. Basically, I am during the extraction of data from the internet using Basic authentication Http. for this, I created a style waiting screen that will show while downloading data from the Internet... all right, but when you make a reminder for updating an ObjectListField with the results of the operation (public void didReceivedResponse (byte [] data) on the example)... my code starts fadlng son as it is inside a loop for... I really have no idea what's going on... even on eclipse in debugging it continues execution of the run method of the HttpHelper class. These are the classes that I am referring:

    package login.example;
    
    import java.util.Vector;
    
    import login.example.model.Noticias;
    import login.example.networking.HttpHelper;
    import login.gui.WaitScreen;
    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.component.LabelField;
    import net.rim.device.api.ui.component.ObjectListField;
    import net.rim.device.api.ui.component.SeparatorField;
    import net.rim.device.api.ui.container.MainScreen;
    
    import com.kruger.exceptions.ParserException;
    import com.kruger.networking.interfaces.HttpDelegate;
    import com.kruger.parsing.NoticiasJsonParser;
    
    /**
     * A class extending the MainScreen class, which provides default standard
     * behavior for BlackBerry GUI applications.
     */
    public final class LoginExampleScreen extends MainScreen implements
            FieldChangeListener, HttpDelegate {
        /**
         * Creates a new MyScreen object
         */
    
        ObjectListField objectField;
        WaitScreen waitScreen;
        ButtonField loginButton;
        Vector listaNoticias;
    
        public LoginExampleScreen() {
            // Set the displayed title of the screen
            setTitle("MyTitle");
    
            loginButton = new ButtonField("Start");
            loginButton.setChangeListener(this);
            add(loginButton);
            add(new SeparatorField());
            add(new LabelField("Noticias"));
            objectField = new ObjectListField(){
    
                protected boolean navigationClick(int status, int time) {
                    if(objectField.getSize()==0) return true;
                    Noticias noticiaSeleccionada = (Noticias) objectField.get(objectField, objectField.getSelectedIndex());
                    UiApplication.getUiApplication().pushScreen(new DetailScreen(noticiaSeleccionada));
                    return true;
    
                }
    
            };
            objectField.setEmptyString("No se han encontrado resultados",
                    LabelField.VCENTER);
            objectField.setChangeListener(this);
            add(objectField);
    
        }
    
        public void didReceivedResponse(byte[] data) {
            if (data != null) {
                waitScreen.hideScreen();
                NoticiasJsonParser noticiasParser = new NoticiasJsonParser();
                    try {
                        noticiasParser.initialize(data);
                        Vector noticias = noticiasParser.readObjects();
                        listaNoticias=noticias;
                        UiApplication.getUiApplication().invokeLater(new Runnable() {
    
                            public void run() {
                                updateNoticiasList();
    
                            }
                        });
    
                    } catch (ParserException e) {
    
                        e.printStackTrace();
                    }
    
            }
    
        }
    
        private void updateNoticiasList(){
    
            Object[] noticiasList = new Object[listaNoticias.size()];
            listaNoticias.copyInto(noticiasList);
            objectField.set(noticiasList);
        }
    
        public void didReceiveUnauthorizedResponse() {
            waitScreen.hideScreen();
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    UiApplication.getUiApplication().pushScreen(new LoginScreen());
                }
            });
    
        }
    
        public void fieldChanged(Field field, int context) {
                waitScreen = new WaitScreen();
                HttpHelper helper = new HttpHelper(
                        "http://localhost:8088/simple-login/rest/noticias", null,
                        this);
                helper.setOperation(HttpHelper.GET);
                helper.start();
    
        }
    }
    
    package login.example.networking;
    
    import java.io.DataInputStream;
    import java.io.IOException;
    
    import javax.microedition.io.HttpConnection;
    
    import login.example.ApplicationPreferences;
    import net.rim.device.api.io.Base64OutputStream;
    import net.rim.device.api.io.transport.ConnectionDescriptor;
    import net.rim.device.api.io.transport.ConnectionFactory;
    import net.rim.device.api.system.DeviceInfo;
    import net.rim.device.api.util.ByteVector;
    
    import com.kruger.networking.interfaces.HttpDelegate;
    
    public class HttpHelper extends Thread {
    
        private byte[] postData;
        private String url;
        private String operation;
        private HttpDelegate delegate;
        private HttpConnection connection;
    
        public static final String GET = "GET";
        public static final String POST = "POST";
        private ConnectionFactory connectionFactory = new ConnectionFactory();
    
        public HttpHelper(String url, byte[] postData, HttpDelegate delegate) {
            this.url = url;
            this.postData = postData;
            this.delegate = delegate;
        }
    
        public HttpHelper(String url, byte[] postData, HttpDelegate delegate,
                String operation) {
            this.url = url;
            this.postData = postData;
            this.delegate = delegate;
            this.operation = operation;
        }
    
        public void run() {
            if (operation == null)
                delegate.didReceivedResponse(null);
            if (operation == GET) {
                ConnectionDescriptor connectionDescriptor = connectionFactory
                        .getConnection(url);
                DataInputStream din = null;
                final ByteVector responseBytes = new ByteVector();
                int responseCode;
                connection = (HttpConnection) connectionDescriptor.getConnection();
                String loginInfo = ApplicationPreferences.getInstance().getUsername()+":"+ApplicationPreferences.getInstance().getPassword();
                String encodedLogin;
                try {
                    encodedLogin = new String(Base64OutputStream.encode(
                            loginInfo.getBytes(), 0, loginInfo.length(), false,
                            false), "UTF-8");
                    connection.setRequestProperty("Authorization", "Basic "
                            + encodedLogin);
                    //Send the Device PIN number
                    connection.setRequestProperty("DeviceId", String.valueOf(DeviceInfo.getDeviceId()));
                    responseCode = connection.getResponseCode();
                    switch (responseCode) {
                        case HttpConnection.HTTP_UNAUTHORIZED:
                        case HttpConnection.HTTP_FORBIDDEN: {
                            Thread delegateThread=new Thread(){
                                public void run(){
                                    delegate.didReceiveUnauthorizedResponse();
                                }
                            };
                            delegateThread.start();
                            connection.close();
                            return;
                        }
                    }
                    din = connection.openDataInputStream();
                    int i = din.read();
                    while (-1 != i) {
                        responseBytes.addElement((byte) i);
                        i = din.read();
                    }
                } catch (IOException e) {
                    System.out.println(e.getMessage());
                    e.printStackTrace();
                    return;
                } finally {
                    try {
                        connection.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                if (responseBytes != null && responseCode != 0) {
                    Thread delegateThread=new Thread(){
                        public void run(){
                            delegate.didReceivedResponse(responseBytes.toArray());
                        }
                    };
                    delegateThread.start();
                    return;
    
                }
            } else if (operation == POST) {
                return;
            }
        }
    
        public String getOperation() {
            return operation;
        }
    
        public void setOperation(String operation) {
            this.operation = operation;
        }
    
    }
    
    package login.gui;
    
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.system.GIFEncodedImage;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.container.FullScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class WaitScreen extends FullScreen {
    
        private GIFEncodedImage _image;
        private int _currentFrame;
        private int _width, _height, _xPos, _yPos;
        private AnimatorThread _animatorThread;
        private Bitmap backgroundBitmap;
    
        public WaitScreen() {
            super(new VerticalFieldManager(), Field.NON_FOCUSABLE);
            //TODO: Correctly handle icons
            GIFEncodedImage img = (GIFEncodedImage) GIFEncodedImage.getEncodedImageResource("loading6.agif");
    
            // Store the image and it's dimensions.
            _image = img;
            _width = img.getWidth();
            _height = img.getHeight();
            _xPos = ((Display.getWidth() - _width) >> 1);
            _yPos = ((Display.getHeight() - _height) >> 1)+50;
            // Start the animation thread.
            _animatorThread = new AnimatorThread(this);
            _animatorThread.start();
            UiApplication.getUiApplication().pushScreen(WaitScreen.this);
            //TODO: handle correctly background
            backgroundBitmap=Bitmap.getBitmapResource("Wallpaper1.png");
          }
    
        protected void paintBackground(Graphics graphics) {
            super.paintBackground(graphics);
            graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap, 0, 0);
        }
    
        protected void paint(Graphics graphics) {
            super.paint(graphics);
                    // Draw the animation frame.
                    graphics
                      .drawImage(_xPos, _yPos, _image
                        .getFrameWidth(_currentFrame), _image
                          .getFrameHeight(_currentFrame), _image,
                        _currentFrame, 0, 0);
        }
    
        protected void onUndisplay() {
            _animatorThread.stop();
        }
    
        private class AnimatorThread extends Thread {
            private WaitScreen _theField;
            private boolean _keepGoing = true;
            private int _totalFrames, _loopCount, _totalLoops;
            public AnimatorThread(WaitScreen _theScreen) {
                    _theField = _theScreen;
                    _totalFrames = _image.getFrameCount();
                    _totalLoops = _image.getIterations();
    
            }
    
            public synchronized void stop() {
                    _keepGoing = false;
            }
    
            public void run() {
                    while (_keepGoing) {
                            // Invalidate the field so that it is redrawn.
                            UiApplication.getUiApplication().invokeAndWait(
                              new Runnable() {
                                    public void run() {
                                            _theField.invalidate();
                                    }
                            });
                            try {
                              // Sleep for the current frame delay before
                              // the next frame is drawn.
                              sleep(_image.getFrameDelay(_currentFrame) * 10);
                            } catch (InterruptedException iex) {
                            } // Couldn't sleep.
                            // Increment the frame.
                            ++_currentFrame;
                            if (_currentFrame == _totalFrames) {
                              // Reset back to frame 0
                              // if we have reached the end.
                              _currentFrame = 0;
                              ++_loopCount;
                              // Check if the animation should continue.
    
                            }
                    }
            }
    
        }
    
        public void hideScreen(){
            _animatorThread.stop();
            UiApplication.getUiApplication().invokeAndWait(new Runnable() {
    
                public void run() {
                    UiApplication.getUiApplication().popScreen(WaitScreen.this);
    
                }
            });
        }
    }
    

    Please any help would be great... or at least an explanation of what I'm doing wrong... I'm new to using Threads. Thank you very much.

    Note that the fieldchanged event is triggered not only by the user, but also by changes programmatically, for example when you add an item to a listfield.
    You can check the context to be! = http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/FieldChangeListener.html#PR... to filter them.

  • Ugh... Requirement: A TimerTask making an HTTP call, parsing JSON, insertion into a SQLite database.

    How to implement a better design of the following?

    I have a UiApplication which has the following requirements:

    1. A static timer in the class that extends UiApplication.
    2. A class that extends screen and contains a class internal which extends TimerTask.
    3. When a user accesses to the screen, the TimerTask is started with:
      _timer.schedule(MyTimerTask, 1000, 15000);
      
    4. The first step is to do an HTTP call and return a valid JSON object which varies in structure - that is, it has a wide variety of paintings and JSON objects.
    5. The second step is to analyze and insert the JSON object values into tables in a SQLite database. The SQLite file is on the map.
    6. The third step is to read the updated SQLite table, loop through the table and build my ObjectListFields with the new values, and attach them to a VerticalFieldManager.
    7. The fourth step is to replace the old VerticalFieldManager with the new VerticalFieldManager and push the screen pop and updated then the current screen - so I have a stack of view high one single layer.

    Now the logic is actually on the spot, but since the TimerTask must cover every 15 seconds, I am a memory leak in all directions.

    To try to solve this problem, I have:

    • Cancelled the TimerTask with the onObscured and the onUiEngineAttached (false).
    • Restart the TimerTask with onExposed and onUiEngineAttached (true).
    • My DatabaseConnection closed the finally statement.

    However, when I look at the objects in Eclipse BlackBerry objects View when the TimerTask is not running, I still see 1 ~ 4 TimerTask objects and 1 ~ 4 DatabaseConnection objects.

    TimerTask both DatabaseConnection have a static instance (I don't have several entry points) with the following in my class that extends UiApplication:

    public static Timer _timer = new Timer();
    public static Database db = null;
    

    I attribute db when I need it with a call to DatabaseFactory.open within the class that extends TimerTask.

    Now that the business logic is correct, how to improve the design so I don't not leaking memory in every way?

    The statement closed the database is being called in, because I can set a breakpoint and see it has reached.

    Instead of onObscured/etc, you can move them into onVisibilityChange (boolean) is only in one place. Cancel your existing TimerTask before running a new, or at least check the TimerTask reference if you are only creating a... not just passing 'New TimerTask' in the calendar method without being able to track this object reference.

  • Best game API to use... I need help

    I really don't care about the issue of portability as most of the APIs are fairly easy to swap from one phone to another, and since the great player outside BB is the iphone and there's no similarity, portability is really not really a problem... except perhaps for the Android... TO BE DETERMINED.

    Conversations, I had on a previous question, I came to the conclusion that we should try to use the javax API and only when necessary to go with the blackberry API. However, I notice that there is no equivalent control field, with the exception of forms.

    What it really seems to boil down to is that you prefer to use. I think that I have to use the approach of Blackberry Ecran and I have the choice to use the screen as a Bitmap (using getGraphics()) and draw or I can even create a Bitmap field and call Graphics.create (bitmap) to get a graphics context in which I can get, and here I can even combine my small bitmap with the fields of regular control... This seems to be the most adaptable.

    So, during the passage of cmdlets midlets, I think that applications using the screens are much more flexible.

    It seems that I can use a moped with lcdui and a canvas, which is OK for the games but useless if you want to use buttons gauges and stuff like that. The alternative, that's what I said above, and this seems much more flexible.

    Any comments? Am I wrong?

    I am at a junction point where I am about to be really productive, and I just need to know which way to go. I'll be churning of code once I know which way to go... so a little, I need to be told to go with. If I'm just above, then if I need all the controls I'll go with the blackberry app.

    If it's just a game or something with a canvas, then I can just go with the approach of the midlet.

    I just need someone that has produced more commercial software to let me know if I'm right or not.

    Thank you people.

    -Donald

    I only develop with the APIs of BB. We have some experiences of hobby with j2me Polish and a few standard tests to j2me, but restrictions are just much worse and you do not have access to many features related to BB.

    That said, the native BB UI is almost as ugly as j2me. Android and IPhone are miles ahead of him and you can see RIM trying to find at least with some basics, such as rounded corners, etc.
    Give your first app a good part of the extra hours and think out of the box. You will need to develop some components that need to be reusable and allow you to have a beautiful generic application in a short time.
    It begins with bitmap-buttonfields, color labelfields and other product managers to layout custom with some functions of border and objectlistfields with built-in logical treatment until bar framesets that use a fixed navigation and change only the part of the screen.

    Usually, you want to improve the appearance of your application, the next time - make sure you have a prepared concept for your library or you end up with incompatible versions for your older projects.

  • Set the Bitmap image as wallpaper

    Hi guys, sorry pattées English goofy

    I have an image in my resources, and I want to add that the image as wallpaper. How to handle this.

    I tried with VerticalFieldManager and substitute the reproductives of paint... I can't get that

    your help is highly appreciated

    Thank you

    vinoopraj

    Please use HomeScreen.setBackgroundImage (Sring uri), but it is available on JDE4.7

  • question about the torch slider 9800

    package mypackage;
    
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Hashtable;
    
    import javax.microedition.lcdui.Font;
    
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.Ui;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.TextField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class AnswersScreen extends MainScreen {
    
        LabelField title = new LabelField();
    
        TextField message = new TextField(TextField.NON_SPELLCHECKABLE);
    
        VerticalFieldManager verticalManager;
    
        public AnswersScreen(int selectedIndex) {
    
            super(NO_VERTICAL_SCROLL);
    
            Hashtable properties = getProperties();
            System.out.println("AnswerScreen");
            setBanner(new BitmapField(Bitmap.getBitmapResource(ScreenManager.getStringProperty("answersscreen.banner"))));
    
            verticalManager = new VerticalFieldManager(USE_ALL_HEIGHT | VERTICAL_SCROLL) {
    
                protected void paint(net.rim.device.api.ui.Graphics graphics) {
                    graphics.clear();
    
                    graphics.setColor((67 << 16) + (67 << 8) + 67);
                    graphics.fillRect(0, 0, ScreenManager.getPositionAtKey("answersscreen.verticalfieldmanager.fillrect.width"),
                            ScreenManager.getPositionAtKey("answersscreen.verticalfieldmanager.fillrect.height"));
                    graphics.setColor(Color.WHITE);
    
                    super.paint(graphics);
    
                }
    
                protected void sublayout(int maxWidth, int maxHeight) {
                    super.sublayout(maxWidth, maxHeight);
    
                    setPositionChild(title, ScreenManager.getPositionAtKey("answersscreen.title.x"),
                            ScreenManager.getPositionAtKey("answersscreen.title.y"));
                    layoutChild(title, ScreenManager.getPositionAtKey("answersscreen.title.width"),
                            ScreenManager.getPositionAtKey("answersscreen.title.height"));
    
                    setPositionChild(message, ScreenManager.getPositionAtKey("answersscreen.message.x"),
                            ScreenManager.getPositionAtKey("answersscreen.message.y"));
                    layoutChild(message, ScreenManager.getPositionAtKey("answersscreen.message.width"),
                            ScreenManager.getPositionAtKey("answersscreen.message.height"));
    
                }
            };
    
            title.setFont(this.getFont().derive(Font.STYLE_BOLD, 9, Ui.UNITS_pt));
            title.setText((selectedIndex + 1) + " " + (String) properties.get("pergunta" + (selectedIndex + 1)));
    
            message.setText((String) properties.get("resposta" + (selectedIndex + 1)));
            message.setFont(this.getFont().derive(Font.STYLE_BOLD, 7, Ui.UNITS_pt));
            message.setEditable(false);
    
            verticalManager.add(title);
            verticalManager.add(message);
    
            add(verticalManager);
    
        }
    
        private Hashtable getProperties() {
            Class classs = null;
            try {
                classs = Class.forName(this.getClass().getName());
            } catch (ClassNotFoundException e) {
    
                e.printStackTrace();
            }
            InputStream stream = classs.getResourceAsStream("/fraseologia.properties");
            PropertiesUtil properties = new PropertiesUtil();
            try {
                properties.load(stream);
            } catch (IOException e) {
    
                e.printStackTrace();
            }
            return properties.getProperties();
        }
    
    }
    

    Hi all

    Im trying to encode a scrolling screen with verticalFieldManager to run on the torch 9800 and I had this problem:

    When I put the screen of NO_vertical_scroll, scrolling style do not even work I put the textfield object in a verticalfieldmanager with the Vertical_scroll style. his works in the curve 8900 and 8520.

    If I put the screen of vertical_scroll style, the screen allows an infinite scrolling with white background.

    This code run on 4.6.1 because this should work for curve 8520, torch 9800 and 8900.

    Thanks in advance!

    I solved! I removed the overrided method sublayout and put the padding to solve spaces.

  • How to add the png file in another png file

    Greetings

    How to add another png to a png file

    for example: I have the png file 1) 320 * 480

    second is 2) very small png file

    I want to add the small png like this button (320 * 480) of the png file, how can I do

    Help, please

    account s

    Anthony singh

    It is not much more left to do, really:

    1. create your custom - bitmap button class copy most of the project advanced user interface.

    2. create your personalized with background image - again, Manager copy most of "adding background... picture." "with all the changes that you deem necessary.  You can replace HorizontalFieldManager with VerticalFieldManager, for example, according to your needs. Also, if you've read this article, visit again and take a look at the note at the bottom - I just added a. It might not be relevant today, but may be useful later - I answered enough questions here on the forums, so people do not experience this problem.

    3 create an instance of your custom Manager to enlarge the image as the parameter - let's call him myBgMgr, for example. Add myBgMgr to your screen.

    4. Add the new BitmapButtonField (smallerImage,...) to myBgMgr.

    That's all!

  • Problem with the ObjectListField

    Hello

    I have problems with the method getSelectedIndex() ObjectListField.
    Supposedly, when there is no index selected, it returns-1. But how come it always returns the index of the last element?

    To illustrate, I created my own dialog that has similar functionality to the "device window select" Bluetooth BB application. I have an ObjectListField and a Cancel button. What I did simply, is to change the label of the button to show the selected index. I have attached my sample code below.

    public class MyDialog extends dialog
    {
    private ObjectListField m_list;
    private ButtonField m_btn;

    public MyDialog)
    {
    Super ("Select Device:", null, null, 0, Bitmap.getBitmapResource ("bluetoothIcon.PNG"), Manager.FOCUSABLE);

    m_List = new ObjectListField();
    m_btn = new ButtonField ("Cancel", Field.FIELD_HCENTER);
    m_List.set (new String [] {"first", "second"});

    Add (m_List);
    Add (m_btn);
    }

    protected boolean navigationClick (int status, int time)
    {
    m_btn.setLabel (Integer.ToString (m_List.getSelectedIndex ()));

    Returns true;
    }
    }

    Can someone help me on this problem? Is there something wrong with my code, or is the buggy API? All I want to do is to return an index of-1 if there is no selected item in the list.

    Also, I tried the isFocus() method to check if the list is being concentrated, it always returns false even if the list is OBVIOUSLY being focused. I'm running out of options on how to determine the solution to this problem. Help, please!

    Thank you very much.

    @jacylan - I do not use isFocus() to determine if the ListField is net.  Take a look at the following code, I think that with this, you can force-1 when the ListField is not the point.

        protected boolean navigationClick(int status, int time)
        {
            int selectedIndex = m_list.getSelectedIndex();
            boolean listInFocusOption1 = false;
            if ( this.getLeafFieldWithFocus() == m_list ) {
                listInFocusOption1 = true;
            }
            boolean listInFocusOption2 = false;
            if ( m_list.isFocus() ) {
                listInFocusOption2 = true;
            }
            m_btn.setLabel(Integer.toString(selectedIndex) + ":" + listInFocusOption1 + ":" +listInFocusOption2);
    
            return true;
        }
    
  • VerticalFieldManager with a fixed size: scroll issue

    Hello

    I try to have a full screen UI in a fix header (some fields Manager) and a scrollable (a list of custom field) content. The idea is to emulate a kind of drop-down list.

    To do this, I made a custom VerticalFieldManager that accept a maxHeight (the screen height - the height of the header).

    I had the following problems:
    -The scroll arrows are not displayed (never)
    -On OS 4.7 (Storm), I can scroll further down that last point to have nothing on my screen, but the header.

    My code need to compile with the JDE 4.2.1 & 4.7 and running on Pearl and storm. (at least I might have two versions of this class)

    I suspect that the two problems are related. I probably do something wrong. I looked at a few example/forum and always find a similar solution.
    Can Guys tell me what I did wrong?

        /**
         *  custom class, so we can set a max height (to keep the header visible)
         */
        class InvVerticalFieldManager extends VerticalFieldManager{
        private int maxHeight = 0;
    
        InvVerticalFieldManager(int _maxHeight){
          super(
           //this provoc an "empty scrollable zone" on Storm
           // but if you don't put it, on other OS, the vertical manager does not scroll at all.
           Manager.VERTICAL_SCROLL
    
           | Manager.VERTICAL_SCROLLBAR
           );
          maxHeight = _maxHeight;
        }
    
        protected void sublayout(int width, int height){
                super.sublayout(width, getPreferredHeight());
                setExtent(width, getPreferredHeight());
        }
    
        public int getPreferredWidth() {
            return Graphics.getScreenWidth();
        }
    
        /**
         * allow the manager to use all the given height. (vs auto Height)
         */
        public boolean forceMaxHeight = false;
        public int getPreferredHeight() {
          if (forceMaxHeight) return maxHeight;
          int m = super.getPreferredHeight();
          if (m > maxHeight) m = maxHeight;
          return m;
        }   
    
        ////////////////////////////////////////////////////////////////////////////
    
        protected boolean isUpArrowShown(){
          //TODO: does not seem to work (4.2.1 emulator & 4.5 device). (called with good return value but the arrows are not painted)
          int i = getFieldWithFocusIndex();
          //Trace("isUpArrowShown " + i);
          return i > 0;
          // note: algo not correct, cause the up arrow will be visible event when no field are hidden.
          //       but not so bad, so the user "know" that he can go up.
        }
    
        protected boolean isDownArrowShown(){
          int i = getFieldWithFocusIndex();
          return i < getFieldCount();
        }
    
        ////////////////////////////////////////////////////////////////////////////
        // note : since 4.6 you can use
        // http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/ui/decor/Background.html
    
        public int myBackgroundColor = 0xffffff;
        protected void paint(Graphics g){
            g.setBackgroundColor(myBackgroundColor);
            // Clears the entire graphic area to the current background
            g.clear();
            super.paint(g);
        }
    
        }
    

    any help is welcome.

    I got it!

    the solution to add the header as raw material and the other the field in a factory of value for money. BUT, you must call 'super (NO_VERTICAL_SCROLL)' in the constructor of the form.

  • Need to call ObjectListField.setSelectedIndex (int) with holding EventLock

    Hello

    first of all I'm new here and I want to thank the forum a LOT as he already has helped me by just searching. Now I am facing a problem where I can't fiond one equivalent to the.

    I have read through several totorials how manipulate GUI (EventThread) and also through several topics on this site, so the idea of how doing this is familiar to me.

    I use a third-party library that is implemented with an Observer pattern to send events. On obtaining a particular event, I have to call the UI thread and display information on a screen changed.

    Now I do the error familiar "UIEngine" accessible without holding the lock of the event inside the invokeLater/invokeAndWait. How can this happen? Is it possible that it depends on the third my library event thread since it's the thread that calls?

    However, I found that with the help of snchronized (Application.getEventLock) {...}, no error is thrown, but ObjectListField.setSelectedIndex (int) is not working properly. It actually changes the index but do not display the change on the screen. So is it possible that changes in the return buffer, but not in the display buffer? Also tried to invalidate the entire list or only the selected item and was updated with

    UiApplication.getUiApplication () .updateDisplay (). Without success.

    Any suggestion would be appreciated. Thanks in advance.

    DoubleCheck if the object is really the same. singletons can be tricky in blackberry java!

Maybe you are looking for

  • Unknown device on High Definition Audio Bus on Satellite M200

    Hello I'm working on a Satellite M200 laptop customers, the Realtek sound card is not installed.I even ran the restore partion and made a return to the factory settings and all I get is * unknown device on high definition Audio Bus * listed in the ti

  • Apple tv Gaming Controller

    I use Apple TV 4th generation in Turkey. There is only one controller games available is Kontorland YEAR-200, which is a controller of the IFM. It works with all other apple products (IE. IPad, Iphone) without any problem. Apple TV 4th generation eve

  • HP Officejet 6500 wireless

    When I use my document feeder I have a line on copies, faxes and scans

  • the printer queue

    Bought a new copy and the old does not work. Have documents in the print queue for the old printer that I need to print, but can't figure out how to transfer those to the print queue of the printer?

  • Lines scrolling too quickly at the start to the top

    After that I turned on my laptop HP Pavilion dv6568se two lines of scrolling are quickly, but before Windows starts. I don't have the time to read these two lines until they disappear. I can read only F1, F2, F8, F9 & F10.   Is there a way to slow do