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: 490
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

How to set line width on Graphics?

Hi guys.

     

I am trying to draw a line two pixels wide. How can I do this?

 

For example on Android : paint.setStrokeWidth(3); This method sets line width. In this case, line width is 3 pixels. I am searching just like this method on BlackBerry.

 

Thanks.

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to set line width on Graphics?

shift over one pixel and redraw the line  Smiley Happy

 

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: How to set line width on Graphics?

In my application I just draw two (or more) lines next to each other.  But then, I have only horizontal and vertical lines...

 

Neither net.rim.device.api.ui.Graphics nor javax.microedition.lcdui.Graphics support a drawLine method with lines thicker than 1 pixel (if they do it is not documented).  As an alternative to drawing two lines you can use fillRect method of either of those two - again, for vertical/horizontal lines only.

 

For diagonal lines you may use drawFilledPath - or use the "two line" approach again.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to set line width on Graphics?

Thanks guys.

 

There is no method in API.

 

 

Trusted Contributor
Posts: 114
Registered: ‎10-21-2010
My Device: Bold 9650
My Carrier: Develper

Re: How to set line width on Graphics?

 


Raiden wrote:

Hi guys.

     

I am trying to draw a line two pixels wide. How can I do this?

 

For example on Android : paint.setStrokeWidth(3); This method sets line width. In this case, line width is 3 pixels. I am searching just like this method on BlackBerry.

 

Thanks.


 

Try this :

        Graphics.setColor(Color.RED);
        Graphics.setStrokeWidth(20);
        Graphics.drawRect(0, 0, 100, 100);

They are available in net.rim.device.api.ui.Graphics package.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to set line width on Graphics?

Maybe just me, but I don't see a setStrokeWidth() in Graphics

Developer
Posts: 133
Registered: ‎04-30-2010
My Device: Curve 8520
My Carrier: T-Mobile

Re: How to set line width on Graphics?

You mean even when you achieve Level 6 (congratulations by the way on attaining your new level, there must be a huge box of freebies heading your way) RIM don't open up that part of the API for you?  Smiley Happy

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to set line width on Graphics?

Thanks for the congrats.  Unfortuantely no extra access to things internal Smiley Sad.  The biggest difference I have noted so far getting to Level 6 is the background color of my 'Level'! 

Highlighted
Trusted Contributor
Posts: 114
Registered: ‎10-21-2010
My Device: Bold 9650
My Carrier: Develper

Re: How to set line width on Graphics?

 


peter_strange wrote:

Maybe just me, but I don't see a setStrokeWidth() in Graphics


yes, I also don't see it in JavaDoc but when I type graphics, Eclipse has suggested me a list of methods and I have found setStrokeWidth(). I'm using BlackBerry JRE 5.0.0.