Scroll and custom button image

Hi all

I'm having some difficulty with it.

I have now managed to get a scrolling image downloaded from a url.

I now place buttons above the image scroll, previous and next buttons.  But I can't seem to the paint without knocking the image scrolling.

Any ideas on how I can achieve this.  If I do a this.add in the constructor, it gets ignored because I replaced the painting.

Real novice so the pointers/code examples would be fantastic.

Cheers all, you're really a helpful bunch!

/* * OldImage.java * * © , 2003-2008 * Confidential and proprietary. */

package PageSuite;

import java.io.*;import javax.microedition.io.*;import net.rim.device.api.system.*;import net.rim.device.api.ui.*;import net.rim.device.api.ui.component.*;import net.rim.device.api.ui.container.*;import net.rim.device.api.system.Bitmap;import net.rim.device.api.ui.Graphics;import net.rim.device.api.ui.UiApplication;import net.rim.device.api.ui.component.Dialog;import net.rim.device.api.ui.container.MainScreen;import net.rim.device.api.util.DataBuffer;import net.rim.device.api.util.ByteVector;import net.rim.device.api.util.*;import java.util.*;import net.rim.device.api.i18n.*;import javax.microedition.lcdui.Image;

class OldImage extends MainScreen {                private static final int HORZ_SCROLL_FACTOR     = 10;          private static final int VERT_SCROLL_FACTOR     = 10;

         Bitmap bitmap;            int left = 0;          int top = 0;           int maxLeft = 0;               int maxTop = 0;

               public OldImage() {

                        StreamConnection stream = null;                        InputStream in = null;                        synchronized(this)                        {                        try                        {                        stream = (StreamConnection)Connector.open("http://www.image.com/get_image.aspx?eid=032cf610-8918-425b-a4d9-441fa9468f23&w=" + Graphics.getScreenWidth() + "&pnum=1");                        in = stream.openInputStream();                        }                        catch(Exception e)                        {                        }                        }                        try                        {                        // Extract the data from the input stream.                        byte[] data = new byte[in.available()];                        try                        {                        DataBuffer db = new DataBuffer();                        int chunk = 0;                        while ( -1 != (chunk = in.read(data)))                        {                        db.write(data, 0, chunk);                        }                        in.close();                        // Here is ur image in byte format.                        data = db.getArray();                        }                        catch(Exception e)                        {                        }

                        EncodedImage jpegPic = EncodedImage.createEncodedImage(data, 0 , data.length);                        bitmap = jpegPic.getBitmap();

                       if (bitmap == null) {                          UiApplication.getUiApplication().invokeLater(new Runnable() {                                  public void run() {                                            Dialog.alert("Failed to load image");                                          System.exit(0);                                        }                              });                            return;                        }

                       if (bitmap.getWidth() > Graphics.getScreenWidth()) {                           maxLeft = bitmap.getWidth() - Graphics.getScreenWidth();                       }

                       if (bitmap.getHeight() > Graphics.getScreenHeight()) {                         maxTop = bitmap.getHeight() - Graphics.getScreenHeight();                      }                    }                    catch (Exception ex)                    {}

                    CustomButtonField cf = new CustomButtonField("Nathan");                    this.add(cf);

              }

               protected void paint(Graphics graphics) {                      if (bitmap != null) {                          graphics.drawBitmap(0, 30, Graphics.getScreenWidth(), Graphics.getScreenHeight() - 20,                                               bitmap, left, top);

                    }              }

               protected boolean navigationMovement(int dx, int dy, int status, int time) {                   left += (dx * HORZ_SCROLL_FACTOR);                     top += (dy * VERT_SCROLL_FACTOR);

                     if (left < 0) left = 0;                        if (top < 0) top = 0;                  if (left > maxLeft) left = maxLeft;                    if (top > maxTop) top = maxTop;

                       invalidate();

                 return true;           }      }

You can call the subpaint (graphics) of your paint to draw the fields 'child '. And you can try Trackball.setFilter (Trackball.FILTER_ACCELERATION) and see if it makes more responsive scrolling.

Cheers, Barak.

Tags: BlackBerry Developers

Similar Questions

  • Problem with fieldChanged() and custom button field

    Hello

    I created a custom button class by extending LabelField.  I chose LabelField over field because the LabelField contains desirable properties that are already being implemented.  The only problem I'm having has to do with the change listener.  It seems to 'steal' the event click on other areas in my application.

    For example, when I click on the custom button, a popupscreen with a listfield opens. When I click on an item in the listfield, then the fieldChanged() of custom button is called again...

    Can you see anything wrong with my code?

    package com.rantnetwork.fields;
    
    import com.rantnetwork.app.Constants;
    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.Font;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.Ui;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class CustomButtonField extends LabelField {
    
        private boolean highlighted = false;
    
        public CustomButtonField(String text, long style) {
            super(text, style | Field.FOCUSABLE | LabelField.ELLIPSIS);
    
            setPadding(10, 0, 10, 5);
    
            setFont(Font.getDefault().derive(Font.BOLD,
                    Constants.DEFAULT_FONT_SIZE, Ui.UNITS_pt));
    
            setBackground(BackgroundFactory.createLinearGradientBackground(
                    0x163d7c, 0x163d7c, 0x03162d, 0x03162d));
            setBorder(BorderFactory
                    .createBevelBorder(new XYEdges(1, 1, 1, 1), new XYEdges(
                            Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK),
                            new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                    Color.BLACK)));
    
        }
    
        public int getPreferredWidth() {
            return Display.getWidth() / 3;
        }
    
        protected void paint(Graphics graphics) {
            graphics.setColor(Color.WHITE);
            super.paint(graphics);
        }
    
        protected void drawFocus(Graphics graphics, boolean on) {
            // Do nothing
        }
    
        protected boolean navigationClick(int status, int time) {
            fieldChangeNotify(1);
            return true;
        }
    
        protected void onFocus(int direction) {
            if (!highlighted) {
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x4bb7df, 0x4bb7df, 0x1b96da, 0x1b96da));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            }
        }
    
        protected void onUnfocus() {
            if (!highlighted) {
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x163d7c, 0x163d7c, 0x03162d, 0x03162d));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            }
        }
    
        public void showHighlighted(boolean focus) {
            if (focus) {
                highlighted = true;
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x4bb7df, 0x4bb7df, 0x1b96da, 0x1b96da));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            } else {
                highlighted = false;
                setBackground(BackgroundFactory.createLinearGradientBackground(
                        0x163d7c, 0x163d7c, 0x03162d, 0x03162d));
                setBorder(BorderFactory.createBevelBorder(new XYEdges(1, 1, 1, 1),
                        new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,
                                Color.BLACK), new XYEdges(Color.BLACK, Color.BLACK,
                                Color.BLACK, Color.BLACK)));
            }
            invalidate();
        }
    
        public boolean isHighlighted() {
            return highlighted;
        }
    
    }
    

    behrk2 wrote:

    Now, I'm not sure why customButton.setText (calling) would trigger the fieldChanged().  Can anyone think of a reason why he can do?

    Thank you!

    Can you think of a reason why we can't do that? The field has changed, after all! Of course, the context (second argument to fieldChanged) will be PROGRAMMATIC in this case, that might be a pretty good indication for you. But not invoke fieldChanged at all would be wrong.

    This is why I don't like the idea of extending LabelField and not just the field for your custom badges - you have much less control over his behavior. If you want an example showing how to create abstract off-screen buttons, take a look at BaseButtonField and his descendants in managers, fields and advanced buttons.

  • JDialog with options and custom buttons

    I can't seem to find a builder for custom buttons and drop-down menu items. I wanted to do was add custom buttons this text simply nothing complicated. 'Connect' and 'Cancel '.
    /**
     * Dialog window for new connection.
     */
    protected String NewConnectionDialog()
    {
         Window win = SwingUtilities.getWindowAncestor(mainPanel);
         String[] databases = {"Oracle", "Access", "MySQL", "PostgreSQL"};
         Object[] options = {"Connect", "Cancel"};
    
         String s = (String)JOptionPane.showInputDialog( win, 
                   "Select Database:", "New Connection Wizard.", 
                   JOptionPane.OK_CANCEL_OPTION, icon, databases, 
                   "MySQL" );
    
         String nullStr  = ""; // no exceptions thanks
         return (s != null ? s.toUpperCase() : nullStr);
    }

    javax.swing.JOptionPane.showOptionDialog ()...

    JPanel pea = new JPanel();
    JLabel jl = new JLabel("Select DB");
    JComboBox jcb = new JComboBox(...stuff here..);
    pea.ad(jl);
    pea.add(jcb);
    
    JButton conButton = new JButton("Connect");
    Object[] buttonRowObjects = new Object[] {
      conButton, "Cancel"
    };
    
    int result = JOptionPane.showOptionDialog(
      Component parentComponent,
      Object message,//<- pea right here
      String title,
      int optionType,
      int messageType,
      Icon icon,
      Object[] options,//<- buttonRowObjects here
      Object initialValue
    );
    

    There now, your patience has paid off. And don't forget to eat your vegetables.

  • Development/unfocus field custom button problem

    Hi all

    I have something weird happens.  I have a custom button field that swaps the images based on a focused state or blur.  I have been using this field custom for awhile now, and I have never had any problems.  Imagine the following provision:

    ______________    ________________________

    | Custom button |    | BasicEditField |

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

    When my screen is launched, the focus is on the custom button.  If I move the trackball in a downward movement, the focus is taken the custom button, and its background image changes adequately to what has been defined in the untargeted State.  The BasicEditField then has the focus.  This is the correct behavior.

    If, however, I move the trackball in a movement to the right to the BasicEditField, then the BasicEditField will indeed get the focus, however the custom button field always displays its "highlight" picture  Using print statements, I was able to determine that when I move in a movement to the right with the trackball, the custom field button loses the focus and then gets the focus back to back, that's why it shows the highlighted image.

    Additional info:  This isn't an issue on touch devices, and custom button Manager is a TableLayoutManager.

    Any ideas why this might be happening?  Here's the code to my custom button field:

    public class BitmapButtonField extends Field {
        private String text = "";
        private Bitmap bitmap;
        private Bitmap bitmapHighlight;
        private Bitmap b;
        private boolean highlighted;
    
        public BitmapButtonField(String image, String imageHighlight, long style) {
    
            super(style | Field.FOCUSABLE);
    
            this.bitmap = Bitmap.getBitmapResource(image);
            this.bitmapHighlight = Bitmap.getBitmapResource(imageHighlight);
    
            b = bitmap;
    
        }
    
        public BitmapButtonField(String text, String image, String imageHighlight,
                long style) {
    
            super(style | Field.FOCUSABLE);
    
            this.text = text;
            this.bitmap = Bitmap.getBitmapResource(image);
            this.bitmapHighlight = Bitmap.getBitmapResource(imageHighlight);
    
            b = bitmap;
    
        }
    
        protected void drawFocus(Graphics graphics, boolean on) {
            // Do nothing
        }
    
        public int getPreferredHeight() {
            return bitmap.getHeight();
        }
    
        public int getPreferredWidth() {
            return bitmap.getWidth();
        }
    
        protected void layout(int width, int height) {
            setExtent(getPreferredWidth(), getPreferredHeight());
        }
    
        protected boolean navigationClick(int status, int time) {
            fieldChangeNotify(1);
            return true;
        }
    
        protected void onFocus(int direction) {
            b = bitmapHighlight;
            invalidate();
            System.out.println("FOCUSED");
    
        }
    
        protected void onUnfocus() {
            b = bitmap;
            invalidate();
            System.out.println("UNFOCUSED");
        }
    
        protected void paint(Graphics graphics) {
    
            int topTextPadding = (b.getHeight() - getFont().getHeight()) / 2;
            int sideTextPadding = (b.getWidth() - getFont().getAdvance(text)) / 2;
    
            graphics.drawBitmap(0, 0, getWidth(), getHeight(), b, 0, 0);
            graphics.setColor(Color.WHITE);
            if (text.length() > 0) {
                graphics.drawText(text, sideTextPadding, topTextPadding,
                        Graphics.ELLIPSIS, b.getWidth());
            }
        }
    }
    

    Have you looked at navigationMovement in the TableLayoutManager?  I confess that I rewrote it because it handles no left and right as I wanted.  Perhaps, you might be able to do the same thing.

  • Save the button Image file

    I have a Captivate 7 file that contains the custom button images.  How to save a copy of any of these images?  I can't find it in the library or on my local hard drive.  Thank you

    Just thought of this.

    Generate a HTML 5 output and you should be able to find the images in the output.

    See you soon... Rick

  • How to copy a hyperlink and make moving image work

    Hi all

    I created a hypertext navigation, rather like a table of contents, for our presentation of the iPad and we would like to have on individual items on each page. It is quite large, so it is in a floating, accessed framework since a MSO (Menu button). It works great on the first article, but when I copy and paste the DSO for master pages for the other articles, none of them work.

    I work in InDesign 5.5. I understand that I can create buttons with the navto: / / command, all with the text of the group block and who enter as part of content to have a navigation scroll, and the buttons with navto controls are less likely to break, but is there something else I forget?

    It seems illogical that can not copy and paste as hyperlink folio names and page numbers have not changed. However, I note that InDesign assigns a number after the name hyperlink in the hyperlinks Panel. I tried to rename the hyperlink to its original name (with no number) and it adds a different number at the end.

    I'll probably start course button, but I thought it was a valid discussion to begin.

    Thanks a lot for your time ~.

    Screen shot.png

    So, I thought about it. Hope this helps someone else because it took me HOURS to fix.

    I deleted all of the hyperlinks in the control panel and went on the creation of each of them from scratch, using the hyperlinks - new icon link at the bottom - so that I have the option to deselect the 'shared target of hyperlink' which is always checked, unless you uncheck the box, simple, gosh darn link.

    (They might mention this bit of info somewhere. I sure couldn't find.)

    Worked like a charm. Hallelujah.

    See you soon ~

    ( :

  • Can add you a custom button to HTML5 and refer them to a URL?

    I went out sensitive HTML5 from FM 12 (soon upgrading to 2015 FM). I manually delete the Index and glossary buttons the output (this step will disappear with FM 2015). I would like to replace the image of the Index button with an image of custom button (on the PDF symbol) and make sure when you click on this button PDF, a PDF file opens (if the button should redirect to the URL for the PDF file). Is this possible?

    Here's the correct answer:

    With the help of FM2015, unzip the file (.sts) settings and open the Topic.slp file in a text editor such as Notepad. Find the index of the sidebar button:

     

    It contains all the code required to display the index. "To change this to a hyperlink, change it in: http://www.example.com" > This turns it into a hyperlink that opens the page.

    To make the hover text something other than 'Index' remove the data-attr="title:@KEY_LNG attribute. The index ". Then add the title = "My title" attribute instead. In my case, I added the title = 'PDF', and the resulting line in my Topic.slp is:

    http://www.Sonos.com/documents/productguides/en/Play1Guide_EN.PDF">."

    A big thanks to Willam van Weelden and Stefan Gentz for their advice to help me resolve this issue.

    In each of my guides of HTML5, the PDF button should open the PDF for the guide. So, if I opened the ABC HTML5 guide and I click on the PDF button, the ABC PDF file should open. Since the PDF button link goes to a specific PDF file, I have a single file of Topic.slp (and therefore the settings file) for each guide to HTML5.

    I also removed the code for the icon that appears at the top left of the HTML5 content and links to the home page. I'd rather have the title of the HTML5 hunting guide water left and do not have a logo. So, I deleted the lines

  • I want to use a custom button photoshop with my composition and have the substitution effect

    I'm trying to put a button in photoshop in a blank publication widget trigger. When I cut an paste the image into the trigger, he loses his robot and switches are no longer the colors during the reversal. It works very well in the composition of the lightbox, but the problem with lightbox composition, is there no working capital options to display click only target. How to work around this problem. I want to have my own custom button with the effect of composition within the cc muse.

    You should check the design layout and defined States for relaxation, if the State is set correctly then it should show the rollover State, but the container target corresponding to the relaxation is on the page, then it could show you the active State not the rollover State.

    Thank you

    Sanjit

  • Tools-options-customize-disable 3rd party cookies window is great and save buttons at the bottom of the screen don't show up so I can't change anything or scroll or mak

    Tools-options-customize-disable 3rd party cookies window is great and save buttons at the bottom of the screen don't show up so I can't change anything or scroll, minimize the window somehow

    Hello, please try to start firefox in safe mode - interferes probably an extension or theme...
    Troubleshoot extensions, themes, and issues of hardware acceleration to resolve common problems of Firefox

  • When I turn on my computer, it gets stuck on the ultra-portable gigabyte 3 screen and custom which leave me there 2 hours still no luck the only button that works are TAB rebooting too

    Original title: stuck

    When I turn on my computer, it gets stuck on ultra-portable gigabyte 3 screen and custom wide movement which I gave 2 hours still no luck the only button that works are TAB restart too it can someone help please

    Follow these steps:

    Step 1: Start the computer in safe mode and check if the problem persists.

    A description of the options to start in Windows XP Mode

    http://support.Microsoft.com/kb/315222

    Step 2: If the problem does not still in safe mode, perform a clean boot to see if there is a software conflict as the clean boot helps eliminate software conflicts.

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Note: After completing the steps in the clean boot troubleshooting, follow the section How to configure Windows to use a Normal startup state of the link to return the computer to a Normal startupmode.

    After the clean boot used to resolve the problem, you can follow these steps to configure Windows XP to start normally.

    (a) click Start, run.

    (b) type msconfigand click OK.

    (c) the System Configuration Utility dialog box appears.

    (d) click the general tab, click Normal startup - load all services and device drivers and then click OK.

    (e) when you are prompted, click on restart to restart the computer.

  • Problem with wheel scrolling and buttons on Microsoft mouse optical basic v2.0 in Vista

    Hello recently, I logged on to my computer and found out that my laser mouse does not shine by the sensor and the pointer didn't budge when I moved the mouse wheel works only the buttons and scroll

    Why what happened?

    wheel scrolling and buttons on my mouse works nothing else don't

    EDIT: im using a basic v2.0 mouse Microsoft Optical

    Nope it na no:(mais c'est correct, je pense que c'est un problème matériel et j'ai acheté une nouvelle souris qui fonctionne très bien)

    but thanks for your help when even :) as I'm not sure how this forum works, but I think a mod should close this question

  • How to add and delete custom buttons

    Hello world

    I have two field of custom button with different colors of red and white button.

    And I want to add and remove both button in the same place each other.

    I mean when I click on the red button, red button remove the screen and the same when I click on the white button to remove white button must be appear and red button should appear. Both button must be exposed to the same place.

    Please any idea...

    Thank you.

    public void add (field)
    survey
    IllegalStateException - if the field has already been added to a Manager.

    Public Sub delete (field)
    IllegalArgumentException - if the field to delete does belong to this Manager.

    So check with the field.getManager () function to make it work properly...

  • Custom button problem (is the closure of a popup and it shouldn't)

    Hello.

    In my ADF, 11.1.1.7.0 JDeveloper application, I have a popup with its dialogue and its default buttons "Ok" and "Cancel".

    In addition to this, I put a custom command button. I want it, when it is selected, go to the server, do things in a method and return to the open popup.

    The fact is that, when you click the custom button, the method is executed (action or actionListener, I tested both), but popup closes immediately.

    So, I have to reopen the popup to see the actions performed.

    How can I avoid the popup gets closed when clicking this custom button?

    Thanks in advance.

    AutoCancel = disabled on the popup property set. It will not close the popup.

    Thank you

  • from vertical scrolling of the buttons and NO mouse

    I have 5 items, mainly the rectangles with different colors. What I want to do is roll of particular color based on the action of the buttons. I placed 5 buttons above the first rectangle. Based on the action of the button, it must scroll to a particular color and 5 buttons should stay in the same place.

    I created the layout on the edge of what I want to do. I don't want scroll bars so I then hid. And I don't want to achieve this by using scroll mouse, but with buttons. Using the scroll buttons.

    Download the example:

    http://www.4shared.com/zip/RTTSNCrjce/scrolling.html

    @heathroweexample is closer to what I want to achieve. It has different menu items on each rectangle. I tried to do but was unable to get things to work.

    EDIT: If I create a Web site in Adobe Muse using anchors and add actions on the buttons to switch to this anchor, I want o something similar to Adobe Edge. I almost did the same thing with Muse, unfortunately there no sensitive support, so I'm doing it on board

    Post edited by: alexmathayes

    Super

    Just for 'nest' make sure / of group items that I did with my sample.

    Example, I put all the menu items in a parent, called "topbar" element

    Similarly for elements that should just below in the 'brown' area, nest the respective elements. Similarly for the other 'blocks '.

    Darrell.

  • How to change the highlight color, click the button image and text and sound.  are there packages of buttons for use in my project?

    How to change the highlight color, click the button image and text and sound. are there packages of buttons for use in my project?

    Hello

    Even if the point of things based Web links buttons created using them is of simple images. Captivate uses simple images. If you need to put your creative hat and not to let the fact that you see the word 'web' scared you somehow. An image is an image. Use on the web, use Captivate. Same case!

    If you change the properties of the button, you can activate the legend of success. Fix any sound that you like with the legend of success and it will play when you click the button. If you do not want to see the legend of success, delete the text and configure it as transparent.

    See you soon... Rick

    Useful and practical links

Maybe you are looking for