Move a Rectangle

Hi, I have developed a screen that has a rectangle that appears at the bottom using the following code:

package com.rim.breakoutapp;

import net.rim.device.api.system.Characters;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class Play extends MainScreen {
    public Play()
    {
        super(NO_VERTICAL_SCROLL);
        setTitle(new LabelField ("Play Game Screen", Field.FIELD_HCENTER));
        setStatus(new LabelField ("Block Breakerz Breakout Game ©", Field.FIELD_HCENTER));

        VerticalFieldManager vfm = new VerticalFieldManager(Manager.FIELD_HCENTER|USE_ALL_WIDTH|USE_ALL_HEIGHT) {
            protected void paint(Graphics graphics) {
                graphics.setBackgroundColor(0x0000A2E8);
                graphics.clear();

                int x = ((Display.getWidth() - 100) / 2);
                int y = (Display.getHeight() - 100);
                graphics.setColor(Color.FORESTGREEN);
                graphics.fillRect(x, y, 100, 20);
                super.paint(graphics);
            }
        };
        add(vfm);
    }

}

My question is, how will I be able to make the rectangle move on the screen left and right depends on the direction of the trackball or a touch?

Thank you

I made small changes to your code and it works...

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.TouchEvent;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class Play extends MainScreen {
    int x;
    int y;
    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Play()
    {
        super(NO_VERTICAL_SCROLL);
        setTitle(new LabelField ("Play Game Screen", Field.FIELD_HCENTER));
        setStatus(new LabelField ("Block Breakerz Breakout Game ©", Field.FIELD_HCENTER));

        VerticalFieldManager vfm = new VerticalFieldManager(Manager.FIELD_HCENTER|USE_ALL_WIDTH|USE_ALL_HEIGHT) {
            protected void paint(Graphics graphics) {
                graphics.setBackgroundColor(0x0000A2E8);
                graphics.clear();

                int x = getX();
                int y = getY();
                graphics.setColor(Color.FORESTGREEN);
                graphics.fillRect(x, y, 100, 20);
                super.paint(graphics);
            }
        };
        add(vfm);
    }

    protected boolean touchEvent(TouchEvent message) {
        if(message.getEvent()==TouchEvent.MOVE)
        {
            x=message.getX(1);
            y=message.getY(1);
            invalidate();
        }
        return super.touchEvent(message);
    }

}

Tags: BlackBerry Developers

Similar Questions

  • InDesign: how to move a rectangle object with its content?

    Hello

    I'm developing an indesign extension with flash builder and extension builder cs 2.

    When I move a rectangle object that contains an image whose ownership geometricBounds image does not move and is no longer visible...

    How to move a rectangle with its content?

    Thank you

    Simon

    Use rectangle.move)

  • Move the rectangle at the top (homepage of the navigation bar)

    Hello.

    I am a new user of Adobe Muse and found no answers yet, probably due to lack of know me the correct terms for what I want to do.

    I want to create a Web site with an initiation site that looks like this:

    Muse_MoveRectangle1.jpg

    By clicking on one of the links (link1, link2, link3), I want to switch to one of these sites, but for a more modern experience, want to have white move rectangle to the top of the site and if possible to reorganize the sitename to the top left and maybe let it reduce a bit and have the link1, link3 move upwards to the right and 50% scale.

    Muse_MoveRectangle2.jpg

    Such a thing is possible, even without scaling within the muse or a code I can paste in it?

    Thank you very much in advance for pointers, even if only how such a thing is called and for me to go hunting more.

    If you talk about change of the object on the page once the page opens in the browser and without any mouse click on white bar should go the top of the page, then you may need to use the animation for that.

    Others that the scrolling animation only may be used.

    You can take a look here, and if you find something similar you can download and use:

    EXCHANGE | Adobe Muse CC

    Thank you

    Sanjit

  • find features in InDesign, I want a known rectangle coordinates can move that I would be happy if you write for this scprit

    find features in InDesign, I want a known rectangle coordinates can move

    I would be happy if you write for this scprit

    If you want to get the contact information, select a rectangle and try the code below:

    var rectangleBounds = app.selection[0].geometricBounds;//array
    alert(rectangleBounds[0]);
    alert(rectangleBounds[1]);
    alert(rectangleBounds[2]);
    alert(rectangleBounds[3]);
    

    If you want to move the rectangle.

    app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
    app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
    app.selection[0].move([0,10])//x-axis and y-axis
    

    Vandy

  • How to access a PDF file imported inside a rectangle and move

    Hi, I have the following code which puts a PDF file inside a rectangle var f = new File ("C:/pdf.pdf");    var doc = app.activeDocument;  var thepdf = doc.pages [0] .rectangles [0] .place (f, false);  doc.pages [0] .rectangles [0] .fit (FitOptions.FILL_PROPORTIONALLY);  Now I want to spend "thepdf" (which is the type of PDF object), but I can only find a way to move the rectangle around it. I need to move the inner rectangle (PDF), as I would with the direct Selection tool. is this possible?

    Yes. It is possible.
    The PDF file placed inside the rectangle is the graphics object [0] of the rectangle.
    Or, if search you the collection of links, the parent of this link. The parent of the parent that is the container, the rectangle object.

    myRectangle.graphics[0].move(/*insert your arguments here*/)
    

    Move the PDF file inside. When the move() method could have different arguments:

    Adobe InDesign CS6 (8,0) object model JS: graph

    Uwe

  • Why do I see «Editing sub-items on AutoShapes...» "whenever I move a rounded rectangle?

    Hello

    Whenever I move a rectangle rounded around the page, I see this dialog box:

    Screen Shot 2013-01-03 at 9.13.54 AM.png

    And more often then I can't modify certain properties of the form, for example, the rounding of the corners. Is there a way to avoid this?

    Thank you.

    Annoying, isn't?

    You should not experience this problem if you use the pointer (black arrow) tool to move the smart shapes on the canvas. But you will encounter it if you use the Subselection (white arrow) tool. Where I tend to run in this alert message is at this time I have option to copy an object, like the Option key also acts as a shortcut to the Subselection tool, and I find accidentally subselect of a part of the active form.

    The fact that you cannot change a property as subsequently rounded corner is exactly what this dialog box tries to warn you. If this is the case, you can click Undo has the first appearance of such a dialogue and re-think this that the tool you are currently using.

  • What field / class should I use to create a mobile rectangle?

    Hello

    I want to create a rectangle that people can focus on, and when it's to the point, people can scroll to the left or right to move the rectangle left and right. What field or the object or the class should I use?

    Thank you!

    I noticed that too.  However, since the BB is double buffered, I'm not sure you save anything in fact.  As you move your rectangle, you would have to redraw where it was anyway.

    This treatment is all done in the paint of the screen method so effectively treats the screen as a large Bitmap.

    If you have created a field for yourself, you could add that field to a Manager, then use this Manager to place this field on the screen and then move.  In fact, it would be fairly simple.  But to do this, you must create a manager who knew how to move the field, then move the field whenever you wanted to move.  Then painting everything would be done by another person (i.e. the Manager and the field.)  In my opinion, costs, overhead and complication just to draw a rectangle of mobile, is excessive.  However if you plan to put different data in the Rectangle, such as text and therefore might want to use a real field of BB to help with its interior design.  To help you with this, I suggest you only consider these three KB articles:

    What is - BlackBerry UI hierarchy
    Article number: DB-00111
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...
     
    -How to create a custom handler for a screen presentation
    Article number: DB-00117
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800508/...

    -Creating custom fields
    Article number: DB-00120
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

  • Rectangle back on top of text lines when I achor the rectangle in the text.

    I would like to draw attention to a few lines of text in a large text frame. I put a rectangle around these lines, apply a nice color and move the rectangle behind the text. So far do good. I want to anchor the text rectangle if the rectangel with the text up and down. When I do that the rectangle automatically moves over the text again and the text is invisable. How can I stop this from happening?

    Anchor the value inline or above line position and twist the space before and after

  • I did a shape layer, and it moves in After Effects CS4.

    Hello

    I'm working on a project that has a lot of masks and shape layers to frame masks in After Effects CS4. For example the timeline that I am focusing is 3 seconds long; There is 2 keyframes in the shape layer (vertical rectangle), key frames are 3 seconds gap and are at the same position (511.1,89.5). If I go to the beginning of the seconds 3 press the space bar and let him play for some reason any moves the rectangle from left to right. Although keyframes aren't there, he is moving-even thought the last keyframe to the left is the same as the next keyframe law - as the first screenshot

    The best solution, I came up with for this is to copy and paste keyframes so that there is a keyframe for each frame within 3 seconds, then I get a schedule like the second screen shot.

    Is there something I could use where I could select 2 identical keys seconds out and make the form remain in the same spot with them into the second screenshot? It is speed and things happen quickly in this case isn't it?

    I also had an another question-are there - it a shortcut to insert a keyframe in the timeline? I found a page with all the shortcuts and couldn't find this one should be.

    Thanks guys, you have been life savers in the past!pic 1.pngpic 2.png

    As keyboard shortcuts you go to hold down the option/alt key and the keyboard shortcut ' Show/Hide properties ' to switch between adding and removing keyframes.  Adobe does not have the freedom to document them all in their page keyboard shortcuts, so here goes:

    Option + P: Position keyframe

    Option + R: Rotation keyframe (adds the keyframe at all values of rotation and orientation if the layer is 3D)

    Option + S: Scale keyframe

    Option + A: keyframe Anchor Point

    Option-T: Opacity keyframe (adding a keyframe of intensity if the layer is a 3D light)

    Option + M: Keyframe mask path

    Option + F: Mask Feather keyframe

    Option + L: Levels Audio keyframe

    * This does that for the single letter shortcuts - double letters do not work (i.e. TT for the opacity of the mask, RR for the time remapping, etc.).

    * Option + shift + the letter will work too which is good if you have reconfigured the Option + letter for other things such as throwing scripts - that I have.

    On the "boomerang" effect, I highly recommend you go to your preferences > "Général" tab and turn on 'by default spatial interpolation to linear', then you can manually add the Bezier handles to your keyframes in the composition Viewer if need be.

  • TouchMove events do not sent

    I have a page that listen to key events. If you tap and drag right now everything is fine, but if you hesitate a moment after the touchstart, touchmove ever event happens. All the event handlers call preventDefault().

    The test page prints below each event it receives when you move the rectangle.

    http://www.apprisant.com/tab/mm.html

    This has been filed as bug 735523 by diagrammer and works for me using the trunk builds (Firefox 14 a-1).

  • Put the pictures side by side in a new image

    Hello

    In my program, I had two (each 400 x 400 px) images I want to combine them into a single image (and save it on the disk).
    To do this, I extracted the image data and table construction allows to create a new image Board.
    Then I create a new image with dimensions 0,0-800 400 and use the new table of image as input data.
    The image is saved to the disk, but the two original images underneath the other.
    I would like to have them side by side, but I don't know how to do this.
    A screenshot of my original program is attached.

    Kind regards

    Björn

    There are two ways to leave the photo functions to do the work for you.  The most effective is to change the rectangle of the second image, but the code to change this to that and add this to it's a bit ugly, so I take the easy this time, but suggest that you write a little Subvi to simply move the rectangle.  You can choose side by side, on top, add padding, etc.

    Here is the ease (in code).

  • Black screen when opening a game displays

    Recently bought a game called the "Gundemonium Collection"(CD ROM). "» This came with three games, "Gundemonium Recollection, GundeadGne and Hitogata Happa". Out of these three games only GundeadGne works perfectly. The other two games lead receive me a black screen where I can still hear my cursor movement and confirm/exit command sounds, but no visuals are provided. The final result is based on the windows key, do a right click on the program and its closure.

    Note: I tried to reinstall the game several times, screen resolution of setting, run the program in compatibility modes different, update drivers, install the latest version of DirectX and run the program in a minimized window. Pretty interesting when I reduce the program, the window is black, but I can move blue rectangle hollow (which I assume is a cursor) medium size when I do that I hear no noise at all, or if I can play the game.

    Thanks for any help you can provide.

    Morshu,

    It's really, really weird.
    Everything should work fine.
    All I can say is that you try to delete the parameters (gundemonium.sav and hhconfig.cfg) and rerun games.
    Who should ask if you want to run the game in full screen or in a window.
    Try the windowed mode, there may be a difference.
    In addition, you can try to install the game somewhere other than the default in Program Files, just in case.
    We have done everything that we can to ensure the compatibility, but we weren't able to test all possible cases.

    Also make sure that gdmdat.dat is in the folder Gundemonium Recollection and hhdat.dat is located in the folder Hitogata Happa.

    If you have additional problems, contact me at Sarah (at) wingdreams (dot) net and we can match this topic.

    Sara LEEN,
    Rockin ' Android, Inc..

  • BlackBerry App

    Hi friends,

    I'm new to the Blackberry native development using the api of rim. I'm the extending class of screen and using the paint method to draw pictures and some texts with fillRect. My question is, how to scroll vertically through the rectangle (Ofcourse changing Y param) so that I can hover over the screen. I did some home work (maybe bad strategy) for the management of events in BB. Alternative method was to implement custombuttons but I don't want to compromise on the user interface and if the customer .

    1 NavigationClick

    2 KeyListener

    3 EventListener.

    But although I was able to move the rectangle even a pixel. Please guide me (code example would be a big help) where I am doing mistake.

    Code:

    public void paint (Graphics g)
    {
    g.Clear ();
    g.drawBitmap (0, 0, getWidth(), getHeight(), Utils.homeBG, 0, 0);
       
    g.setColor (Color.GREENYELLOW);
    g.fillRect (0, 40 + rectYPOS, 100, 25);

    g.setColor (Color.WHITE);
    g.drawText ("Lock", 20, rectYPOS);
    }

    public boolean navigationClick (int status, int time)
    {
    If ((status & KeypadListener.STATUS_TRACKWHEEL) == KeypadListener.STATUS_TRACKWHEEL)
    {
    If ((status & TrackwheelEvent.THUMB_ROLL_UP) == TrackwheelEvent.THUMB_ROLL_UP)
    {
                rectYPOS -= 20;
    }
    else if ((status & TrackwheelEvent.THUMB_ROLL_DOWN) == TrackwheelEvent.THUMB_ROLL_DOWN)
    {
                rectYPOS += 20;
    }
            
    }
    Return super.navigationClick (status, time);
    }

    Scenario of

    text 1

    _________________

    |          text 2 |   --->> This event would be the TrackBall up/down

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

    text 3

    text 4

    text 5

    invalidate after change of position

  • I can't click on any menu of Windows 7 Explorer buttons/scrollbar

    I recently noticed, I can't click on the scroll bar (the gray rectangle that you drag to scroll in the right corner of the window/file/explore) I can't click any other button in the folder as "burning" or "share". I can't click most of the buttons in the Panel, and I can not press or click on the buttons in a game (for example skyrim, because I spent the last hours 3 download) menu. But I can click very well on my desk, in the file (such as files in a folder that I can drag them around open ect) I can move the scroll bar in google chrome and click and make everything just fine, but not on windows, buttons, it seems. I was thinking of doing a system restore clean, or try a local restore point, but I really just finished download it Skyrim again and I just-ARGH. When I do ctrl + alt + delete I can't click anything that I can use enter however also although I can click anywhere in the scroll bar and the rectangle moves it slowly but I can't move the rectangle itself in the scroll bar. Please it's driving me crazy, that's why I bought a mac!

    I certainly know that this isn't for lack of my keyboard and mouse because I replaced them with others and I still get the same problem.

    JUST at the moment WHERE I WAS SUBJECT to GIVE HOPE, I tried all other solutions with no luck, I was up to 2. Ether make a clean install of the system, or do a clean boot! And to my surpise the boot worked :)) I can move the scrollerbar and click on the buttons in Explorer. I have not yet find it remains or even works in Skyrim: c.

  • Lightroom unusable 2016.6 of the slow

    The last update broke Lightroom and unusuably slow rendering. It's the way past "atrocious", it is really unusable. Simple tasks like cropping simply do not work anymore, every movement of the cursor with one of nodes requires a second 30 update and is therefore more possible to watch the cursor movement and rectangle in real time. Nothing has changed on my computer, the system is all that day, the only thing that has changed is the last update CC.

    Photoshop seems to work normally, even if she seems incapable of Comet of panoramas of several lines in auto mode.

    Back to Lightroom 6.5.1/Lightroom CC 2015.5.1

    Follow these instructions (where it says Lightroom 6.1.1/Lightroom CC 2015.1.1 claim he says Lightroom 6.5.1/Lightroom CC 2015.5.1)

    How do I roll back to Lightroom 2015.1.1 or Lightroom 6.1.1? Lightroom Queen

Maybe you are looking for

  • How to export history and bookmarks from firefox to another browser?

    I want to export firefox bookmarks and history to the default browser on android. Is this possible?

  • Satellite L30 - 11 d is not completely turned off

    As the title says, when I select 'Shut Down' in the start menu under Vista, the system says it stops, but w/lan stays on and if you press the eject button, the dvd opens.Also the battery will drain overnight, so it's obviously not turn off completely

  • W530: VMWare virtualization 64-Bit

    Hello I am trying to run a virtual machine on my new device w530 64 but I get this error: "This host is VT-capable but VT is disabled. VT is enabled in the BIOS and the securable tool also tells me that it is enabled. Y at - it another option to set

  • 5.0.2 for Moscow time zone GMT + 04:00?

    Change request Moscow TIME GMT + 03:00 p.s. the event calendar does not work.

  • Focus rectangle

    Hello New blackberry development. I have seen that when I concentrate on any icon in my request, he gets surrounded by a blue rectangle, filling the surrounding parts. (1) can I change this color to others? Or, (2) If a direct change of color is not