±Û¾´ÀÌ :±Ç¸í¿ø 1999³â 11¿ù 01ÀÏ 18:10:33
In Reply to: [´äº¯] Swing¿¡¼ Canvas ´ë½Å »ç¿ëÇÏ´Â °Í. posted by À¯ºÀÃá on 1999³â 7¿ù 15ÀÏ 08:21:50:
SwingÀ» »ç¿ëÇÒ ¶§ JPanel µîÀ» »ç¿ëÇÏ¿© ±× À§¿¡ ±×·¡ÇÈ ÀÛ¾÷À» ÇÒ ¼ö ÀÖ½À´Ï´Ù.
¹°·Ð À̶§ ÁÖÀÇ ÇÏ¼Å¾ß ÇÒ °ÍÀº
JComponent´Â component, boder, childrenÀ» °¡Áö°í ÀÖ½À´Ï´Ù.
±×·¡¼ ÀϹÝÀûÀ¸·Î JComponetÀÇ paint() ´ë½Å paintComponent(), paintBorder(), paintChildren()¿¡
°¡ »ç¿ëµË´Ï´Ù.
±×·¡ÇÈ ÀÛ¾÷À» ÇÒ ¶§´Â ¹°·Ð JPanelÀ» Çϳª ¸¸µå½Å ÈÄ ±×ÀÇ paintComponent()¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù.
¹°·Ð paint()¸¦ »ç¿ëÇصµ µÇ±ä ÇÕ´Ï´Ù.
±×¸®°í ±×·¡ÇÈ ³»¿ëÀÌ Å¬ °æ¿ì JScrollPaneÀ» »ç¿ëÇØ¾ß ÇÒ °Í °°Àºµ¥ ÀÌ·² ¶§´Â
JScrollPane ¾È¿¡ JPanelÀ» ¸¸µé¸é µÉ µí ÇÕ´Ï´Ù.
Áï,
JScrollPane scrollpane = new JScrollPane();
JPanel graph = new JPanel();
scrollpane.setViewportVIew(graph);
setLayout(new BorderLayout());
add(scrollpane);
ÀÌ·± ½ÄÀ¸·Î¿ä....