Source Code : drawString(): specify the position of the text on the window area
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
drawString(): specify the position of the text on the window area

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Text extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHints(rh);
Font font = new Font("New Roma", Font.BOLD, 40);
g2d.setFont(font);
g2d.drawString("text", 20, 30);
}
public static void main(String[] args) {
Text text = new Text();
JFrame frame = new JFrame("Sonnet 55");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(text);
frame.setSize(500, 470);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Thank with us