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
Contributor
amelRedshift
Posts: 18
Registered: ‎01-17-2012
My Device: developer
My Carrier: developer
Accepted Solution

How to underline a part of a checkBoxfield label ?

Hello

 

Let's say I have a checkBoxField object like this:

_checkboxField =  new CheckboxField("I accept the terms and conditions ", false, FOCUSABLE);

 

I want only the "the terms and conditions" to be underlined. Is that possible?

 

Thanks

Please use plain text.
Developer
alishaik786
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: How to underline a part of a checkBoxfield label ?

[ Edited ]

Try this sample code and see the difference: 

 

public class Abc extends MainScreen	
{
	CheckboxField checkField;
	Font font;//Set the font is the main;
        
	public Abc()
        {      
		font=Font.getDefault().derive(Font.BOLD|Font.UNDERLINED, 18);		
                createGUI();        
               makeGUI();	
        }
	
	private void createGUI() 
	{
		HorizontalFieldManager hr=new HorizontalFieldManager();
		
		checkField=new CheckboxField("", false);//Here you only get the focus on check box
		checkField.setFont(font);
		hr.add(checkField);
		
		LabelField labelField=new LabelField("Forgot Password",Field.NON_FOCUSABLE|Field.FIELD_VCENTER);
		labelField.setFont(font);
		hr.add(labelField);
		
		add(hr);
		
		add(new ButtonField("Save"));
	}


	private void makeGUI() 
	{
		checkField=new CheckboxField("Forgot Password", false);//Here you get focus on Text also; Better to use Upper one ;
		checkField.setFont(font);		
		add(checkField);
		
		add(new ButtonField("Save"));
	}
}

 =========================================================================

Feel free to click LIKE button if the solution helps you;

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Please use plain text.
Trusted Contributor
govind23
Posts: 112
Registered: ‎05-20-2011
My Device: 9800
My Carrier: Developer

Re: How to underline a part of a checkBoxfield label ?

[ Edited ]

Try as follows 

 

CheckboxField field=new CheckboxField("", false, Field.FOCUSABLE);
		HorizontalFieldManager hr=new HorizontalFieldManager();
		String data = "I accept the terms and conditions";
		int index = data.indexOf("the");
		int offsets[] ={0,index,index+23,data.length()};
		Font[] fonts = new Font[] { Font.getDefault(),Font.getDefault().derive(Font.UNDERLINED)};

		byte attributes[] = {0,1,0};

		RichTextField richTextField = new RichTextField(data, offsets, attributes, fonts,
		0);
		hr.add(field);
		hr.add(richTextField);
		add(hr);

 you can out put as follow

 

9700.jpg

 

if you like this please accept as solution 

Please use plain text.
Contributor
amelRedshift
Posts: 18
Registered: ‎01-17-2012
My Device: developer
My Carrier: developer

Re: How to underline a part of a checkBoxfield label ?

 

Hello 

I tried your code. But unfortantuly I don't have what you are in your simulator !

I have the checkBox without text. I think that the richtextField is not added. What do you think the problem is?

 

Thank you

Please use plain text.
Developer
alishaik786
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: How to underline a part of a checkBoxfield label ?

Whom you replayed that message?

 

provide his/her name then undersand by us that whom you are asking.....?

 

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Please use plain text.
Developer
swap_chau
Posts: 179
Registered: ‎06-15-2011
My Device: Storm 9550
My Carrier: Vodaphone

Re: How to underline a part of a checkBoxfield label ?

I think you should create custom checkfield. In its paint method you can draw the text using graphics.drawtext(). You can set whichever font you want.

Please use plain text.
Contributor
amelRedshift
Posts: 18
Registered: ‎01-17-2012
My Device: developer
My Carrier: developer

Re: How to underline a part of a checkBoxfield label ?

I replayed that message to govind23.

 

Thanks

Please use plain text.
Contributor
amelRedshift
Posts: 18
Registered: ‎01-17-2012
My Device: developer
My Carrier: developer

Re: How to underline a part of a checkBoxfield label ?

 

Hello govind23,

 

Whay you have in your simulator (the picture you added ) is exactly what I want to do.

I tried your code, but when I tested it I have only a checkBox without text.

Could you help me please?

 

Thanks

Please use plain text.
Trusted Contributor
govind23
Posts: 112
Registered: ‎05-20-2011
My Device: 9800
My Carrier: Developer

Re: How to underline a part of a checkBoxfield label ?

which os and which devise did you check?

Please use plain text.
Contributor
amelRedshift
Posts: 18
Registered: ‎01-17-2012
My Device: developer
My Carrier: developer

Re: How to underline a part of a checkBoxfield label ?

I check os 7.0 device 9810.

Please use plain text.