자바GUI실전프로그래밍2_장대원.PDF

Similar documents
9장.key

rmi_박준용_final.PDF

JMF3_심빈구.PDF

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

01-OOPConcepts(2).PDF

JMF2_심빈구.PDF

MasoJava4_Dongbin.PDF

05-class.key

Microsoft PowerPoint - 04-UDP Programming.ppt

11장.key

Microsoft PowerPoint - ÀÚ¹Ù08Àå-1.ppt

제8장 자바 GUI 프로그래밍 II

Microsoft PowerPoint - EEL2 Lecture10 -Swing and Event Handling.pptx

09-interface.key

<4D F736F F F696E74202D20C1A63236C0E520BED6C7C3B8B428B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

gnu-lee-oop-kor-lec10-1-chap10

JTable과 MVC(Model-View-Controller) 구조 - 모델-뷰-컨트롤러구조는데이터의저장과접근에대한제공은모델이담당하고, 화면표시는뷰, 이벤트의처리는컨트롤러가하도록각역할을구분한구조이다. 즉, 역할의분담을통하여상호간의영향을최소화하고각요소의독립성을보장하여독자

10장.key

PowerPoint Presentation

강의자료

Chap12

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

비긴쿡-자바 00앞부속

02 C h a p t e r Java

PowerPoint 프레젠테이션

Java Programing Environment

5장.key

public class FlowLayoutPractice extends JFrame { public FlowLayoutPractice() { super("flowlayout Practice"); this. Container contentpane = getcontentp

PowerPoint Presentation

중간고사

자바 프로그래밍

PowerPoint 프레젠테이션

Microsoft PowerPoint - 14주차 강의자료

Microsoft PowerPoint - [JAVA프로그래밍]9장GUI

PowerPoint 프레젠테이션

Microsoft PowerPoint - java1-lecture11.ppt [호환 모드]

슬라이드 1

Microsoft PowerPoint - Java-03.pptx

<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

8장.그래픽 프로그래밍

12-file.key

No Slide Title

PowerPoint 프레젠테이션

PowerPoint Presentation

슬라이드 1

DB 에데이터저장을위한입력창설계 - JLabel, JTextField, JButton 을이용한입력창설계 - 2 -

Java Coding Standard

ch09

07 자바의 다양한 클래스.key

No Slide Title

11-GUI.key

1

쉽게 풀어쓴 C 프로그래밍

PowerPoint 프레젠테이션

Java ~ Java program: main() class class» public static void main(string args[])» First.java (main class ) /* The first simple program */ public class

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

03장

Microsoft PowerPoint - java2-lecture5.ppt [호환 모드]

Spring Data JPA Many To Many 양방향 관계 예제

PowerPoint Presentation

PowerPoint Presentation

DocsPin_Korean.pages

PowerPoint 프레젠테이션

Microsoft PowerPoint - ÀÚ¹Ù08Àå-2.ppt

Microsoft PowerPoint 자바-AWT컴포넌트(Ch8).pptx

PowerPoint 프레젠테이션

제8장 자바 GUI 프로그래밍 II

10-Java Applet

JavaGeneralProgramming.PDF

자바로

Microsoft PowerPoint - java1-lecture10.ppt [호환 모드]

( )부록

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

UML

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

Interstage5 SOAP서비스 설정 가이드

Week3

자바 쓰레드 능숙하게 다루기

iii. Design Tab 을 Click 하여 WindowBuilder 가자동으로생성한 GUI 프로그래밍환경을확인한다.

Modern Javascript

JMF1_심빈구.PDF

03-JAVA Syntax(2).PDF

Microsoft PowerPoint - lec04_05.ppt [호환 모드]

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

gnu-lee-oop-kor-lec06-3-chap7

JAVA PROGRAMMING 실습 08.다형성

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint - Java7.pptx

Contents. 1. PMD ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 2. Metrics ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 3. FindBugs ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 4. ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ

모든스윙컴포넌트에는텍스트옆에이미지를추가로표시할수있다. ImageIcon image = new ImageIcon("image.gif"); JLabel label = new JLabel(" 이미지레이블 "); label.seticon(image);

(Microsoft PowerPoint - java1-lecture7.ppt [\310\243\310\257 \270\360\265\345])

Microsoft Word - java18-1-final-answer.doc

Spring Boot/JDBC JdbcTemplate/CRUD 예제

PowerPoint 프레젠테이션

JavaPrintingModel2_JunoYoon.PDF

Java

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

PowerPoint Presentation

Transcription:

<JSTORM> JAVA GUI - 2 JSTORM http://wwwjstormpekr

JAVA GUI - 2 Issued by: < > Document Information Document title: JAVA GUI - 2 Document file name: Revision number: <10> Issued by: Issue Date: <2000/8/23 > Status: GUI 2_ doc < > dwjang@jkdsoftcokr : < > junoyoon@orgionet final Content Information Audience Abstract Reference Benchmark information GUI SWING - SWING SWING JSTORM <2/37>

JAVA GUI - 2 Issued by: < > Document Approvals Signature date Signature date Revision History Revision Date Author Description of change JSTORM <3/37>

JAVA GUI - 2 Issued by: < > Table of Contents 5 JComponent 6 (Visibility) (Opaqueness) 7 8 JComponent 9 MVC 12 Model, View, Controller 13 GCad 16 16 MVC17 27 (Composit) 27 JSTORM <4/37>

JAVA GUI - 2 Issued by: < > GUI! AWT GUI AWT (?) SwingSet ([ 1], SwingSet c:\jdk12\demo\jfc\swingset ), JSTORM <5/37>

JAVA GUI - 2 Issued by: < > GUI AWT GUI GUI (?) GUI ( ) GUI! Jr 5 5 5 JComponent (JApplet, JDialog, JFrame, JWindow) JComponent ([ 1][ 2] ) JComponent JComponent JComponent AWTContainer Container Component JComponent JSTORM <6/37>

JAVA GUI - 2 Issued by: < > Component Container JComponent (Visibility) (Opaqueness) JComponent ( 995 319 ) AWT JComponent 100 (Visibility) JFrame framesetvisible(true); dialogshow(); JButton buttonsetvisible(true); JButton JFrame? JFrame JButton AWT ( ) setopaque() truefalse true [ 2] 25 JSTORM <7/37>

JAVA GUI - 2 Issued by: < > ( ) [ 1] AboutDialogjava JComponent AWT AWT update() update() paint() update() update() paint() Canvas paint() AWT AWT public class GCanvas extends JPanel { public void paintcomponent(graphics g) { JSTORM <8/37>

JAVA GUI - 2 Issued by: < > JPanel AWTCanvas? AWTCanvas Canvas JCanvas Panel JPanel JPanel Canvas JPanel paintcomponent() AWT paint() paint() paintcomponent() AWT [1] paintcomponent() paintborder() paintchildren() paint() paint() [1] paint() paintcomponent() JComponent JSTORM <9/37>

JAVA GUI - 2 Issued by: < > JComponent JComponent JComponent JComponent Component Container [2] UI MVC(Model, View, Controller) MVC? [2] true setborder()? JSTORM <10/37>

JAVA GUI - 2 Issued by: < > JSTORM <11/37>

JAVA GUI - 2 Issued by: < > MVC MVC MVCModel, View, Controller MVC MVC MVC? ( ) (State) [ 2]?? [ 2], v JSTORM <12/37>

JAVA GUI - 2 Issued by: < >? 98 [ 2]? PLAF(Pluggable Look and F eel) Jr 5 MVC? (Control)? CIH Model, View, Controller [ 4] ( ) [ 4] UI JSTORM <13/37>

JAVA GUI - 2 Issued by: < > 98 ([ 3]) UI (Delegate) UI Model Model UI UI JButton ButtonModel ButtonUI UI MVC MVC JSTORM <14/37>

JAVA GUI - 2 Issued by: < > [ 1] ( ) public class GugudanModelDemo extends JFrame { public GugudanModelDemo() { super(" "); GugudanTableModel mymodel = new GugudanTableModel(); JTable table = new JTable(myModel); <<--- [1 ] getcontentpane()add(tablegettableheader(), BorderLayoutNORTH); getcontentpane()add(table, BorderLayoutCENTER); public static void main(string[] args) { GugudanModelDemo frame = new GugudanModelDemo(); framepack(); framesetvisible(true); // class GugudanTableModel extends AbstractTableModel { <<--- [2] public int getcolumncount() { return 9; public int getrowcount() { return 9; public String getcolumnname(int col) { return "" + (col+1); public Object getvalueat(int row, int col) { return new Integer((row+1)*(col+1)); [ 1][2] JSTORM <15/37>

JAVA GUI - 2 Issued by: < > AbstractTableModel [1 ] setmodel() 4 364 MVC MVC MVC MVC GCad MVC MVC MVC GEditor GEditor GCad MVC [ 5]GCad Jr GEditor GStatus GStatus,,,, GStatus GStatus JSTORM <16/37>

JAVA GUI - 2 Issued by: < > GStatus GStatus GMenu, GToolBar, GColorTable? GStatus GStatus GStatus ~ GStatusMVC GMenu, GToolBar, GColorTable MVC? GMenu, GToolBar, GColorTable GStatusBar GUI [ 5] [ 7] GStatus GStatusgetOutlineColor() (GStatusBar), [ 5] MVC GCad, GDocument, GCanvas GCad( GEditor ), GCanvas GDocument GDocument GCad ( JSTORM <17/37>

JAVA GUI - 2 Issued by: < > ) GDocument GDocument GCanvas GDocument, GCanvas, GCad MVC GDocument GCanvasGDocument GCadGDocument GDocument MVC MVC MVC [ 2] GStatus package gcad; import gcadgobject*; import gcadgui*; import javaawt*; /////////////////////////////////////////////////////////////// public class GStatus { // private int m_selectedshape = GShapeLINE; // private Color m_backgroundcolor = Colorwhite; // private Color m_outlinecolor = Colorblack; // private int m_outlinewidth = 1; // private boolean m_isfill = false; // private Color m_fillcolor = Colorwhite; // Status (Controller) (View) private GToolBar m_toolbar; private GColorTable m_colortable; private GMenu m_menu; JSTORM <18/37>

JAVA GUI - 2 Issued by: < > private GStatusBar m_statusbar; // public void settoolbar(gtoolbar toolbar) { m_toolbar = toolbar; public void setmenu(gmenu menu) { m_menu = menu; public void setstatusbar(gstatusbar statusbar) { m_statusbar = statusbar; public void setcolortable(gcolortable colortable) { m_colortable = colortable; public int getselectedshape() { return m_selectedshape; public void setselectedshape(int shape) { m_selectedshape = shape; updateviews(); <<--- [1 ] public Color getbackgroundcolor() { return m_backgroundcolor; public void setbackgroundcolor(color color) { m_backgroundcolor = color; updateviews(); public Color getoutlinecolor() { return m_outlinecolor; public void setoutlinecolor(color color) { m_outlinecolor = color; updateviews(); public int getoutlinewidth() { return m_outlinewidth; public void setoutlinewidth(int width) { m_outlinewidth = width; public boolean isfill() { return m_isfill; public void setfill(boolean fill) { m_isfill = fill; updateviews(); JSTORM <19/37>

JAVA GUI - 2 Issued by: < > public Color getfillcolor() { return m_fillcolor; public void setfillcolor(color color) { m_fillcolor = color; updateviews(); // private void updateviews() { m_toolbarupdate(); m_colortableupdate(); m_menuupdate(); m_statusbarupdate(); <<--- [2 ] [ 2] [1 ]? GStatus [1 ] [2 ] update() [ 3][1 ] update(), GStatus MVC? [ 3][2 ]? (Static initializer) (Attribute)? { package gcadgui; [ 3] GColorTable import gcad*; import javaawt*; import javaawtevent*; import javaxswing*; JSTORM <20/37>

JAVA GUI - 2 Issued by: < > ///////////////////////////////////////////////////////////////// public class GColorTable extends JPanel { /** (, ) */ private static final Dimension TABLE_SIZE = new Dimension(2, 8); /** */ private static final Dimension CELL_SIZE = new Dimension(30, 30); /** */ private static final Color[] CELL_COLORS = { ; new Color( 0, 0, 0), new Color(128, 0, 0), new Color( 0, 128, 0), new Color(128, 128, 0), new Color( 0, 0, 128), new Color(128, 0, 128), new Color( 0, 128, 128), new Color(192, 192, 192), new Color(128, 128, 128), new Color(255, 0, 0), new Color( 0, 255, 0), new Color(255, 255, 0), new Color( 0, 0, 255), new Color(255, 0, 255), new Color( 0, 255, 255), new Color(255, 255, 255) /* private static final Color[] CELL_COLORS = new Color[TABLE_SIZEheight*TABLE_SIZEwidth]; // Static initializer <<--- [2 ] { int colorcount = TABLE_SIZEheight*TABLE_SIZEwidth; for (int i=0; i<colorcount; i++) { CELL_COLORS[i] = new Color(i*(255/colorCount), 0, 0); */ // Status JSTORM <21/37>

JAVA GUI - 2 Issued by: < > private GStatus m_status; /** */ private SelectedColorCell m_selectedcolorcell; public GColorTable(GStatus status) { m_status = status; m_statussetcolortable(this); setborder(borderfactorycreateetchedborder()); // JPanel standardcolorspane = new JPanel(); standardcolorspanesetlayout(new GridLayout(0, TABLE_SIZEwidth)); for (int i=0; i<cell_colorslength; i++) { standardcolorspaneadd(new ColorCell(CELL_COLORS[i])); // m_selectedcolorcell = new SelectedColorCell(); m_selectedcolorcelladdmouselistener(new MouseAdapter() { ); public void mouseclicked(mouseevent e) { Color oldcolor = m_statusgetoutlinecolor(); Color newcolor; newcolor = JColorChoosershowDialog(null, " ", oldcolor); m_statussetoutlinecolor(newcolor); // JPanel colorpane = new JPanel(); colorpanesetlayout(new BorderLayout()); colorpaneadd(standardcolorspane, BorderLayoutNORTH); colorpaneadd(new JSeparator(SwingConstantsVERTICAL)); colorpaneadd(m_selectedcolorcell, BorderLayoutSOUTH); setlayout(new BorderLayout()); add(colorpane, BorderLayoutNORTH); JSTORM <22/37>

JAVA GUI - 2 Issued by: < > public void update() { Color color = m_statusgetoutlinecolor(); m_selectedcolorcellrepaint(); <<--- [1 ] ///////////////////////////////////////////////////////////////// /** */ private class ColorCell extends JPanel { /** */ private Color m_color; // ----------------------------------------------------------- // : public ColorCell(Color color) { m_color = color; setborder(borderfactorycreateetchedborder()); setpreferredsize(cell_size); addmouselistener(new MouseAdapter() { public void mouseclicked(mouseevent e) { m_statussetoutlinecolor(m_color); ); // ----------------------------------------------------------- public void paintcomponent(graphics g) { gsetcolor(m_color); gfilloval(2, 2, getsize()width-4, getsize()height-4); ///////////////////////////////////////////////////////////////// private class SelectedColorCell extends JPanel { // ----------------------------------------------------------- public SelectedColorCell() { setborder(borderfactorycreateetchedborder()); setpreferredsize(new Dimension( 2*CELL_SIZEwidth, 2*CELL_SIZEheight)); JSTORM <23/37>

JAVA GUI - 2 Issued by: < > // ----------------------------------------------------------- public void paintcomponent(graphics g) { Color color = m_statusgetoutlinecolor(); gsetcolor(color); gfillrect(2, 2, getsize()width-4, getsize()height-4); package gcad; [ 4] GDocument import gcadgobject*; import javautil*; import javaio*; ////////////////////////////////////////////////////////////// public class GDocument { // private Vector m_shapes = new Vector(); // public void addshape(gshape shape) { m_shapesaddelement(shape); // public Enumeration getshapes() { return m_shapeselements(); // public void clear() { m_shapesremoveallelements(); // public void save() { JSTORM <24/37>

JAVA GUI - 2 Issued by: < > // public void load() { JSTORM <25/37>

JAVA GUI - 2 Issued by: < > JSTORM <26/37>

JAVA GUI - 2 Issued by: < > [ 8] CompositGObject (Composit) CompositGObject GCad (Grouping) GCrossedRectangle? (JTextField, JTextArea, JEditorPane JTextPane ) [ 5] (Composit) 3 260 JSTORM <27/37>

JAVA GUI - 2 Issued by: < > [ 6] CompositGObject GObject (Composit) CompositGObject GObject CompositGObject GObject (implements) (is a) GObject [ 5][ 6] UML ( ) UML http://wwwrationalcom/uml/ 12 374 (implements) (extends) (Composit Aggregation) GObject, GShape, GLine [ 7][1 ] 2D 2D GEditor Graphics 2D 2D JDK 2D [ 5] GObject JSTORM <28/37>

JAVA GUI - 2 Issued by: < > package gcadgobject; import javaawt*; import javaio*; ///////////////////////////////////////////////////////////////// public interface GObject extends Serializable { // public abstract void draw(graphics g); // public abstract void erase(graphics g); [ 6] GShape package gcadgobject; import javaawt*; ///////////////////////////////////////////////////////////////// public abstract class GShape implements GObject { // public static final int LINE = 1; public static final int RECTANGLE = 2; public static final int SQUARE = 3; public static final int ELLIPSE = 4; public static final int CIRCLE = 5; // protected Color m_outlinecolor = Colorblack; // protected int m_outlinewidth = 1; // protected boolean m_isfill = false; JSTORM <29/37>

JAVA GUI - 2 Issued by: < > // protected Color m_fillcolor = Colorwhite; // public Color getoutlinecolor() { return m_outlinecolor; public void setoutlinecolor(color color) { m_outlinecolor = color; public int getoutlinewidth() { return m_outlinewidth; public void setoutlinewidth(int width) { m_outlinewidth = width; public boolean isfill() { return m_isfill; public void setfill(boolean fill) { m_isfill = fill; public Color getfillcolor() { return m_fillcolor; public void setfillcolor(color color) { m_fillcolor = color; // ( ) public abstract void setpenposition(point point); // public void erase(graphics g) { gsetxormode(colorwhite); draw(g); [ 7] GLine package gcadgobject; import javaawt*; ///////////////////////////////////////////////////////////////// public class GLine extends GShape { // private Point m_startpoint; // private Point m_ endpoint; JSTORM <30/37>

JAVA GUI - 2 Issued by: < > public GLine(Point point) { m_startpoint = point; m_endpoint = point; // ( ) public void setpenposition(point point) { m_endpoint = point; // public void draw(graphics g) { Graphics2D g2 = (Graphics2D)g; <<--- [1 ] Stroke oldstroke = g2getstroke(); g2setstroke(new BasicStroke(m_outlineWidth)); g2setcolor(m_outlinecolor); g2drawline(m_startpointx, m_startpointy, m_endpointx, m_endpointy); g2setstroke(oldstroke); GCad JSTORM <31/37>

JAVA GUI - 2 Issued by: < > JSTORM <32/37>

JAVA GUI - 2 Issued by: < > JSTORM <33/37>

JAVA GUI - 2 Issued by: < > JSTORM <34/37>

JAVA GUI - 2 Issued by: < > JSTORM <35/37>

JAVA GUI - 2 Issued by: < > JSTORM <36/37>

JAVA GUI - 2 Issued by: < > JSTORM <37/37>