on 03-25-2008 9:04 AM
Hi,
Can any one tell me how we bold a particular string .? Is there any method for that ...
Regards,
Gurprit Bhatia
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where? Inside a TextEdit?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.