Drew Rectangle in Java Example
Drew Rectangle in Java Example..
-------------------------------------------------------------------------------------
/**
* @(#)MainClass11.java
*
*
* @author Satya
* @https://www.facebook.com/
* @http://satyarahulraj.blogspot.in/
* @version 1.00 2012/11/3
*/
import java.awt.Graphics;
import java.awt.*;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MainClass11 extends JPanel {
public void paint(Graphics g) {
g.drawString(g.getClipBounds().toString(), 10, 30);
g.setColor(Color.RED);
g.clipRect(10, 40, getSize().width - 20, getSize().height - 80);
g.fillOval(0, 0, getSize().width, getSize().height);
String newClip = g.getClipBounds().toString();
g.setClip(0, 0, getSize().width, getSize().height);
g.drawString(newClip, 10, getSize().height - 10);
}
public static void main(String[] args) {
JFrame frame = new JFrame("http://www.SatyaRahulRaj.blogspot.com");
frame.getContentPane().add(new MainClass11());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
0 comments :