<div><span style="font-size: 9pt; color: blue; font-family: 'Courier New'; line-height: normal"><font size="2">import</font></span><font size="2" style="line-height: normal"><span style="font-family: 'Courier New'"> java.awt.*; </span></font></div><font size="2"><span style="font-family: 'Courier New'; line-height: normal; color: blue">import</span><span style="font-family: 'Courier New'; line-height: normal"> java.awt.event.*; </span><br style="font-family: 'Courier New'; line-height: normal" /><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">class</span><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">extends</span><span style="font-family: 'Courier New'; line-height: normal"> Frame { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuBar _mb = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Menu _file = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItem _new = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItem _load = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItem _saveAs = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Panel img_panel = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Button b1 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; Button b2 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Button b3 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; Button b4 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Panel buttons = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> FileDialog fd = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Toolkit tk = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Image img = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Image img_called = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Graphics gImg = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">static</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> main(String[] args) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering ifr = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Image Filtering Test"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 생성자</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering(String title) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// Frame을 상속받았으므로 super는 Frame</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">super</span><span style="font-family: 'Courier New'; line-height: normal">(title); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 일단 x버튼으로 종료시켜야 하니까....</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> addWindowListener(</span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> WindowAdapter() { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> windowClosing(WindowEvent we) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> we.getWindow().setVisible(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">false</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> we.getWindow().dispose(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> System.exit(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">0</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> }); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 이미지를 보여줄 패널</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> img_panel = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Panel(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> img = img_panel.createImage(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">600</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">600</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 메뉴바 만들고, 이벤트 리스너도 등록하고</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _mb = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuBar(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Menu(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"File"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _new = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItem(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"New"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _load = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItem(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Load"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _saveAs = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItem(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"SaveAs..."</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItemHandler mih = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItemHandler(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _new.addActionListener(mih); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _load.addActionListener(mih); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _saveAs.addActionListener(mih); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 버튼을 만들고, 이벤트리스터도 등록하고</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b1 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Filter1"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b2 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Filter2"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b3 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Filter3"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b4 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"+"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> ButtonHandler bh = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> ButtonHandler(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b1.addActionListener(bh); b2.addActionListener(bh); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b3.addActionListener(bh); b4.addActionListener(bh); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 이제 Frame에다가 붙여넣을거 붙여 넣고 고고고~</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">this</span><span style="font-family: 'Courier New'; line-height: normal">.setMenuBar(_mb); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _mb.add(_file); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file.add(_new); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file.add(_load); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file.add(_saveAs); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> add(img_panel, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Center"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> buttons = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Panel(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> buttons.add(b1); buttons.add(b2); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> buttons.add(b3); buttons.add(b4); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> add(buttons, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"South"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> setLocation(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">100</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">100</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> setSize(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">600</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">600</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> setVisible(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">true</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// ImageFiltering(String title)</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> paint(Graphics g) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(img != </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// Image의 크기를 얻는다.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">//int imgWidth = img.getWidth(this.img_panel); // getWidth(ImageObserver obj)</span><span style="font-family: 'Courier New'; line-height: normal"></span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">//int imgHeight = img.getHeight(this.img_panel); // getHeight(ImageObserver obj)</span><span style="font-family: 'Courier New'; line-height: normal"></span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 이미지를 img_panel 중앙에 출력</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> gImg = img_panel.getGraphics(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> gImg.drawImage(img, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">0</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">0</span><span style="font-family: 'Courier New'; line-height: normal">, img_panel); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// paint(Graphics g)</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 메뉴아이템 이벤트 핸들러, New, Load, SaveAs....</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">class</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItemHandler </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">implements</span><span style="font-family: 'Courier New'; line-height: normal"> ActionListener { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> actionPerformed(ActionEvent ae) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == _new) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 화면 비우기</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == _load) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> fd = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> FileDialog(ImageFiltering.</span><span style="font-family: 'Courier New'; line-height: normal; color: blue">this</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Load"</span><span style="font-family: 'Courier New'; line-height: normal">, FileDialog.LOAD);</span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> fd.setVisible(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">true</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> String fileName = fd.getDirectory() + fd.getFile(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> tk = Toolkit.getDefaultToolkit(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> img = tk.getImage(fileName); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> repaint(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == _saveAs) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 보이는 화면 그대로 저장.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// class MenuItemHandler</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 버튼 이벤트 핸들러. 필터링 작업 실시.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">class</span><span style="font-family: 'Courier New'; line-height: normal"> ButtonHandler </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">implements</span><span style="font-family: 'Courier New'; line-height: normal"> ActionListener { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> actionPerformed(ActionEvent ae) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b1) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 필터링 작업1</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b2) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 필터링 작업2</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b3) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 필터링 작업3</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b4) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 효과 합치기.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// class ButtonHandler</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal">} </span></font> <div><font face="Courier New" size="2"><span style="line-height: normal"><br /></span></font> <div><font face="Courier New" size="2"><span style="line-height: normal"><br /></span></font> <div><font size="2"><span style="font-family: 'Courier New'; line-height: normal"><br /></span></font></div> <div> <div><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">이미지파일을 가져와서요</span></div> <div><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">버튼을 누르면 필터링작업을 시키고 저장하는 프로그램을 만들려고 해요 (연습용이에요).</span></div> <div><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">근데 이거....파일 불러오는 것도 두 번은 불러와야 이미지가 화면에 뜨구요...</span></div> <div><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">그마저도 화면크기 좀만 조절시켜도 화면이 다시 하얘지고 그래요 ㅜㅜ</span></div></div> <div><font face="Courier New" size="3"><span style="line-height: normal">이미지를 Panel에 띄우지 말고 Frame에 직접 띄우는 방식으로 고치면(아래 코드처럼 고치면) 대충 해결은 되는듯 보이는데요</span></font></div> <div><font face="Courier New" size="3"><span style="line-height: normal">Frame에 좀 더 많은 Panel을 넣을 생각이라서요...어떻게해서든 img_panel에다가 그림을 그려넣고싶어요 ㅜㅜ 어케 해야할까요 ㅜㅜ?</span></font></div> <div><font color="#0000ff" face="Courier New" size="3"><span style="line-height: normal"><br /></span></font></div> <div><font size="2"><span style="font-family: 'Courier New'; line-height: normal; color: blue">import</span><span style="font-family: 'Courier New'; line-height: normal"> java.awt.*; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal; color: blue">import</span><span style="font-family: 'Courier New'; line-height: normal"> java.awt.event.*; </span><br style="font-family: 'Courier New'; line-height: normal" /><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">class</span><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering3 </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">extends</span><span style="font-family: 'Courier New'; line-height: normal"> Frame { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuBar _mb = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Menu _file = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItem _new = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItem _load = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItem _saveAs = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// Panel img_panel = null;</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Button b1 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; Button b2 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Button b3 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; Button b4 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Panel buttons = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> FileDialog fd = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Toolkit tk = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Image img = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Image img_called = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> Graphics gImg = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">; </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">static</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> main(String[] args) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering3 ifr = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering3(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Image Filtering Test"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 생성자</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> ImageFiltering3(String title) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// Frame을 상속받았으므로 super는 Frame</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">super</span><span style="font-family: 'Courier New'; line-height: normal">(title); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 일단 x버튼으로 종료시켜야 하니까....</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> addWindowListener(</span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> WindowAdapter() { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> windowClosing(WindowEvent we) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> we.getWindow().setVisible(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">false</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> we.getWindow().dispose(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> System.exit(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">0</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> }); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 이미지를 보여줄 패널</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// img_panel = new Panel();</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// img = img_panel.createImage(600, 600);</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 메뉴바 만들고, 이벤트 리스너도 등록하고</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _mb = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuBar(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Menu(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"File"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _new = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItem(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"New"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _load = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItem(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Load"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _saveAs = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItem(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"SaveAs..."</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> MenuItemHandler mih = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItemHandler(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _new.addActionListener(mih); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _load.addActionListener(mih); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _saveAs.addActionListener(mih); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 버튼을 만들고, 이벤트리스터도 등록하고</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b1 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Filter1"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b2 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Filter2"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b3 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Filter3"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b4 = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Button(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"+"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> ButtonHandler bh = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> ButtonHandler(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b1.addActionListener(bh); b2.addActionListener(bh); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> b3.addActionListener(bh); b4.addActionListener(bh); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 이제 Frame에다가 붙여넣을거 붙여 넣고 고고고~</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">this</span><span style="font-family: 'Courier New'; line-height: normal">.setMenuBar(_mb); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _mb.add(_file); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file.add(_new); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file.add(_load); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> _file.add(_saveAs); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// add(img_panel, "Center");</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> buttons = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> Panel(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> buttons.add(b1); buttons.add(b2); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> buttons.add(b3); buttons.add(b4); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> add(buttons, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"South"</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> setLocation(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">100</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">100</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> setSize(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">600</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">600</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> setVisible(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">true</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// ImageFiltering(String title)</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> paint(Graphics g) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(img != </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">null</span><span style="font-family: 'Courier New'; line-height: normal">) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// Image의 크기를 얻는다.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">//int imgWidth = img.getWidth(this.img_panel); // getWidth(ImageObserver obj)</span><span style="font-family: 'Courier New'; line-height: normal"></span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">//int imgHeight = img.getHeight(this.img_panel); // getHeight(ImageObserver obj)</span><span style="font-family: 'Courier New'; line-height: normal"></span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 이미지를 img_panel 중앙에 출력</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// gImg = img_panel.getGraphics();</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// gImg.drawImage(img, 0, 0, img_panel);</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> g.drawImage(img, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">0</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">0</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">this</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// paint(Graphics g)</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 메뉴아이템 이벤트 핸들러, New, Load, SaveAs....</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">class</span><span style="font-family: 'Courier New'; line-height: normal"> MenuItemHandler </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">implements</span><span style="font-family: 'Courier New'; line-height: normal"> ActionListener { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> actionPerformed(ActionEvent ae) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == _new) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 화면 비우기</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == _load) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> fd = </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">new</span><span style="font-family: 'Courier New'; line-height: normal"> FileDialog(ImageFiltering3.</span><span style="font-family: 'Courier New'; line-height: normal; color: blue">this</span><span style="font-family: 'Courier New'; line-height: normal">, </span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">"Load"</span><span style="font-family: 'Courier New'; line-height: normal">, FileDialog.LOAD);</span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> fd.setVisible(</span><span style="font-family: 'Courier New'; line-height: normal; color: maroon">true</span><span style="font-family: 'Courier New'; line-height: normal">); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> String fileName = fd.getDirectory() + fd.getFile(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> tk = Toolkit.getDefaultToolkit(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> img = tk.getImage(fileName); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> repaint(); </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == _saveAs) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 보이는 화면 그대로 저장.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// class MenuItemHandler</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 버튼 이벤트 핸들러. 필터링 작업 실시.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">class</span><span style="font-family: 'Courier New'; line-height: normal"> ButtonHandler </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">implements</span><span style="font-family: 'Courier New'; line-height: normal"> ActionListener { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">public</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">void</span><span style="font-family: 'Courier New'; line-height: normal"> actionPerformed(ActionEvent ae) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b1) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 필터링 작업1</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b2) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 필터링 작업2</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b3) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 필터링 작업3</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">else</span><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; line-height: normal">(ae.getSource() == b4) { </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// 효과 합치기.</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal"> } </span><span style="font-family: 'Courier New'; line-height: normal; color: green">// class ButtonHandler</span><span style="font-family: 'Courier New'; line-height: normal"> </span><br style="font-family: 'Courier New'; line-height: normal" /><span style="font-family: 'Courier New'; line-height: normal">} </span></font></div></div></div>
<a href="http://blog.naver.com/finalboogi">
<img src="http://thimg.todayhumor.co.kr/upfile/201312/1387637645G9UumBQ6ZyDeaNnTpq.jpg"></a>
<style>#okNokBookDiv img{content:url("http://thimg.todayhumor.co.kr/upfile/201312/1387635212a6x9jURsp.jpg");}#okNokBookDiv img:nth-child(2){content:url("http://thimg.todayhumor.co.kr/upfile/201312/1387635212a6x9jURsp.jpg");}#okNokBookDiv a img{content:url("http://thimg.todayhumor.co.kr/upfile/201312/1387635212a6x9jURsp.jpg");}</style>
<STYLE> div.writerInfoBgMiddle {background-image:url(http://thimg.todayhumor.co.kr/upfile/201402/1391873950VuGynwQ3Xn8gP.png);} </STYLE>
<STYLE>#login_span span b a:before{content: "글냥이의 사역마 ";}#memo_insert_ div b:before{content: "글냥이의 사역마 ";}</STYLE>
<style>textarea{background:url(http://thimg.todayhumor.co.kr/upfile/201401/1388604479R9q6U8rB8uCQHJVyexn6.png);background-position:bottom right;}</style>
<style>div.whole_box {background: url('http://postfiles2.naver.net/20140119_177/finalboogi_1390115067400zzy7d_PNG/64363453245234524.png?type=w2'); background-attachment: fixed; background-repeat: no-repeat; background-position: bottom left; background-size: 200px;}</style>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.