9장.key

Similar documents
PowerPoint 프레젠테이션

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

PowerPoint 프레젠테이션

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

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

11장.key

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

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

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

10장.key

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

강의자료

PowerPoint Presentation

PowerPoint Presentation

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

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

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

10 이벤트 처리와 그래픽 프로그래밍.key

Microsoft PowerPoint - 04-UDP Programming.ppt

No Slide Title

PowerPoint 프레젠테이션

Java Programing Environment

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

11-GUI.key

Microsoft PowerPoint - Java-03.pptx

PowerPoint Presentation

Java Coding Standard

슬라이드 1

제13강. 스윙(Swing)

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

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

Microsoft PowerPoint - 12장_스윙 [호환 모드]

Microsoft PowerPoint - 14주차 강의자료

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

No Slide Title

05-class.key

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

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

<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

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

제1장 자바 언어 소개

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

PowerPoint 프레젠테이션

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

Cluster management software

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

Chap12

<4D F736F F F696E74202D20C1A63236C0E520BED6C7C3B8B428B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

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

PowerPoint Presentation

PowerPoint 프레젠테이션

歯제9장.PDF

Cluster management software

PowerPoint Presentation

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

슬라이드 1

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

02 C h a p t e r Java

중간고사

10-Java Applet

rmi_박준용_final.PDF

Microsoft PowerPoint - Java7.pptx

12장.그래픽 사용자 인터페이스

슬라이드 1

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

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

PowerPoint 프레젠테이션

<4D F736F F F696E74202D205B4A415641C7C1B7CEB1D7B7A1B9D65D3130C0E5C0CCBAA5C6AEC3B3B8AE>

JMF1_심빈구.PDF


PowerPoint 프레젠테이션

비긴쿡-자바 00앞부속

8장.그래픽 프로그래밍

09-interface.key

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

5장.key

Interstage5 SOAP서비스 설정 가이드

PowerPoint 프레젠테이션

01-OOPConcepts(2).PDF

Microsoft PowerPoint - 06-Chapter09-Event.ppt

Cluster management software

오버라이딩 (Overriding)

자바 프로그래밍

12-file.key

연습문제이론홀수정답

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

Dialog Box 실행파일을 Web에 포함시키는 방법

JMF3_심빈구.PDF

쉽게 풀어쓴 C 프로그래밍

이것만은 알고 갑시다 정답

PowerPoint Presentation

Ext JS À¥¾ÖÇø®ÄÉÀ̼ǰ³¹ß-³¹Àå.PDF

PowerPoint 프레젠테이션

Network Programming

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

Design Issues

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

Transcription:

JAVA Programming 1

GUI(Graphical User Interface) 2 GUI!,! GUI! GUI, GUI GUI! GUI AWT Swing AWT - java.awt Swing - javax.swing

AWT Swing 3 AWT(Abstract Windowing Toolkit)! GUI! java.awt! AWT (Heavy weight components) AWT native(peer) GUI. Swing()! AWT AWT + AWT J J! javax.swing! Swing (Light weight components) native(peer)

4 JButton JCheckBox JRadioButton JSlider JTextField JPasswordField JSpinner JTextArea JComboBox JList

JProgressBar JToolTip JMenu JScrollPane JDialog JFrame JColorChooser 5

JTable 6 JTree JEditorPane and JTextPane

JToolBar JTabbedPane JSplitPane 7

Swing GUI 8 JButton JLabel JTextField JMenu JToolBar JFrame JMenuBar JComboBox JList JLabel JScrollPane JSplitPane

GUI Object Font FontMetrics Component Dimension Color Graphics AWT Button Label TextComponent Container List Canvas Scrollbar Panel Window Checkbox Choice Applet Frame Dialog Swing JComponent JApplet JFrame JDialog JLabel JList JComboBox JSlider JTextComponent AbstractButton JScrollBar JPanel JLayeredPane JEditorPane JTextField JTextArea JOptionPane JTabbedPane JSplitPane JSeparator JRootPane JToolBar JPasswordField JMenuItem JButton JToggleButton JMenuBar JToolTip JPopupMenu JFileChooser JMenu JCheckBox JColorChooser JTree JTable JTableHeader JCheckBoxMenuItem JRadioButton JProgressBar JSpinner JScrollPane JInternalFrame JRadioButtonMenuItem 9

Swing 10 J GUI 2! JComponent! AWT Container JApplet, JDialog, JFrame JComponent! new JComponent()! AWT Component

11! GUI! java.awt.container!! AWT : Panel, Frame, Applet, Dialog, Window Swing : JPanel JFrame, JApplet, JDialog, JWindow! JFrame, JDialog, JApplet!!! java.awt.component! javax.swing.jcomponent

12

GUI 13 1. 2. main() 3. import! import java.awt.*; //! import java.awt.event.*; // AWT! import javax.swing.*; //! import javax.swing.event.*; //

14 GUI! JFrame!! (JFrame)!!! GUI Frame Menu Bar JFrame Frame : Content Pane

9-1 : 300x300 15 300 300. import javax.swing.*; public class MyFrame extends JFrame { public MyFrame() { settitle("300x300 "); setsize(300,300); // 300x300 setvisible(true); // public static void main(string[] args) { MyFrame frame = new MyFrame();

main() 16 import javax.swing.*; public class MyFrame extends JFrame { MyFrame() { settitle(" "); setsize(300,300); setvisible(true); public static void main(string [] args) { MyFrame mf=new MyFrame(); main() import javax.swing.*; class MyFrame extends JFrame { MyFrame() { settitle(" "); setsize(300,300); setvisible(true); public class MyApp { public static void main(string [] args) { MyFrame mf = new MyFrame(); main() MyApp

17 public MyFrame() { // super(""); // Jframe settitle(""); // Container contentpane = frame.getcontentpane(); Container c = frame.getcontentpane(); JButton b = new JButton("Click"); c.add(b); JPanel p = new JPanel(); frame.setcontentpane(p);

9-2 : 3 18, OK, Cancel, Ignore. import javax.swing.*; import java.awt.*; public class ContentPaneEx extends JFrame { public ContentPaneEx() { settitle("contentpane JFrame"); setdefaultcloseoperation(jframe.exit_on_close); Container contentpane = getcontentpane(); contentpane.setbackground(color.orange); contentpane.setlayout(new FlowLayout()); contentpane.add(new JButton("OK")); contentpane.add(new JButton("Cancel")); contentpane.add(new JButton("Ignore")); setsize(300, 150); setvisible(true); public static void main(string[] args) { new ContentPaneEx();

19 System.exit(0);! (X)?!! setvisible(true) frame.setdefaultcloseoperation(jframe.exit_on_close);

main()? 20! main()! GUI! main()!

21 (Container) 1.,.. 2.. (Layout Manager) (Component)

4 22 java.awt FlowLayout BorderLayout.. GridLayout CardLayout..

23!! Container.setLayout(LayoutManager lm) lm // JPanel BorderLayout JPanel p = new JPanel(); p.setlayout(new BorderLayout()); // FlowLayout Container c = frame.getconentpane(); // c.setlayout(new FlowLayout());

FlowLayout 24!. container.setlayout(new FlowLayout()); container.add(new JButton("add")); container.add(new JButton("sub")); container.add(new JButton("mul")); container.add(new JButton("div")); container.add(new JButton("Calculate"));!

FlowLayout - 25 vgap, 40 hgap, 30 FlowLayout.LEFT

9-3 : FlowLayout 26 30, 40 LEFT FlowLayout 5. import javax.swing.*; import java.awt.*; public class FlowLayoutEx extends JFrame { public FlowLayoutEx() { settitle("flowlayout Sample"); setdefaultcloseoperation(jframe.exit_on_close); Container c = getcontentpane(); c.setlayout(new FlowLayout(FlowLayout.LEFT, 30, 40)); c.add(new JButton("add")); c.add(new JButton("sub")); c.add(new JButton("mul")); c.add(new JButton("div")); c.add(new JButton("Calculate")); setsize(300, 200); setvisible(true); hgap, 30 FlowLayout.LEFT vgap, 40 public static void main(string[] args) { new FlowLayoutEx();

BorderLayout 27! 5, East, West, South, North, Center! add(component comp, int index) comp index! BorderLayout.NORTH BorderLayout.EAST container.setlayout(new BorderLayout()); container.add(new JButton("div"), BorderLayout.WEST); container.add(new JButton("Calculate"), BorderLayout.CENTER); BorderLayout.WEST BorderLayout.SOUTH BorderLayout.CENTER

BorderLayout 28

BorderLayout 29 CENTER CENTER NORTH CENTER, NORTH, SOUTH new BorderLayout(30,20); vgap, 20 hgap, 30

9-4 : BorderLayout 30 BorderLayout 5. import javax.swing.*; import java.awt.*; public class BorderLayoutEx extends JFrame { public BorderLayoutEx() { settitle("borderlayout Sample"); setdefaultcloseoperation(jframe.exit_on_close); vgap, 20 Container c = getcontentpane(); c.setlayout(new BorderLayout(30, 20)); c.add(new JButton("Calculate"), BorderLayout.CENTER); c.add(new JButton("add"), BorderLayout.NORTH); c.add(new JButton("sub"), BorderLayout.SOUTH); c.add(new JButton("mul"), BorderLayout.EAST); c.add(new JButton("div"), BorderLayout.WEST); hgap, 30 setsize(300, 200); // 300 200 setvisible(true); // public static void main(string[] args) { new BorderLayoutEx();

GridLayout 31! (), container.setlayout(new GridLayout(4,3,5,5)); // 4 3 container.add(new JButton("1")); // container.add(new JButton("2")); //! 4x3 11 add vgap : 5 hgap : 5

GridLayout 32

9-5 : GridLayout 33 import javax.swing.*; import java.awt.*; public class GridLayoutEx extends JFrame { public GridLayoutEx() { settitle("gridlayout Sample"); setdefaultcloseoperation(jframe.exit_on_close); vgap 5 GridLayout grid = new GridLayout(4, 2); grid.setvgap(5); Container c = getcontentpane(); c.setlayout(grid); c.add(new JLabel(" ")); c.add(new JTextField("")); c.add(new JLabel(" ")); c.add(new JTextField("")); c.add(new JLabel(" ")); c.add(new JTextField("")); c.add(new JLabel(" ")); c.add(new JTextField("")); setsize(300, 200); setvisible(true); public static void main(string[] args) { new GridLayoutEx();

34?!!! /!! container.setlayout(null); // JPanel JPanel p = new JPanel(); p.setlayout(null);!! : component.setsize(int width, int height); : component.setlocation(int x, int y); : component.setbounds(int x, int y, int width, int height);

9-6 : 35 import javax.swing.*; import java.awt.*; public class NullContainerEx extends JFrame { public NullContainerEx() { settitle("null Container Sample"); setdefaultcloseoperation(jframe.exit_on_close); Container c = getcontentpane(); c.setlayout(null); JLabel la = new JLabel("Hello, Press Buttons!"); la.setlocation(130, 50); la.setsize(200, 20); c.add(la);. for(int i=1; i<=9; i++) { JButton b = new JButton(Integer.toString(i)); // b.setlocation(i*15, i*15); b.setsize(50, 20); c.add(b); // setsize(300, 200); setvisible(true); public static void main(string[] args) { new NullContainerEx();

36