import java.awt.*;
import javax.swing.*;
public class even extends JFrame {
Container comp;
mypanel my=new mypanel();
even(){
setTitle("기하학적 모양");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
comp=getContentPane();
comp.add(my, BorderLayout.CENTER);
setSize(400,400);
setVisible(true);
}
class mypanel extends JPanel{
int x[]= {this.getWidth()/2, 0, this.getWidth()/2, this.getWidth()};
int y[]= {0, this.getHeight()/2, this.getHeight(), this.getHeight()/2};
public void paintComponent(Graphics g){
super.paintComponent(g);
for(int i=0; i<10; i++){
g.drawPolygon(x, y, 4);
x[1]+=i*10;
x[2]-=i*10;
y[0]+=i*10;
y[3]-=i*10;
}
}
}
public static void main (String args[]){
new even();
}
}
int x[]= {this.getWidth()/2, 0, this.getWidth()/2, this.getWidth()};
int y[]= {0, this.getHeight()/2, this.getHeight(), this.getHeight()/2};
g.drawPolygon(x, y, 4);
이런식으로 해야하는데 내가생각할땐 저 배열에 값저장이 안되는거같음
검색좀 해보니까 뭐 getPreferredSize 메소드를 오버라이딩해서 어쩌고 하라는데
api찾아봤는데 내가 지금 Dimention 클래스를 배우지도않았고..
댓글 0