cancel
Showing results for 
Search instead for 
Did you mean: 

Can any one tell me how we bold a particular string .? Is there any method

Former Member
0 Kudos

Hi,

Can any one tell me how we bold a particular string .? Is there any method for that ...

Regards,

Gurprit Bhatia

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi see the following code.

It will work. and it will be helpful for u.

import java.awt.*;

import java.awt.event.*;

import java.awt.geom.*;

import java.awt.font.*;

public class TimesB extends Canvas {

private Image img;

public TimesB() {

setBackground(Color.white);

}

public void paint(Graphics g) {

Graphics2D g2;

g2 = (Graphics2D) g;

g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,

RenderingHints.VALUE_ANTIALIAS_ON);

g2.setRenderingHint(RenderingHints.KEY_RENDERING,

RenderingHints.VALUE_RENDER_QUALITY);

FontRenderContext frc = g2.getFontRenderContext();

Font f = new Font("Times",Font.BOLD, 24);

String s = new String("24 Point Times Bold");

TextLayout tl = new TextLayout(s, f, frc);

Dimension theSize= getSize();

g2.setColor(Color.green);

tl.draw(g2, theSize.width/30, theSize.height/2);

}

public static void main(String s[]) {

WindowListener l = new WindowAdapter() {

public void windowClosing(WindowEvent e) {System.exit(0);}

public void windowClosed(WindowEvent e) {System.exit(0);}

};

Frame f = new Frame("2D Text");

f.addWindowListener(l);

f.add("Center", new TimesB());

f.pack();

f.setSize(new Dimension(400, 300));

f.show();

}

}

Regards

Hazrath

Former Member
0 Kudos

Where? Inside a TextEdit?

Armin

Former Member
0 Kudos

Hi ,

I am retrive one string as output of one rfc enable fm. I am divide this string in two four fields and i have to show one field boldly.

Regards,

Gurprit Bhatia

Former Member
0 Kudos

Hi,

Make sure that you put the target string in a seperate TextView. Create your context appropriately. Then you can set the "design" property of the TextView to "header1"/"header2"/"header3"/"emphasized" etc.

Regards,

Satyajit.

Former Member
0 Kudos

Hi

try with the following code

It will be helpful for u.

import java.awt.*;

Font f = new Font("Helvetica",Font.BOLD, 24);

String s = new String("24 Pont Helvetica Bold");

Physical fonts may use names such as Helvetica, Palatino, HonMincho, or any number of other font names

Regards

Hazrath

Edited by: Hazrath on Mar 25, 2008 11:43 AM

Former Member
0 Kudos

Hi Hazrath,

I affraid to tell that it does not work.

Regards,

Gurprit Bhatia

Former Member
0 Kudos

Hi,

To make the string bold ,,,,,, as Sharanya told u have to do at design time of the UI element .

1) Take a label ....> Make its property design -- emphasized

2) Take a group --> Make its header text --- type the required string.

3)Page header UI element ---> It will be useful for Page headings on the top .

If you want dynamically , take a value attribute of a context of string type , dynamically change the string.....

make the label text property bind with that string and make visible or invisible of the label according to

your need.

Thanks ,

Srini

Former Member
0 Kudos

hai,

If you want to make a string(text view)UI element bold then you need to choose the design property of the text view accordingly(header2)..If any issues plz be specific about your requirement.

Thanks n Regards

Sharanya.R