aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes font size, and dialogbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "font size, and dialogbox" Watch "font size, and dialogbox" New topic
Author

font size, and dialogbox

PETER OBAYEMI
Greenhorn

Joined: Oct 10, 2005
Posts: 1
hi,
pls,i'am a beginner in java and have being trying to write a code to (1).change the font size of a text.(2). change the font style of a text.(3)use dialog boxes effectively but failed.pls i need to tell me how to go about it and if you can help me with the code
Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
hi,
The 1st two problems that you've mentioned involve the use of the Font class found in package "java.awt.*"

To change the Font Style and The Font Size use the following constructor of the Font class :

Font font=new Font(String name, int style, int size);

where,
name - is the required font name like Lucida, Arial etc(if you're
on Windows)
style - can be PLAIN, or a bitwise union of BOLD and/or ITALIC(for
example, ITALIC or BOLD|ITALIC)
size - is the integer value that specifies theh size on the font.

An example of using the above would be :

Font font=new Font("Comic Sans Ms",PLAIN,12);

Once you've created the Font object you can set the font of a Label, TextArea, etc to the perticular Font using the setFont(Font); method. Here's How....

TextArea ta=new TextArea("www.ParthSoft.cjb.net");
Font font=new Font("Comic Sans Ms",PLAIN,12);

ta.setFont(font);



The above call would work even if ta was an object of the Label class. As the method setFont is inherited from java.awt.Component, it can be applied to all the classes that are inherited from the Component class...

Your Second question relates to using Dialogs. Since your question is not very specific. Here is an example of how to create a Dialog :

Dialog d=Dialog(Dialog owner, String title);
d.setSize(int Width,int Height);
d.setLocation(int Left,int Top);
d.setVisible(boolean);


If your new Big Idea doesn't scare the hell out of you, <br />it's probably not a "new Big Idea".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: font size, and dialogbox