1
package com.szsm.swing.framepanel;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.szsm.swing.parent.FrameSet;
public class CavasFrame extends FrameSet {
public static void main(String[] args) {
new CavasFrame();
}
public CavasFrame() {
}
protected void initInterface()
{
super.initInterface();
parentContainer.add(new RectPanel());
}
protected void init()
{
this.setLocation(400,100);
this.setSize(400,300);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
protected void initend()
{
super.initend();
}
private void initen() {
this.setVisible(true);
}
class RectPanel extends JPanel
{
@Override
protected void paintComponent(Graphics g) {
System.out.println("先这里");
super.paintComponent(g);
g.drawRect(10, 10, 10, 10);
g.drawOval(30, 30, 30, 30);
g.drawOval(80, 80, 40, 30);
int[] xs = {10, 50, 30};
int[] ys = {80, 80, 110};
g.drawPolygon(xs, ys, 3);
}
}
}
2