Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Need an idea of component

 

Hi,i want a dragger or scroller like component,is there any widgets similar to it,or else custom component needs to be prepared ,component similar to it ,needs to be done .I need on idea on this.in short ,dragger.JPG

 

 

Regards

Rakesh shankar.p

 

Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: Need an idea of component

Hi Rakesh,

     Your image is not visible in firefox and IE. Can you please check it, also can you give a brief about the component which you want?

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Need an idea of component

I'm pretty sure that images must be approved by a moderator before they will be displayed. It takes a very long time before they are approved so it is easier to post it on another site and provide a link.

 

As for the component, guessing from the image name "dragger.jpg" I am guessing that you want either some bar graph that you can control or you want some drag and drop control.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: Need an idea of component

[ Edited ]

yes bar like component,with scroller in it,while dragging the scroller,value should change  based on dragging of  the scroller,can understand me Sir and this is link of the image

 

http://www.filefactory.com/file/a18929d/n/dragger.JPG

 

i want a idea on this

 

Regards

Rakesh shankar.p

Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: Need an idea of component

Hi Rakesh,

   I think you need this component for storm. If then here is the sample code of the custom component

 

class HorzScroll extends GaugeField {
    private int _maxValue, _minValue, _value;

    public HorzScroll()
    {
        super();
        _maxValue = Display.getWidth();
        _minValue = 0;
        _value = 10;
    }

    public int getPreferredHeight()
    {
        return 7;
    }

    public int getPreferredWidth()
    {
        return _maxValue;
    }

    protected void paint (Graphics g)
    {
        g.setBackgroundColor(Color.BLACK);
        g.fillRect (_value, 1, 10, 4);
    }

    protected void layout(int width, int height) {
        super.layout(width, height);
        setExtent (_maxValue, 7);
    }

    protected boolean touchEvent (TouchEvent message)
    {
        if ((message.getEvent() == TouchEvent.CLICK) ||
                                    (message.getEvent() == TouchEvent.MOVE))
        {
            int y = message.getGlobalY (1);
            if ((y < 0) || (y > getPreferredHeight()))
                return false;

            _value = message.getGlobalX (1);
            if (_value >= _maxValue - 10)
                _value = _maxValue - 10;
            invalidate();

            return true;
        }

        return false;
    }

    public int getValueMax()
    {
        return _maxValue;
    }

    public int getValueMin()
    {
        return _minValue;
    }

    public int getValue()
    {
        return _value;
    }
}

class VertScroll extends GaugeField {
    private int _maxValue, _minValue, _value;

    public VertScroll()
    {
        super();
        _maxValue = Display.getHeight();
        _minValue = 0;
        _value = 10;
    }

    public int getPreferredHeight()
    {
        return _maxValue;
    }

    public int getPreferredWidth()
    {
        return 7;
    }

    protected void paint (Graphics g)
    {
        g.setBackgroundColor(Color.BLACK);
        g.fillRect (1, _value, 4, 10);
    }

    protected void layout(int width, int height) {
        super.layout(width, height);
        setExtent (7, _maxValue);
    }

    protected boolean touchEvent (TouchEvent message)
    {
        if ((message.getEvent() == TouchEvent.CLICK) ||
                                    (message.getEvent() == TouchEvent.MOVE))
        {
            int x = message.getGlobalX (1);
            if ((x < 0) || (x > getPreferredWidth()))
                return false;

            _value = message.getGlobalY (1);
            if (_value >= _maxValue - 10)
                _value = _maxValue - 10;
            invalidate();

            return true;
        }

        return false;
    }

    public int getValueMax()
    {
        return _maxValue;
    }

    public int getValueMin()
    {
        return _minValue;
    }

    public int getValue()
    {
        return _value;
    }
}

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: Need an idea of component

[ Edited ]

Hi Vignesh,this is the sample image of component that i described earlierr

 

 

 

 

 

http://www.filefactory.com/f/ef594ce25b74ba1a

/--chk this link

Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: Need an idea of component

Hi Rakesh,

     Here is the sample code which will solve your requirement.

 

class HorzScroll extends GaugeField {
    public HorzScroll()
    {
        super ("", 0, Display.getWidth(), 5, GaugeField.NO_TEXT);
    }

    public int getPreferredHeight()
    {
        return 32;
    }

    protected void paint (Graphics g)
    {
        int value = getValue();
        if (value >= getValueMax() - 10)
            value = getValueMax() - 10;
        g.setBackgroundColor(Color.BLUE);
        g.fillRect (0, 11, value, 12);
        Bitmap image = Bitmap.getBitmapResource("image.jpg");
        g.drawBitmap (value - (image.getWidth()/2), 0, image.getWidth(), image.getHeight(), image, 0, 0);
    }

    protected void layout(int width, int height) {
        super.layout(width, height);
        setExtent (_maxValue, 32);
    }

    protected boolean touchEvent (TouchEvent message)
    {
        if ((message.getEvent() == TouchEvent.CLICK) ||
                                    (message.getEvent() == TouchEvent.MOVE))
        {
            int y = message.getGlobalY (1);
            if ((y < 0) || (y > getPreferredHeight()))
                return false;

            setValue(message.getGlobalX (1));
            invalidate();

            return true;
        }

        return false;
    }

}

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------