Details about the drawString() method in Java
drawString is one of the most used method from teh Graphics class to generate text out in a Swing Window. The drawString() method can be used with abstract and void modifiers.
General Syntax
i) drawString(String str, int x, int y)
ii) drawString(AttributedCharacterIterator iterator, int x, int y)
i) drawString(String str, int x, int y)
String str is the string that can be displayed on the screen. Integer type x and y are the variables hold the x and y position on the graphical window.
ii) drawString(AttributedCharacterIterator iterator, int x, int y)
Renders the text of the specified iterator applying its attributes in accordance with the specification of the TextAttribute class. An AttributedCharacterIterator allows iteration through both text and related attribute information. An attribute is a key/value pair, identified by the key. No two attributes on a given character can have the same key. The values for an attribute are immutable, or must not be mutated by clients or storage. They are always passed by reference, and not cloned.
Example Program to Demonstrate drawString() method:
// drawString example program
import java.awt.*;
import java.applet.*;
public class HelloWorldApplet extends Applet{
public void paint(Graphics g) {
g.drawString("Hello World", 100, 100);
}
}
Another interesting articles The programming was very easily understand and more important coding are provided.this is very valuable in my studies,all coding easily understand.
ReplyDeletesap basis training in chennai
While i execute this code ,it is showing that main method isnt found.pls help
ReplyDeleteapplet programs DO NOT have main method. And also they are not executed as a normal java program. You have to use either a tag-based program or appletviewer
DeleteYou would realize that you would be able to easily find and buy graphics software according to your needs and according to reliability if you would only know how. Adobe After Effects CC 2014
ReplyDeleteapplet viewer code comment
ReplyDeleteI simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
ReplyDeletejava training in chennai
This comment has been removed by the author.
ReplyDeleteThese fundamental perspectives would frame an ideal setting to urge the designer to work either alone or inside a group, with a constructive outcome and results which will manage him towards imagination.sun Clipart
ReplyDeletebookkeeping configuration to guarantee that the result of the business logo likewise looks proficient and that it can altogether met the majority of your requirements for acknowledgment. logo design service
ReplyDeleteYour blog has chock-a-block of useful information. I liked your blog's content as well as its look. In my opinion, this is a perfect blog in all aspects. Image background removal service
ReplyDelete
ReplyDeleteThis is an awesome post.Really very informative and creative contents.
Logo design company in chennai