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.

Tags: BlackBerry Developers

Similar Questions

  • Background with custom layout error

    Hello

    I have a screen that I put to use a background image, and I created a custom presentation of HFM

    but when I use my layout on the screen I get an 104 error not caught illegal argument exception.

    When I delete the code for the background image, the screen will display properly with my custom layout,

    How can I use my custom with a background image layout.

    Thank you

    Hello

    I ran my application with debugging and here is a screenshot of the debug window when my application crashes.

    He seemed to have solved the problem now my custom layout and and background displays correctly, I changed my background don't not to scale, can someone help explain this that when wrong when using Background.REPEAT_SCALE_TO_FIT

    Bitmap VO = Bitmap.getBitmapResource ("splashscreen.png");
    Background _bg = BackgroundFactory.createBitmapBackground (VO,
    Background.POSITION_X_LEFT, Background.POSITION_Y_TOP,
    ( Background.REPEAT_SCALE_TO_FIT) ;
    VerticalFieldManager _scrMngr = (VerticalFieldManager) getMainManager();
    _scrMngr.setbackground (_bg);

    Bitmap VO = Bitmap.getBitmapResource ("splashscreen.png");
    Background _bg = BackgroundFactory.createBitmapBackground (VO,
    Background.POSITION_X_LEFT, Background.POSITION_Y_TOP,
    ( Background.REPEAT_NONE) ;
    VerticalFieldManager _scrMngr = (VerticalFieldManager) getMainManager();
    _scrMngr.setbackground (_bg);

  • HP Jet 7: My hp stream 7 tab stucks in the configuration of the window has... (a picture of blue background with whi

    My hp stream 7 tab stucks in the configuration of the window has... (a picture of a blue background with white letters) its does not accept the entry while I also use an aotg with the mouse cable. So please help me its very urgent

    Try to hold the low volume button when the power and press the F11 key to enter the menu of system recovery.

  • When taking picture with the light in the background with the camera back from my iPhone more than 6 s, there is a clear blue colour square (a bit like a reflection of the light) will appear.

    When taking picture with the light in the background with the camera back from my iPhone more than 6 s, there is a clear blue colour square (a bit like a reflection of the light) will appear.

    someone has an idea of what's going on?

    The blue square is the area of the camera is in point and exposure on.

    Tap on the area actually taking a picture of. For example, if you take a photo of someone int eh the room and the bottom is very light (or dark), tap on the face of the person to turn to that.

    See it-> http://iphonephotographyschool.com/how-to-use-iphones-camera-app/

  • Static translation with Port forwarding

    Hello

    I have a scenario in which two public ip address (the one with HTTP requests & other with query SMTP/SSL for OWA) must be translated on a single inside the ip of the ISA Server in the DMZ. Please suggest which is the best practice. I know that we cannot do a NAT because the two addresses ip cannot translate into one. Use the static translation with forwarding Port of best practice to access the ISA server for OWA? What is the best security that can be applied at the moment? I'm going to redirect only requests to port 80,8080,25,443,110. I'll also create access list to only allow as these ports.

    I need to recommend this to a client. Please advice.

    Thank you

    Kevin

    Port forwarding is the best way to go here. As you already know, you can enter a static for two outside IP pointing to an inside (or vice versa), but statically mapping ports just will be fine. Similarly, simply allow these ports in your incoming ACL and you'll be good to go.

    You want something like the following:

    static (inside, outside) tcp XXX1 80 a.a.a.1 80

    static (inside, outside) XXX1 8080 a.a.a.1 8080 tcp

    static (inside, outside) tcp x.x.x.2 25 a.a.a.1 25

    static (inside, outside) tcp x.x.x.2 110 a.a.a.1 110

    public static x.x.x.2 a.a.a.1 443 tcp (indoor, outdoor) 443

    list of allowed inbound tcp access any host XXX1 eq 80

    list of allowed inbound tcp access any host XXX1 eq 8080

    list of allowed inbound tcp access any eq 25 x.x.x.2 host

    list of allowed inbound tcp access any host x.x.x.2 eq 110

    list of allowed inbound tcp access any host x.x.x.2 eq 443

    Access-group interface incoming outside

    where x.x.x. [1 | 2] is your public IP address and a.a.a.1 your home server.

  • How to darken the edges after removing white background with Magic Wand too.

    Hi guys!

    Is there a way to darken the edges on an image after having removed the white background with the magic wand tool?

    I want to talk about an image where there all different colors... skin tones, hair tones etc...

    When you remove the white background, it leaves sort of a white glow around the image... How better to handle this?

    booke56

    Please refer Darkening picture edges - tutorial Photoshop

    See also get rid of those Pesky edge Halos in Photoshop

    ~ Assani

  • How ca I remove the yellow background (with red vertical lines) all my videos to my preview screen?

    In recent weeks, all of my videos (even those created before) now have a yellow background with red vertical lines when I stop (only when I stop). That, when I export, it creates the vertical issues with colors.

    I finally had someone from the tech group to answer! Here's the answer: the issue you report is a known problem / bug in first 2015 on mac 10.11 with Nvidia graphics cards. I advise you to change the rendering engine for 'Software only' for this problem.

    and it worked! Hooray!

  • Develop mode shows a blue background with a white box and white diagonals.

    When I opened the fashion picture, I chose is not displayed. Is rather a blue background with a white box and white diagonals. Can anyone help? Everything else seems to work. If I choose the before and after seeing the photo shows at the front but the blue screen in the after.

    Support cat informed me that my graphics card is not taken in charge used Edit > preferences > Performance Unchecked "use the graphics processor.

  • IM wondering how would you do a page scrolling on a static background?

    I watched this and its great https://www.YouTube.com/watch?v=qRC5-GKYa_Q but I'm wondering how would you do that on a static background?

    Hi Paul,.

    This is done using Parallax scrolling. Back ground should not be a problem to achieve this. Please try it and let us know if you face any problem.

    Kind regards

    Aish

  • pdf files are displayed on white background with horizontal and vertical lines blue

    Hello

    When you open in Adobe Pro pdf saved locally, they are displayed on a white sheet with blue squares (see below). This is true for all the PDF files I tried to open it. If the pdf document is opened in a Web browser, and then it appears on the white paper with no squares. Once it is saved locally and open, it appears as shown below. How can I get all the pdf appear on a white background with no blue stripes? It's distraction very during playback! If irrelevant, I installed windows update yesterday.

    Press Ctrl + U.

  • Is it possible to create a transparent background with a cutout of jpeg?

    Is it possible to create a transparent background with a cutout of jpeg? I want to know how to cut an object in a jpeg file, so it can be used in a Web site.

    No jpeg file format does not support transparency. Try the PNG format.

  • change a static TF with ACE

    HI - is it possible to address a static textfield in a movieClip with ACE? I want to change the color and the selecability of the text with Actionscript (because I have about 50 of them and won't open each mc to get to textfield.) The mc has an instance name, but natuarally, isn't the textfield object.

    I used the static text because there are fewer problems with the font on different computers. Now, on the road that I have to make these changes. If I'm screwed?

    TIA expertise.

    JL

    You cannot use as access a static text with as2.

    You can with as3, but what you can do with static text seems very limited.

  • "Clip" correct for background with round edge

    Hi all. I'm having a problem with a round border and a round bottom. If you look at the code below, you will see that I have a border specified with a radius of 5. If I run the present, the bottom sticks outside the border. If I put also the context in which a radius of 5, it still seems wrong since the outside of the border turns to purple while I expect it to be the red light. If I change the bottom radius of 4 then the inside of the border is not quite equal to the background.

    How to define a border and just tell the background needs to be 'cut' by it?

    Thank you, Nick.
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.layout.FlowPane;
    import javafx.stage.Stage;
    
    public class RoundTest extends Application {
        @Override
        public void start(Stage stage) throws Exception {
            FlowPane flowPane = new FlowPane();
            Scene scene = new Scene(flowPane, 500, 500);
            flowPane.setStyle("-fx-padding: 10;");
            Label label = new Label("Hello");
            label.setStyle("-fx-border-color: red; -fx-border-radius: 5; -fx-background-color: blue;");
    //        label.setStyle("-fx-border-color: red; -fx-border-radius: 5; -fx-background-color: blue; -fx-background-radius: 5;");
            flowPane.getChildren().add(label);
            stage.setScene(scene);
            stage.show();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }

    It's actually sort of a difficult question to answer well.

    The standard style sheet caspian.css for JavaFX 2.2 almost does not use of the borders.
    The standard controls of the Caspian have things that look like borders or edges highlighted, but they are almost always implemented by stratified environments.
    For example, a ring around a button is a blue background which is placed under the bottom of the key, making the ring to resemble a border, even if it is not.

    I don't really know why the bottom layer approach was chosen on a border + approach background. The possible reasons are:
    -It is easier.
    -its performance is superior.
    -It provides a better visual experience.
    Maybe it's one or all of the above.

    Nevertheless, I think that there was probably a good reason why the bottom layer approach has been chosen, then you would probably better stick.
    One of the advantages of this approach are there are many similar examples in the caspian.css that you can copy from and use.

    An example of string of css style for your sample using boundary layers app could be something like:

    -fx-padding: 1;  -fx-background-insets: 0, 1;  -fx-background-radius: 5, 5;  -fx-background-color: firebrick, forestgreen;
    

    Playing with combinations of laminates circles, padding and background-inserts you can get, borders around your controls which can be either entirely encapsulated in layout standard of your control or outside of it (like the focus ring), so that when you add something as a focus ring around your control, it is not movement of the control on the screen - it really just surrounds the control.

    An updated version of your application example that uses it is below:

    import javafx.application.Application;
    import javafx.scene.*;
    import javafx.scene.control.Label;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    
    public class RoundTest extends Application {
      @Override public void start(Stage stage) throws Exception {
    //    System.setProperty("prism.lcdtext", "false");
        StackPane stackPane = new StackPane();
        Scene scene = new Scene(stackPane, 500, 500, true);
        stackPane.setStyle(
            "-fx-background-color: cornsilk;"
          + " -fx-border-insets: 10;"
          + " -fx-border-color: rgba(128, 128, 128, 0.5)"
        );
        Label label = new Label("Hello");
        label.setStyle(
    //        "-fx-padding: 5;"
    //      + " -fx-background-insets: 0, 5;"
    //      + " -fx-background-radius: 5, 5;"
            "-fx-padding: 1;"
          + " -fx-background-insets: 0, 1;"
          + " -fx-background-radius: 5, 5;"
          + " -fx-background-color: firebrick, forestgreen;"
          + " -fx-text-fill: whitesmoke;"
        );
    //    label.setScaleX(5);
    //    label.setScaleY(5);
        stackPane.getChildren().add(new Group(label));
        stage.setScene(scene);
        scene.setCamera(new PerspectiveCamera());
    
        stage.show();
      }
    
      public static void main(String[] args) { launch(args); }
    }
    

    Now for other questions you raise:

    If I run the present, the bottom sticks outside the border

    Yes, the background properties border radius and radius are independent, so if you use a rounded edge, you must also use a rounded background or the background will extend beyond the corners of the border.

    If I put also the context in which a radius of 5, it still doesn't seem right because outside of the border turns to purple while I expect it to be the red light

    JavaFX 2.2 uses anti-aliasing just about all of it is rendered (and even something else for lcd called sub-pixel text rendered in some cases). Your edge is a single pixel wide. If the border is not exactly sitting on a pixel boundary, it will mingle in the background. Even if the sides of the border to sit exactly on the boundary of the pixel, when the border turns corners, smoothing algorithms are suddenly stirring the corner of the border and the background around the inside edge of the corner.

    You have chosen a green background and a red border. When you mix these two colors, you get purple (which is what's happening).

    I don't know of anyway to turn on or turn off rendering of smoothing for the JavaFX scene graph objects (perhaps something to do that might come along for the ride with the support of Java 8 3D scene graph).

    Regardless, you probably want to anti-aliasing for your rendering anyway. If you develop your application, knowing that anti-aliasing will happen. To do this, choose colors that marry well when anti-aliasing. Caspian done by deriving a lot of foreign background colors inner background colors (i.e. any relief or darkening of the border). It works well because they have the same mix of basic RGB, just in different portions component, so anti-aliasing mixes seamlessly. Full of choice colors at opposite ends of the RGB Spectrum as red and blue translates jarring mixtures as violet. Even if anti-aliasing is not in question, your eyes can play you tricks and have trouble seeing clearly the boundary between this kind of colors due to the strange optics of the eyes.

    Another strategy to alleviate the nasty mix is to use more pixels, for example instead of a one pixel border, use a border of two pixels - mixture of anti-aliasing will be much less noticeable. Using the strategy of greater pixel works very well in conjunction with the new screens of higher resolution (the so-called retina displays), where the pixels themselves are so small that the human eye is unable to distinguish the pixels and how they blend together.

    All that being said - your original example with rounded edges and bottom doesn't look too bad to me :-)

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

    Another question that I fell on during the test, it is that there is a css attribute - fx-border-style, that can have the values of centered, inside and outside, and when I tried to put I got messages like:

    WARNING: declaration of com.sun.javafx.css.parser.CSSParser style of analysis error CSS online ' - fx - padding: 1; -fx-background-inserts: 0, 1; -fx-background-RADIUS: 5, 5; -fx-background-color: brick refractories, forestgreen; -fx-border-style: inside; -fx-text-fill: whitesmoke;' of javafx.scene.Node$22@1bd5d8ab: not supported the of 'inside' when parsing "border - fx - style' to [1 138].

    The css reference note to guide the border feature copy of the w3c background and border features, but there is no nut, silverside, border style centered in the w3c css reference, so I guess that there is a mistake in the JavaFX 2 css documentation it around which is taken in charge and what is implemented of the w3c css reference. Note that I'm not really that JavaFX css processing must correspond to the reference of css of w3c that I find the system complicated and difficult to understand w3c.

    http://docs.Oracle.com/JavaFX/2/API/JavaFX/scene/doc-files/cssref.html#region
    http://www.w3.org/TR/CSS3-background/#border-style

    Perhaps as borders in css do not seem to be used much in JavaFX, the issue of documentation is not such a big.

  • Images of sensitive background with Media Queries

    Hello

    I am creating a mobile Web site in Dreamweaver and want to use a picture that will change with different device widths.  I use queries of media with background images.  My problem is that, so that background images to display, I need to assign a height to the div.  When the image is reduced height static rest, leaving the white space below.  So it will be below the image space white sink and look bad.  Is it possible to use several images with queries media bearing sensitive height?  Thank you!

    @media screen and (max-width: 1024px) {}

    {#mainImage}

    background-image: url (.. / images/mainImageLarge.jpg);

    background-repeat: no-repeat;

    background-position: top center;

    background-size: 100%;

    height: 272px;

    border-top-width: 3px;

    border-top-style: solid;

    border-bottom-color: #FFF;

    }

    }

    @media only screen and (max-width: 480px) {}

    {#mainImage}

    background-image: url (.. / images/mainImageMed.jpg);

    background-repeat: no-repeat;

    background-position: top center;

    background-size: 100%;

    height: 107px;

    border-top-width: 3px;

    border-top-style: solid;

    border-bottom-color: #FFF;

    }

    }

    @media only screen and (max-width: 320px) {}

    #mainImage img {}

    background-image: url (.. / images/mainImageSmall.jpg);

    background-repeat: no-repeat;

    background-position: top center;

    background-size: 100%;

    height: 150px;

    border-top-width: 3px;

    border-top-style: solid;

    border-bottom-color: #FFF;

    }

    }

    As in this example:

    http://ALT-Web.com/FluidGrid/fluid-4.html

    METHOD:

    Insert 2 images - one for desktops and one for mobile.  Assign classes to each image.

    class = "desktop" src = "desktop_image.jgp" / > "

    class 'mobile' = src = "mobile_image.jpg" / >

    In your CSS, use display: no and display: block to show/hide.

    .desktop {}

    Display: block;

    }

    .mobile {}

    display: none;

    }

    / Special rules for mobile devices * /.

    @media only screen and (max-width: 480px) {}

    . Desktop {display: none}

    .mobile {display: block}

    }

    Feel free to put your break points however you like.

    Nancy O.

  • Add static background pictures to all frames of animated gif

    First of all, I'm not a regular Fireworks. I use it when I have to do something (especially web optimazations). I would use it more, but frankly in many cases, the user interface is not intuitive for any other adobe makes.

    Here's my problem...

    I have to Add (not substitute) static type of basis to ALL frames (states) in an animated gif with Fireworks (with alpha), the image of the final product will be a part in the animation of web edge... Details

    I have a lively seq of a spinning object has been created in 3ds max and rendered as a png with alpha seq.

    I opened the SEQ "as an animation" in fireworks. I set the pace. He plays very well. So far so good...

    I imported an image I want to be BEHIND the seq animated on all chassis. I tried to put it on a layer of void behind, I tried to put it on its own layer behind, but it shows that on the first image (State).

    I tried to use 'share with all States', but it replaces images SEQ already on "States" rather than add behind them as in the arrangement of layers.

    So first, is this possible and if so, how?

    Secondly, why is it then process against intuitive in fireworks? I mean if the layer is behind something, then it should be a click on a single button or checkbox etc to say 'show on all chassis (States)', you know like any other adobe product brands. Same "ready image" made more sense than that.  My thought process that has been since I needed to find in fireworks to create and optimize the gif that I should be able to put it together again but it turns out to be much more difficult than expected. I guess I can just composite my elements in AE (which is a piece of cake compared to the Fireworks) and will then return to SEQ another think I import to fireworks to create optimized gif. While I'm a fan of the concept of 'creative suite', one of my biggest complaints about "suite" is the lack of oversite master so keyboard and fundimental UI concepts features common, shortcuts are evenly across all the apps so it works as a 'suite' and not just a collection of separate applications. I know that demanding that all applications of following certain rules would slow development, in the long run it would make it much easier for the end-user to spend more time being "creative" and less time trying to understand why something does not work as it does in other applications. Just my $.02

    Thanks for any help and or explanation

    Joel H

    From your original animation, create a new layer and then import the image into it. Don't forget to give your layer a distinct name not already in use by another layer. Don't bother trying to drag your layer to the position of the bottom of the layer stack. It's a nightmare. Instead, leave the layer to the second lowest position and then drag the layer of background (or background) above him.

    Once the image has been added to its own layer and this layer has been named and properly positioned, you are ready to share with other States. Select the layer in the layers, ctrl-click for the context menu panel, then choose layer part in the States.

Maybe you are looking for

  • jwplayer does not

    Hi all After the upgrade to Safari 9.0.3, suddenly jwplayer has a strange behavior. The film is gray and the transport bar is now on top. Any suggestions? See you soon,. GJ

  • Retrieve the product key after decommissioning

    Hello! A "friend" of mine took my Lenovo Y500 ideapad with an installation of Windows 8 and downgraded to Windows 7. Unfortunately, the guy has destroyed the recovery partition in the process. My question: is it still possible to recover the product

  • No number key on T440s?

    I'm only enter data digital and discovered that there is no on the new designed keyboard num lock key. Also, it has no description on this subject in the manual. I put something to use? Can anyone help?

  • "Successful" installation of Vista SP1 is not successful

    My gateway GT5662 crashed and was finally restored, but lacked the SP1. Automatic update of Windows was used and it was assumed that it was on. But auto update he kept raising. After 'successfully' several times installing the Vista SP1, it does not

  • Cannot be used on Windows 7 Sony bluetooth headset because the driver is missing.

    Original title: Question about bluetooth drivers Hello I have a problem with my Sony bluetooth headset on my Macbook bootcamp Win 7. My helmet model is MDR-10RBT. My Win 7 detected the headset in the bluetooth device section, but I can't use it becau