2
여기 간단한 코드가 있습니다. JPanel
에 그려진 타원을 추가하는 방법을 모르겠습니다. 전에 그림을 그리기도했지만 생성자를 사용한 적이 없으므로 생각이 없습니다.JPanel에 타원형 모양 추가
public class Buffer extends JPanel{
public JFrame frame;
public JPanel panel;
public Buffer(){
frame=new JFrame();
panel=new JPanel();
panel.setSize(500,500);
panel.setBackground(Color.red);
frame.setSize(500,500);
frame.setVisible(true);
frame.add(panel);
}
public void paintComponent(Graphics g){
super.paintComponents(g);
g.fillOval(20,20,20,20);
}
public static void main(String args[]){
new Buffer();
}
}