JAVA 캔버스를 패널에 붙일 수 있을까요?
조회수 1456회
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 500, 500);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
contentPane.add(tabbedPane);
JPanel panel = new JPanel();
tabbedPane.addTab("사진 효과", null, panel, null);
JPanel panel_1 = new JPanel();
tabbedPane.addTab("그림판", null, panel_1, null);
panel.setLayout(new BorderLayout(0, 0));
JTabbedPane을 이용해서 두 가지 패널을 나누어 만들었습니다.
public class JYCanvas extends Canvas{
int x=50;
int y=50;
int width=7;
int height=7;
Color color=Color.black;
public void paint(Graphics g){
g.setColor(color);
g.fillOval(x, y, width, height);
}
public void update(Graphics g){
paint(g);
}
}
panel_1에 canvas를 add하고 싶은데 안 되네요. 혹시 방법이 있을까요?
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력