PowerPoint Presentation

Size: px
Start display at page:

Download "PowerPoint Presentation"

Transcription

1 객체지향프로그래밍 그래픽프로그래밍 손시운

2 자바에서의그래픽 2

3 자바그래픽의두가지방법 3

4 간단한예제 4

5 (1) 프레임생성하기 public class BasicPaint { public static void main(string[] args) { JFrame f = new JFrame(" 그래픽기초프로그램 "); f.setdefaultcloseoperation(jframe.exit_on_close); f.setsize(300, 200); f.setvisible(true); 5

6 (2) 어디에그릴것인가? JFrame 을생성하고여기에 JPanel 을추가한후에 JPanel 위에그림을그려보 자. public class BasicPaint { public static void main(string[] args) { JFrame f = new JFrame(" 그래픽기초프로그램 "); f.setdefaultcloseoperation(jframe.exit_on_close); f.add(new MyPanel()); f.setsize(300, 200); f.setvisible(true); class MyPanel extends JPanel { public MyPanel() {... 6

7 (3) 어떻게그릴것인가? 컴포넌트에무언가를그리려면 paintcomponent() 메소드를중복정의한다. paintcomponent() 메소드는컴포넌트가화면에그려질때호출된다. 7

8 일반적인코드의형태 class MyPanel extends JPanel { public void paintcomponent(graphics g) { super.paintcomponent(g); // 여기에그림을그리는코드를넣는다. 8

9 (4) 그래픽좌표계 y 좌표는아래로갈수록증가한다. 9

10 (5) 그림을그리는메소드 사각형을그리려면 Graphics 객체가가지고있는 drawrect() 을호출하면된 다. g.drawrect(50, 50, 50, 50); g.drawoval(200, 50, 50, 50); 10

11 전체소스 public class BasicPaint { public static void main(string[] args) { JFrame f = new JFrame(" 그래픽기초프로그램 "); f.setdefaultcloseoperation(jframe.exit_on_close); f.add(new MyPanel()); f.setsize(300, 200); f.setvisible(true); class MyPanel extends JPanel { public MyPanel() { setborder(borderfactory.createlineborder(color.black)); protected void paintcomponent(graphics g) { super.paintcomponent(g); g.drawrect(50, 50, 50, 50); g.drawoval(200, 50, 50, 50); 11

12 실행결과 12

13 기초도형그리기 13

14 직선그리기 14

15 사각형그리기 width height 15

16 drawroundrect() 16

17 타원그리기 17

18 호그리기 18

19 예제 아래그림과비슷한얼굴을그려보자 19

20 예제 import javax.swing.*; import java.awt.event.*; import java.awt.*; class MyPanel extends JPanel { public void paintcomponent(graphics g) { super.paintcomponent(g); g.setcolor(color.yellow); g.filloval(20, 30, 200, 200); g.setcolor(color.black); // 왼쪽눈을그린다. g.drawarc(60, 80, 50, 50, 180, -180); // 오른쪽눈을그린다. g.drawarc(150, 80, 50, 50, 180, -180); // 입을그린다. g.drawarc(70, 130, 100, 70, 180, 180); 20

21 예제 public class SnowManFace extends JFrame { public SnowManFace() { setsize(280, 300); setdefaultcloseoperation(jframe.exit_on_close); settitle(" 눈사람얼굴 "); setvisible(true); add(new MyPanel()); public static void main(string[] args) { SnowManFace s=new SnowManFace(); 21

22 Lab: 프랙탈로나무그리기 프랙탈 (fractal) 은자기유사성을가지는기하학적구조를프랙털구조를말 한다. 22

23 프랙탈트리를그리는알고리즘 나무줄기를그린다. 줄기의끝에서특정한각도로 2개의가지를그린다. 동일한과정을가지의끝에서반복한다. 충분한가지가생성될때까지이과정을반복한다. 23

24 SOLUTION import java.awt.color; import java.awt.graphics; import javax.swing.jframe; public class DrawTreeFrame extends JFrame { public DrawTreeFrame() { setsize(800, 700); setdefaultcloseoperation(exit_on_close); setvisible(true); private void drawtree(graphics g, int x1, int y1, double angle, int depth) { if (depth == 0) return; int x2 = x1 + (int) (Math.cos(Math.toRadians(angle)) * depth * 10.0); int y2 = y1 + (int) (Math.sin(Math.toRadians(angle)) * depth * 10.0); g.drawline(x1, y1, x2, y2); drawtree(g, x2, y2, angle - 20, depth - 1); drawtree(g, x2, y2, angle + 20, depth - 1); 24

25 public void paint(graphics g) { g.setcolor(color.black); drawtree(g, 400, 600, -90, 10); public static void main(string[] args) { new DrawTreeFrame(); 25

26 색상 java.awt 패키지의일부인 Color 클래스를사용 빛의 3 원색인 Red 성분, Green 성분, Blue 성분이얼마나함유되어있는지를 0 에서 255 까지의수를사용하여나타낸다. 26

27 색상 클래스변수이름 색상 RGB 값 Color.black black (0,0,0) Color.blue blue (0,0,255) Color.cyan cyan (0,255,255) Color.gray gray (128,128,128) Color.darkGray dark gray (64,64,64) Color.lightGray light gray (192,192,192) Color.green green (0,255,0) Color.magenta magenta (255,0,255) Color.orange orange (255,200,0) Color.pink pink (255,175,175) Color.red red (255,0,0) Color.white white (255,255,255) Color.yellow yellow (255,255,0) 27

28 색상설정 마젠타색상을얻는방법 Color c = Color.magenta; Color c = new Color (255,0,255); Color 는알파값 (alpha) 을가질수있다. 알파값이란색상의투명도를나타낸 다. ( 예 ) Color c = new Color (255, 0, 0, 128); 28

29 컴포넌트색상설정메소드 생성자 설명 setbackground(color c) 컴포넌트객체에서배경색을설정한다. setcolor(color c) 전경색을설정한다. Color getcolor() 현재의전경색을반환한다. 29

30 예제 import javax.swing.*; import java.awt.event.*; import java.awt.*; class MyPanel extends JPanel implements ActionListener { JButton button; Color color = new Color(0, 0, 0); public MyPanel() { setlayout(new BorderLayout()); button = new JButton(" 색상변경 "); button.addactionlistener(this); add(button, BorderLayout.SOUTH); public void paintcomponent(graphics g) { super.paintcomponent(g); g.setcolor(color); g.fillrect(10, 10, 210, 220); 30

31 예제 public void actionperformed(actionevent e) { color = new Color((int) (Math.random()*255.0), (int) (Math.random()*255.0),(int) (Math.random()*255.0)); repaintcomponent(); public class ColorTest extends JFrame { public ColorTest() { setsize(240, 300); setdefaultcloseoperation(jframe.exit_on_close); settitle("color Test"); setvisible(true); JPanel panel = new MyPanel(); add(panel); public static void main(string[] args) { ColorTest s = new ColorTest(); 31

32 실행결과 32

33 색상선택기 33

34 예제 import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.colorchooser.*; public class ColorChooserTest extends JFrame implements ChangeListener { protected JColorChooser color; public ColorChooserTest() { settitle(" 색상선택기테스트 "); setdefaultcloseoperation(jframe.exit_on_close); color = new JColorChooser(); // 생성자호출 color.getselectionmodel().addchangelistener(this); // 리스너등록 color.setborder(borderfactory.createtitledborder(" 색상선택 ")); 34

35 예제 JPanel panel = new JPanel(); panel.add(color); add(panel); pack(); this.setvisible(true); public void statechanged(changeevent e) { Color newcolor = color.getcolor(); System.out.println(newColor); public static void main(string[] args) { new ColorChooserTest(); 35

36 문자열출력과폰트 문자열출력방법 // (x, y) 위치에문자열을출력하려면 g.drawstring("hello World!", x, y); 폰트를지정하기위해서는 Font 클래스를사용 Font 객체는폰트이름 (Courier, Helvetica,..) 과스타일 (plain, bold, italic,...), 크기 (12포인트,...) 의 3가지속성 // plain 형식이고크기는 10포인트 Font font = new Font("Courier", Font.PLAIN, 10); 36

37 폰트의종류 논리적인폰트 설명 "Serif" 삐침 (serif) 를갖는가변폭글꼴, 대표적으로 TimesRoman 이있다. "SansSerif" 삐침 (serif) 를갖지않는가변폭글꼴, 대표적으로 Helvetica 가있다. "Monospaced" 고정폭을가지는글꼴, 대표적으로 Courier 가있다. "Dialog" "DialogInput" 대화상자에서텍스트출력을위하여사용되는글꼴 대화상자에서텍스트입력을위하여사용되는글꼴 37

38 폰트의지정 public void paint(graphics g) { Font f = new Font("Serif", Font.BOLD Font.ITALIC, 12); g.setfont(f);... JLabel mylabel = new JLabel(" 폰트색상 ); Font f = new Font("Dialog", Font.ITALIC, 10); // 1 mylabel.setfont(f); 38

39 예제 class MyPanel extends JPanel { Font f1, f2, f3, f4, f5; public MyPanel() { f1 = new Font("Serif", Font.PLAIN, 20); f2 = new Font("San Serif", Font.BOLD, 20); f3 = new Font("Monospaced", Font.ITALIC, 20); f4 = new Font("Dialog", Font.BOLD Font.ITALIC, 20); f5 = new Font("DialogInput", Font.BOLD, 20); public void paintcomponent(graphics g) { super.paintcomponent(g); g.setfont(f1); g.drawstring("serif 20 points PLAIN", 10, 50); g.setfont(f2); g.drawstring("sanserif 20 points BOLD", 10, 70); g.setfont(f3); g.drawstring("monospaced 20 points ITALIC", 10, 90); g.setfont(f4); g.drawstring("dialog 20 points BOLD + ITALIC", 10, 110); g.setfont(f5); g.drawstring("dialoginput 20 points BOLD", 10, 130); 39

40 예제 public class FontTest extends JFrame { public FontTest() { setsize(500, 200); setdefaultcloseoperation(jframe.exit_on_close); settitle("font Test"); setvisible(true); JPanel panel = new MyPanel(); add(panel); public static void main(string[] args) { FontTest s = new FontTest(); 40

41 이미지출력 자바는 GIF, PNG JPEG 타입의이미지를화면에그릴수있다. BufferedImage img = null; try { img = ImageIO.read(new File("strawberry.jpg")); catch (IOException e) { 41

42 예제 // 소스를입력하고 Ctrl+Shift+O 를눌러서필요한파일을포함한다. public class LoadImageApp extends JPanel { BufferedImage img; public void paint(graphics g) { g.drawimage(img, 0, 0, null); public LoadImageApp() { try { img = ImageIO.read(new File("dog.png")); catch (IOException e) { 42

43 예제 public Dimension getpreferredsize() { if (img == null) { return new Dimension(100, 100); else { return new Dimension(img.getWidth(null), img.getheight(null)); public static void main(string[] args) { JFrame f = new JFrame(" 이미지표시예제 "); f.add(new LoadImageApp()); f.pack(); f.setvisible(true); f.setdefaultcloseoperation(jframe.exit_on_close); 43

44 실행결과 44

45 LAB: 이미지나누어서그리기 drawimage() 를이용하여이미지를그릴때, 일부만그릴수있고또크기를 변경할수있다. 이러한기능을이용하여서이미지를 16 조각으로나누어서 그리는프로그램을작성하여보자. 45

46 drawimage() 메소드 46

47 예제 public class MyImageFrame extends JFrame implements ActionListener { private int pieces = 4; private int totalpieces = pieces * pieces; private int[] piecenumber; private BufferedImage img; public MyImageFrame() { settitle("image Draw Test"); try { img = ImageIO.read(new File("hubble.jpg")); catch (IOException e) { System.out.println(e.getMessage()); System.exit(0); piecenumber = new int[totalpieces]; for (int i = 0; i < totalpieces; i++) { piecenumber[i] = i; add(new MyPanel(), BorderLayout.CENTER); JButton button = new JButton("DIVIDE"); button.addactionlistener(this); add(button, BorderLayout.SOUTH); setsize(img.getwidth(null), img.getheight(null)); setvisible(true); 47

48 예제 void divide() { Random rand = new Random(); int ri; for (int i = 0; i < totalpieces; i++) { ri = rand.nextint(totalpieces); int tmp = piecenumber[i]; piecenumber[i] = piecenumber[ri]; piecenumber[ri] = tmp; class MyPanel extends JPanel { public void paintcomponent(graphics g) { super.paintcomponent(g); int piecewidth = img.getwidth(null) / pieces; int pieceheight = img.getheight(null) / pieces; 48

49 예제 for (int x = 0; x < pieces; x++) { int sx = x * piecewidth; for (int y = 0; y < pieces; y++) { int sy = y * pieceheight; int number = piecenumber[x * pieces + y]; int dx = (number / pieces) * piecewidth; int dy = (number % pieces) * pieceheight; g.drawimage(img, dx, dy, dx + piecewidth, dy + pieceheight, sx, sy, sx + piecewidth, sy + pieceheight, null); public static void main(string[] args) { new MyImageFrame(); public void actionperformed(actionevent e) { divide(); repaint(); 49

50 영상처리 영상처리 (image processing) 은이미지를읽어서여러가지처리를하는학 문분야이다. 예를들어서화질이나쁜이미지의화질을향상시키는것도영 상처리의일종이다. 50

51 예제 public class GrayScaleImage extends JFrame { BufferedImage image; int width; int height; public GrayScaleImage() { try { File input = new File("Lenna.png"); image = ImageIO.read(input); width = image.getwidth(); height = image.getheight(); for (int r = 0; r < height; r++) { for (int c = 0; c < width; c++) { Color color = new Color(image.getRGB(r, c)); 51

52 예제 int red = (int) (color.getred()); int green = (int) (color.getgreen()); int blue = (int) (color.getblue()); int avg = (red + green + blue) / 3; Color newcolor = new Color(avg, avg, avg); image.setrgb(r, c, newcolor.getrgb()); File ouptut = new File("output.png"); ImageIO.write(image, "png", ouptut); add(new MyPanel()); pack(); setvisible(true); catch (Exception e) { System.out.println(" 이미지읽기실패!"); 52

53 예제 class MyPanel extends JPanel { public void paintcomponent(graphics g) { g.drawimage(image, 0, 0, null); public Dimension getpreferredsize() { if (image == null) { return new Dimension(100, 100); else { return new Dimension(image.getWidth(null), image.getheight(null)); static public void main(string args[]) throws Exception { GrayScaleImage obj = new GrayScaleImage(); 53

54 Java 2D 광범위한그래픽객체를그릴수있다. 도형의내부를그라디언트 (gradient) 나무늬로채울수있다. 이미지를그릴수있고필터링연산을적용할수있다. 그래픽객체들의충돌을감지할수있는메커니즘을제공한다. 54

55 Java 2D 를이용한그리기 public void paintcomponent(graphics g) { Graphics2D g2 = (Graphics2D) g; g2.drawline(100, 100, 300, 300); g2.drawrect(10, 10, 100, 100);... 55

56 Java 2D 를이용한그리기 56

57 사각형그리기 Shape r1 = new Rectangle2D.Float(10, 10, 50, 60); g2.draw(r1); 57

58 타원그리기 // 타원객체를생성하고타원을그린다. g2.draw(new Ellipse2D.Double(x, y, rectwidth, rectheight)); 58

59 원호생성 Shape arc1 = new Arc2D.Float(10, 10, 90, 90, 90, 60, Arc2D.OPEN); 59

60 예제 import java.util.*; import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.awt.geom.*; public class MoreShapes extends JFrame { public MoreShapes() { setsize(600, 130); settitle("java 2D Shapes"); setdefaultcloseoperation(jframe.exit_on_close); JPanel panel = new MyPanel(); add(panel); setvisible(true); public static void main(string[] args) { new MoreShapes(); 60

61 예제 class MyPanel extends JPanel { ArrayList<Shape> shapearray = new ArrayList<Shape>(); public MyPanel() { Shape s; // 사각형 s = new Rectangle2D.Float(10, 10, 70, 80); shapearray.add(s); // 둥근사각형 s = new RoundRectangle2D.Float(110, 10, 70, 80, 20, 20); shapearray.add(s); // 타원 s = new Ellipse2D.Float(210, 10, 80, 80); shapearray.add(s); // 원호 : Arc2D.OPEN s = new Arc2D.Float(310, 10, 80, 80, 90, 90, Arc2D.OPEN); shapearray.add(s); 61

62 예제 // 원호 Arc2D.CHORD s = new Arc2D.Float(410, 10, 80, 80, 0, 180, Arc2D.CHORD); shapearray.add(s); // 원호 Arc2D.PIE s = new Arc2D.Float(510, 10, 80, 80, 45, 90, Arc2D.PIE); shapearray.add(s); public void paintcomponent(graphics g) { super.paintcomponent(g); Graphics2D g2 = (Graphics2D) g; // 앤티에일리어싱을설정한다. g2.setrenderinghint(renderinghints.key_antialiasing, RenderingHints.VALUE_ANTIALIAS_ON); g2.setcolor(color.black); g2.setstroke(new BasicStroke(3)); for (Shape s : shapearray) g2.draw(s); 62

63 예제 63

64 도형채우기 단일색으로채우기 g2.setcolor(color.blue); g2.fill(ellipse); 투명하게채우기 g2.setcomposite(alphacomposite.getinstance(alphacomposite.src_over, 0.50F)); 그라디언트로채우기 GradientPaint gp = new GradientPaint(0, 0, Color.WHITE, 0, 100, Color.RED); 64

65 예제 class MyComponent extends JComponent { public void paint(graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setrenderinghint(renderinghints.key_antialiasing, RenderingHints.VALUE_ANTIALIAS_ON); g2.setstroke(new BasicStroke(3)); GradientPaint gp = new GradientPaint(0, 10, Color.WHITE, 0, 70, Color.RED); // 사각형 g2.setpaint(color.red); g2.fill(new Rectangle2D.Float(10, 10, 70, 80)); // 둥근사각형 g2.setpaint(gp); g2.fill(new RoundRectangle2D.Float(110, 10, 70, 80, 20, 20));... 65

66 실행결과 66

67 LAB: 간단한애니메이션 67

68 예제 class MyPanel extends JPanel implements ActionListener { private final int WIDTH = 500; private final int HEIGHT = 300; private final int START_X = 0; private final int START_Y = 250; private BufferedImage image; private Timer timer; private int x, y; public MyPanel() { setbackground(color.black); setpreferredsize(new Dimension(WIDTH, HEIGHT)); setdoublebuffered(true); File input = new File("ship.jpg"); try { image = ImageIO.read(input); catch (IOException e) { e.printstacktrace(); 68

69 예제 x = START_X; y = START_Y; timer = new Timer(20, this); public void paintcomponent(graphics g) { super.paintcomponent(g); g.drawimage(image, x, y, public void actionperformed(actionevent e) { x += 1; y -= 1; if (x > WIDTH) { x = START_X; y = START_Y; repaint(); 69

70 예제 public class MyFrame extends JFrame { public MyFrame() { add(new MyPanel()); settitle(" 애니메이션테스트 "); setdefaultcloseoperation(jframe.exit_on_close); setsize(500, 300); setvisible(true); public static void main(string[] args) { new MyFrame(); 70

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

Microsoft PowerPoint - java1-lecture11.ppt [호환 모드] 자바에서의그래픽 그래픽스, 이미지 514760-1 2019 년봄학기 6/4/2019 박경신 자바그래픽의두가지방법 간단한그래픽 // (1) 프레임생성하기 public class BasicPaint { JFrame f = new JFrame(" 그래픽기초프로그램 "); f.setdefaultcloseoperation(jframe.exit_on_close); f.setsize(300,

More information

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 23 장그래픽프로그래밍 이번장에서학습할내용 자바에서의그래픽 기초사항 기초도형그리기 색상 폰트 Java 2D Java 2D를이용한그리기 Java 2D 를이용한채우기 도형회전과평행이동 자바를이용하여서화면에그림을그려봅시다. 자바그래픽데모 자바그래픽의두가지방법 자바그래픽 AWT Java 2D AWT를사용하면기본적인도형들을쉽게그릴수있다. 어디서나잘실행된다.

More information

8장.그래픽 프로그래밍

8장.그래픽 프로그래밍 윈도우프레임 도형그리기색과폰트이미지그리기그리기응용 2 윈도우프레임 제목표시줄을갖는윈도우를의미 생성과정 1 JFrame 객체생성 2 프레임의크기설정 3 프레임의제목설정 4 기본닫힘연산지정 5 프레임이보이도록만듦. 3 윈도우프레임예제 [ 예제 8.1 - EmptyFrameViewer.java] import javax.swing.*; public class EmptyFrameViewer

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 그래픽사용자인터페이스 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 프레임생성 (1) import javax.swing.*; public class FrameTest { public static void main(string[] args) { JFrame f = new JFrame("Frame Test"); JFrame

More information

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 19 장배치관리자 이번장에서학습할내용 배치관리자의개요 배치관리자의사용 FlowLayout BorderLayout GridLayout BoxLayout CardLayout 절대위치로배치 컨테이너안에서컴포넌트를배치하는방법에대하여살펴봅시다. 배치관리자 (layout manager) 컨테이너안의각컴포넌트의위치와크기를결정하는작업 [3/70] 상당히다르게보인다.

More information

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

자바GUI실전프로그래밍2_장대원.PDF JAVA GUI - 2 JSTORM http://wwwjstormpekr JAVA GUI - 2 Issued by: < > Document Information Document title: JAVA GUI - 2 Document file name: Revision number: Issued by: Issue Date:

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 스윙컴포넌트그리기와 paintcomponent() 활용 2. Graphics 객체에대한이해 3. 도형그리기와칠하기 4. 이미지그리기 5. repaint() 활용하기 6. 마우스와그래픽응용 스윙컴포넌트그리기, paintcomponent() 3 스윙의페인팅기본 모든컴포넌트는자신의모양을스스로그린다. 컨테이너는자신을그린후그위에자식컴포넌트들에게그리기지시

More information

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

gnu-lee-oop-kor-lec10-1-chap10 어서와 Java 는처음이지! 제 10 장이벤트처리 이벤트분류 액션이벤트 키이벤트 마우스이동이벤트 어댑터클래스 스윙컴포넌트에의하여지원되는이벤트는크게두가지의카테고리로나누어진다. 사용자가버튼을클릭하는경우 사용자가메뉴항목을선택하는경우 사용자가텍스트필드에서엔터키를누르는경우 두개의버튼을만들어서패널의배경색을변경하는프로그램을작성하여보자. 이벤트리스너는하나만생성한다. class

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 그래픽 배효철 th1g@nate.com 1 목차 스윙컴포넌트그리기 자바의그래픽좌표시스템 Graphics 2 스윙컴포넌트그리기 스윙의그리기기본철학 모든컴포넌트는자신의모양을스스로그린다. 컨테이너는자신을그린후자식들에게그리기지시 public void paintcomponent(graphics g) 스윙컴포넌트가자신의모양을그리는메소드 JComponent 의메소드 모든스윙컴포넌트가이메소드를가지고있음

More information

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

public class FlowLayoutPractice extends JFrame { public FlowLayoutPractice() { super(flowlayout Practice); this. Container contentpane = getcontentp 8 장 1 번 public class MyFrame extends JFrame { public MyFrame(String title) { super(title); this. setsize(400,200); new MyFrame("Let's study Java"); 2번 public class MyBorderLayoutFrame extends JFrame {

More information

<4D F736F F F696E74202D20C1A63236C0E520BED6C7C3B8B428B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63236C0E520BED6C7C3B8B428B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 26 장애플릿 이번장에서학습할내용 애플릿소개 애플릿작성및소개 애플릿의생명주기 애플릿에서의그래픽컴포넌트의소개 Applet API의이용 웹브라우저상에서실행되는작은프로그램인애플릿에대하여학습합니다. 애플릿이란? 애플릿은웹페이지같은 HTML 문서안에내장되어실행되는자바프로그램이다. 애플릿을실행시키는두가지방법 1. 웹브라우저를이용하는방법 2. Appletviewer를이용하는방법

More information

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

Microsoft PowerPoint - ÀÚ¹Ù08Àå-1.ppt AWT 컴포넌트 (1) 1. AWT 패키지 2. AWT 프로그램과이벤트 3. Component 클래스 4. 컴포넌트색칠하기 AWT GUI 를만들기위한 API 윈도우프로그래밍을위한클래스와도구를포함 Graphical User Interface 그래픽요소를통해프로그램과대화하는방식 그래픽요소를 GUI 컴포넌트라함 윈도우프로그램만들기 간단한 AWT 프로그램 import

More information

9장.key

9장.key 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

More information

11장.key

11장.key JAVA Programming 1 GUI 2 2 1. GUI! GUI! GUI.! GUI! GUI 2. GUI!,,,!! GUI! GUI 11 : GUI 12 : GUI 3 4, JComponent 11-1 :, JComponent 5 import java.awt.*; import java.awt.event.*; import javax.swing.*; public

More information

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

제8장 자바 GUI 프로그래밍 II 제8장 MVC Model 8.1 MVC 모델 (1/7) MVC (Model, View, Controller) 모델 스윙은 MVC 모델에기초를두고있다. MVC란 Xerox의연구소에서 Smalltalk 언어를바탕으로사용자인터페이스를개발하기위한방법 MVC는 3개의구성요소로구성 Model : 응용프로그램의자료를표현하기위한모델 View : 자료를시각적으로 (GUI 방식으로

More information

Microsoft PowerPoint - 04-UDP Programming.ppt

Microsoft PowerPoint - 04-UDP Programming.ppt Chapter 4. UDP Dongwon Jeong djeong@kunsan.ac.kr http://ist.kunsan.ac.kr/ Dept. of Informatics & Statistics 목차 UDP 1 1 UDP 개념 자바 UDP 프로그램작성 클라이언트와서버모두 DatagramSocket 클래스로생성 상호간통신은 DatagramPacket 클래스를이용하여

More information

<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 18 장이벤트처리 이번장에서학습할내용 이벤트처리의개요 이벤트 액션이벤트 Key, Mouse, MouseMotion 어댑터클래스 버튼을누르면반응하도록만들어봅시다. 이번장의목표 버튼을누르면버튼의텍스트가변경되게한다. 이벤트처리과정 이벤트처리과정 (1) 이벤트를발생하는컴포넌트를생성하여야한다. 이벤트처리과정 (2) 이벤트리스너클래스를작성한다.

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 이벤트처리 손시운 ssw5176@kangwon.ac.kr 이벤트 - 구동프로그래밍 이벤트 - 구동프로그래밍 (event-driven programming): 프로그램의실행이이벤트의발생에의하여결정되는방식 2 이벤트처리과정 3 이벤트리스너 발생된이벤트객체에반응하여서이벤트를처리하는객체를이벤트리스너 (event listener) 라고한다. 4 이벤트처리과정

More information

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

10 이벤트 처리와 그래픽 프로그래밍.key [ 10 ] ..,..,,,., 2 1. 3 Section 1 p408 (event) (listen) (event listener) 4 Section 1 [ 1: ] [ 2: ] 5 Section 1 (ActionEvent) (MouseEvent) 6 Section 1 EventObject getsource() 7 Section 1 8 Section 1 MouseListener

More information

05-class.key

05-class.key 5 : 2 (method) (public) (private) (interface) 5.1 (Method), (public method) (private method) (constructor), 3 4 5.2 (client). (receiver)., System.out.println("Hello"); (client object) (receiver object)

More information

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 20 장스윙컴포넌트 1 이번장에서학습할내용 텍스트컴포넌트 텍스트필드 텍스트영역 스크롤페인 체크박스 라디오버튼 스윙에서제공하는기초적인컴포넌트들을살펴봅시다. 스윙텍스트컴포넌트들 종류텍스트컴포넌트그림 텍스트필드 JTextField JPasswordField JFormattedTextField 일반텍스트영역 JTextArea 스타일텍스트영역

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 인터페이스, 람다식, 패키지 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 홈네트워킹 public interface RemoteControl { public void turnon(); // 가전제품을켠다. public void turnoff(); // 가전제품을끈다. 인터페이스를구현 public class Television

More information

슬라이드 1

슬라이드 1 12 장. GUI 학습목표 GUI 이벤트, 이벤트리스너와이벤트소스그림그리기내부클래스 창 Jframe 의모양 (Metal L&F) Jframe 의모양 (Aqua L&F) 창을만드는방법 1. 프레임 (JFrame) 만들기 JFrame frame = new JFrame(); 2. 위젯만들기 JButton button = new JButton( click me );

More information

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx 2018 학년도 1 학기 JAVA 프로그래밍 II 514760-1 2018 년봄학기 5/10/2018 박경신 Lab#1 (ImageTest) Lab#1 은영상파일 (Image) 을읽어서정보를출력 Java Tutorials Lesson: Working with Images https://docs.oracle.com/javase/tutorial/2d/images/index.html

More information

No Slide Title

No Slide Title 사건처리와 GUI 프로그래밍 이충기 명지대학교컴퓨터공학과 사건 사건은우리가관심을가질지모르는어떤일이일어나는것을나타내는객체이다. 예를들면, 다음이일어날때프로그램이어떤일을수행해야하는경우에사건이발생한다 : 1. 마우스를클릭한다. 2. 단추를누른다. 3. 키보드의키를누른다. 4. 메뉴항목을선택한다. 2 사건 사건은컴포넌트에서사용자나시스템에의하여발생하는일이다. 자바는사건을나타내는많은사건클래스를제공한다.

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 필드만있는클래스 텔레비젼 2 예제 1. 필드만있는클래스 3 예제 2. 여러개의객체생성하기 4 5 예제 3. 메소드가추가된클래스 public class Television { int channel; // 채널번호 int volume; // 볼륨 boolean

More information

Microsoft PowerPoint - Java7.pptx

Microsoft PowerPoint - Java7.pptx HPC & OT Lab. 1 HPC & OT Lab. 2 실습 7 주차 Jin-Ho, Jang M.S. Hanyang Univ. HPC&OT Lab. jinhoyo@nate.com HPC & OT Lab. 3 Component Structure 객체 (object) 생성개념을이해한다. 외부클래스에대한접근방법을이해한다. 접근제어자 (public & private)

More information

Microsoft PowerPoint - 14주차 강의자료

Microsoft PowerPoint - 14주차 강의자료 Java 로만드는 Monster 잡기게임예제이해 2014. 12. 2 게임화면및게임방법 기사초기위치 : (0,0) 아이템 10 개랜덤생성 몬스터 10 놈랜덤생성 Frame 하단에기사위치와기사파워출력방향키로기사이동아이템과몬스터는고정종료버튼클릭하면종료 Project 구성 GameMain.java GUI 환경설정, Main Method 게임객체램덤위치에생성 Event

More information

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

gnu-lee-oop-kor-lec06-3-chap7 어서와 Java 는처음이지! 제 7 장상속 Super 키워드 상속과생성자 상속과다형성 서브클래스의객체가생성될때, 서브클래스의생성자만호출될까? 아니면수퍼클래스의생성자도호출되는가? class Base{ public Base(String msg) { System.out.println("Base() 생성자 "); ; class Derived extends Base

More information

Microsoft PowerPoint - 12장

Microsoft PowerPoint - 12장 1 스윙컴포넌트그리기, 메소드 제 12 장그래픽 2 스윙의기본철학 모든컴포넌트는자신의모양을스스로그린다. 컨테이너는자신을그린후자식들에게그리기지시 public void paintcomponent(graphics g) 스윙컴포넌트가자신의모양을그리는메소드 JComponent의메소드 - 모든스윙컴포넌트가이메소드소유 컴포넌트가그려져야하는시점마다호출 컴포넌트의크기가변경되거나,

More information

Chap12

Chap12 12 12Java RMI 121 RMI 2 121 RMI 3 - RMI, CORBA 121 RMI RMI RMI (remote object) 4 - ( ) UnicastRemoteObject, 121 RMI 5 class A - class B - ( ) class A a() class Bb() 121 RMI 6 RMI / 121 RMI RMI 1 2 ( 7)

More information

Microsoft PowerPoint - Java-03.pptx

Microsoft PowerPoint - Java-03.pptx JAVA 프로그래밍 Chapter 19. GUI 프로그래밍 1 GUI 환경에서작동하는프로그램 윈도우프로그램에대하여 텍스트모드프로그램과윈도우프로그램 a) 텍스트모드의프로그램 b) 윈도우프로그램 2 GUI 환경에서작동하는프로그램 -2 윈도우프로그램에대하여 텍스트모드프로그램과윈도우프로그램의구조적차이 3 윈도우프로그램의작성방법 윈도우프로그램의구조 네단계로실행되는윈도우프로그램

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 java.awt Package java.awt 패키지는자바애플리케이션프로그래밍인터페이스 (API : Application Programming Interface) 의일부로서그래픽처리를담당하는컴포넌트들을포함합니다. 즉, 화면상에윈도우를그리고, 그위에버튼이나텍스트필드등을붙이는데필요한 GUI

More information

그래픽 chapter.1 스윙컴포넌트그리기 컴포넌트는자신의모양을스스로그린다 X-window, MFC, C# GUI, Android 등 GUI 플랫폼에서 GUI 컴포넌트는스스로자신의모양을그린다. 자바의스윙도예외는아니다. JButton은버튼모양을그리는코드를내장하고, JCo

그래픽 chapter.1 스윙컴포넌트그리기 컴포넌트는자신의모양을스스로그린다 X-window, MFC, C# GUI, Android 등 GUI 플랫폼에서 GUI 컴포넌트는스스로자신의모양을그린다. 자바의스윙도예외는아니다. JButton은버튼모양을그리는코드를내장하고, JCo 그래픽.1 스윙 컴포넌트 그리기.4 이미지 그리기.2 Graphics.5 repaint()와 그래픽 응용.3 도형 그리기와 칠하기 그래픽 chapter.1 스윙컴포넌트그리기 컴포넌트는자신의모양을스스로그린다 X-window, MFC, C# GUI, Android 등 GUI 플랫폼에서 GUI 컴포넌트는스스로자신의모양을그린다. 자바의스윙도예외는아니다. JButton은버튼모양을그리는코드를내장하고,

More information

PowerPoint Presentation

PowerPoint Presentation Class - Property Jo, Heeseung 목차 section 1 클래스의일반구조 section 2 클래스선언 section 3 객체의생성 section 4 멤버변수 4-1 객체변수 4-2 클래스변수 4-3 종단 (final) 변수 4-4 멤버변수접근방법 section 5 멤버변수접근한정자 5-1 public 5-2 private 5-3 한정자없음

More information

10장.key

10장.key JAVA Programming 1 2 (Event Driven Programming)! :,,,! ( )! : (batch programming)!! ( : )!!!! 3 (Mouse Event, Action Event) (Mouse Event, Action Event) (Mouse Event, Container Event) (Key Event) (Key Event,

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 CHAPTER 11. 자바스크립트와캔버스로게임 만들기 캔버스 캔버스는 요소로생성 캔버스는 HTML 페이지상에서사각형태의영역 실제그림은자바스크립트를통하여코드로그려야한다. 컨텍스트객체 컨텍스트 (context) 객체 : 자바스크립트에서물감과붓의역할을한다. var canvas = document.getelementbyid("mycanvas"); var

More information

10-Java Applet

10-Java Applet JAVA Programming Language JAVA Applet Java Applet >APPLET< >PARAM< HTML JAR 2 JAVA APPLET HTML HTML main( ). public Applet 3 (HelloWorld.html) Applet

More information

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

Microsoft PowerPoint - EEL2 Lecture10 -Swing and Event Handling.pptx 전자공학실험 2 1 WEEK10: SWING AND EVENT HANDLING Fall, 2014 건국대전자공학부 Notice: 주별강의 / 실습 /HW 내용 2 Week Date 강의주제 Homework 실습과제 Handouts 1 09월 03일 Orientation Lab1 Lecture0 2 09월 10일 추석 3 09월 17일 Using Objects

More information

Java Programing Environment

Java Programing Environment Lab Exercise #7 Swing Component 프로그래밍 2007 봄학기 고급프로그래밍 김영국충남대전기정보통신공학부 실습내용 실습과제 7-1 : 정규표현식을이용한사용자정보의유효성검사 (ATM 에서사용자등록용도로사용가능 ) 실습과제 7-2 : 숫자맞추기게임 실습과제 7-3 : 은행관리프로그램 고급프로그래밍 Swing Component 프로그래밍 2

More information

강의자료

강의자료 Copyright, 2014 MMLab, Dept. of ECE, UOS Java Swing 2014 년 3 월 최성종서울시립대학교전자전기컴퓨터공학부 chois@uos.ac.kr http://www.mmlab.net 차례 2014년 3월 Java Swing 2 2017-06-02 Seong Jong Choi Java Basic Concepts-3 Graphical

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 그래픽사용자인터페이스 손시운 ssw5176@kangwon.ac.kr 그래픽사용자인터페이스 그래픽사용자인터페이스 (Graphical User Interface, 간단히 GUI) 는컴포넌 트들로구성된다. 2 자바에서 GUI 의종류 GUI AWT(Abstract Windows Toolkit) AWT 는운영체제가제공하는자원을이용하여서컴포넌트를생성

More information

JMF3_심빈구.PDF

JMF3_심빈구.PDF JMF JSTORM http://wwwjstormpekr Issued by: < > Revision: Document Information Document title: Document file name: Revision number: Issued by: JMF3_ doc Issue Date:

More information

rmi_박준용_final.PDF

rmi_박준용_final.PDF (RMI) - JSTORM http://wwwjstormpekr (RMI)- Document title: Document file name: Revision number: Issued by: Document Information (RMI)- rmi finaldoc Issue Date: Status:

More information

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 (   ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각 JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( http://java.sun.com/javase/6/docs/api ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각선의길이를계산하는메소드들을작성하라. 직사각형의가로와세로의길이는주어진다. 대각선의길이는 Math클래스의적절한메소드를이용하여구하라.

More information

5장.key

5장.key JAVA Programming 1 (inheritance) 2!,!! 4 3 4!!!! 5 public class Person {... public class Student extends Person { // Person Student... public class StudentWorker extends Student { // Student StudentWorker...!

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 23 장스레드 이번장에서학습할내용 스레드의개요 스레드의생성과실행 스레드상태 스레드의스케줄링 스레드간의조정 스레드는동시에여러개의프로그램을실행하는효과를냅니다. 멀티태스킹 멀티태스킹 (muli-tasking) 는여러개의애플리케이션을동시에실행하여서컴퓨터시스템의성능을높이기위한기법 스레드란? 다중스레딩 (multi-threading) 은하나의프로그램이동시에여러가지작업을할수있도록하는것

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 11 장상속 이번장에서학습할내용 상속이란? 상속의사용 메소드재정의 접근지정자 상속과생성자 Object 클래스 종단클래스 상속을코드를재사용하기위한중요한기법입니다. 상속이란? 상속의개념은현실세계에도존재한다. 상속의장점 상속의장점 상속을통하여기존클래스의필드와메소드를재사용 기존클래스의일부변경도가능 상속을이용하게되면복잡한 GUI 프로그램을순식간에작성

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 5 장생성자와접근제어 1. 객체지향기법을이해한다. 2. 클래스를작성할수있다. 3. 클래스에서객체를생성할수있다. 4. 생성자를이용하여객체를초기화할수 있다. 5. 접근자와설정자를사용할수있다. 이번장에서만들어볼프로그램 생성자 생성자 (constructor) 는초기화를담당하는함수 생성자가필요한이유 #include using namespace

More information

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 8 장클래스와객체 I 이번장에서학습할내용 클래스와객체 객체의일생직접 메소드클래스를 필드작성해 UML 봅시다. QUIZ 1. 객체는 속성과 동작을가지고있다. 2. 자동차가객체라면클래스는 설계도이다. 먼저앞장에서학습한클래스와객체의개념을복습해봅시다. 클래스의구성 클래스 (class) 는객체의설계도라할수있다. 클래스는필드와메소드로이루어진다.

More information

중간고사

중간고사 기말고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한 후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답 에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4 자리숫자 ) 를기입하면성적공고시학번대신암호를 사용할것임. // ArithmeticOperator

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

슬라이드 1

슬라이드 1 UNIT 16 예외처리 로봇 SW 교육원 3 기 최상훈 학습목표 2 예외처리구문 try-catch-finally 문을사용핛수있다. 프로그램오류 3 프로그램오류의종류 컴파일에러 (compile-time error) : 컴파일실행시발생 럮타임에러 (runtime error) : 프로그램실행시발생 에러 (error) 프로그램코드에의해서해결될수없는심각핚오류 ex)

More information

JAVA PROGRAMMING 실습 08.다형성

JAVA PROGRAMMING 실습 08.다형성 2015 학년도 2 학기 1. 추상메소드 선언은되어있으나코드구현되어있지않은메소드 abstract 키워드사용 메소드타입, 이름, 매개변수리스트만선언 public abstract String getname(); public abstract void setname(string s); 2. 추상클래스 abstract 키워드로선언한클래스 종류 추상메소드를포함하는클래스

More information

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

JTable과 MVC(Model-View-Controller) 구조 - 모델-뷰-컨트롤러구조는데이터의저장과접근에대한제공은모델이담당하고, 화면표시는뷰, 이벤트의처리는컨트롤러가하도록각역할을구분한구조이다. 즉, 역할의분담을통하여상호간의영향을최소화하고각요소의독립성을보장하여독자 JTable 에서사용하는 Model 객체 JTable - JTable은데이터베이스의검색결과를 GUI에보여주기위해사용되는컴포넌트이다. 가로와세로로구성된테이블을을사용해서행과열에데이터를위치시킨다. - JTable을사용하는방법은다음과같다. 1 테이블에출력될데이터를 2차원배열에저장한다. Object[][] records = { {..., {..., {... ; 2 제목으로사용할문제열을

More information

JavaPrintingModel2_JunoYoon.PDF

JavaPrintingModel2_JunoYoon.PDF 2 JSTORM http://wwwjstormpekr 2 Issued by: < > Revision: Document Information Document title: 2 Document file name: Revision number: Issued by: Issue Date:

More information

No Slide Title

No Slide Title 그래픽사용자인터페이스 이충기 명지대학교컴퓨터공학과 그래픽사용자인터페이스 그래픽사용자인터페이스 (GUI) 는사람과컴퓨터간의상호작용을위한사람 - 컴퓨터인터페이스 (HCI) 중의하나이다. GUI 는사용자가컴퓨터화면상에있는객체들과상호작용을하는인터페이스이다. 오늘날사실상거의모든컴퓨터플랫폼에서 GUI 가사용되고있다. 2 GUI 프로그래밍 GUI 프로그램은실행시키면메뉴가있는창이뜨고창에는아이콘,

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

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

(Microsoft PowerPoint - java1-lecture7.ppt [\310\243\310\257 \270\360\265\345]) 그래픽사용자인터페이스 그래픽사용자인터페이스이벤트객체, 리스너 그래픽사용자인터페이스 (Graphical User Interface, 간단히 GUI) 는컴포넌트들로구성된다. 514760-1 2016 년가을학기 11/10/2016 박경신 자바에서 GUI 의종류 AWT(Abatract Windows Toolkit) 운영체제가제공하는자원을이용하여서컴포넌트를생성한다.

More information

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2 객체지향프로그래밍 IT CookBook, 자바로배우는쉬운자료구조 q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2 q 객체지향프로그래밍의이해 v 프로그래밍기법의발달 A 군의사업발전 1 단계 구조적프로그래밍방식 3 q 객체지향프로그래밍의이해 A 군의사업발전 2 단계 객체지향프로그래밍방식 4 q 객체지향프로그래밍의이해 v 객체란무엇인가

More information

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

(Microsoft PowerPoint - ETRSRHFRXNAM.ppt [\310\243\310\257 \270\360\265\345]) 자바애플릿 학습목표 애플릿동작환경 브라우저에서애플릿이동작하는방법 애플릿프로그램밍 Applet 클래스 폰트및칼라 이미지로드및출력 애니메이션 더블버퍼링을이용한이미지로드및출력 사운드로드및출력 애플릿에서이벤트처리 애플릿프로그램이란? 클라이언트시스템이서버로부터웹페이지를다운로드받았을때, 웹페이지의특정한윈도우에서동작하는프로그램 동작과정 www.webserver.com 2

More information

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

Microsoft PowerPoint - lec04_05.ppt [호환 모드] JAVA 프로그래밍 4. 그래픽프로그래밍 한동일 학습목표 To be able to write simple GUI applications To display graphical shapes such as lines and ellipses To use colors To display drawings consisting of many shapes To read input

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 1 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

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

Microsoft Word - java18-1-final-answer.doc 기말고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4자리숫자 ) 를기입하면성적공고시학번대신암호를사용할것임. 1. 다음 sub1 과 sub2

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

11-GUI.key

11-GUI.key 10 (GUI) (Graphical User Interface) AWT/Swing Java java.awt, javax.swing (Event-Driven Programming) :,,,, (event-handler or event-listener), Java (action event), (action listner). Java AWT/Swing (component),

More information

Design Issues

Design Issues 11 COMPUTER PROGRAMMING INHERIATANCE CONTENTS OVERVIEW OF INHERITANCE INHERITANCE OF MEMBER VARIABLE RESERVED WORD SUPER METHOD INHERITANCE and OVERRIDING INHERITANCE and CONSTRUCTOR 2 Overview of Inheritance

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 멀티태스킹과스레드의개념이해 2. Thread 클래스를상속받아자바스레드만들기 3. Runnable 인터페이스를구현하여자바스레드만들기 4. 스레드종료시키기 5. 스레드의동기화개념과필요성이해 6. synchronized로간단한스레드동기화 7. wait()-notify() 로간단한스레드동기화 멀티태스킹 (multi-tasking)

More information

12-file.key

12-file.key 11 (String).. java.lang.stringbuffer. s String s = "abcd"; s = s + "e"; a b c d e a b c d e ,., "910359,, " "910359" " " " " (token) (token),, (delimiter). java.util.stringtokenizer String s = "910359,,

More information

PowerPoint Presentation

PowerPoint Presentation 자바프로그래밍 1 배열 손시운 ssw5176@kangwon.ac.kr 배열이필요한이유 예를들어서학생이 10 명이있고성적의평균을계산한다고가정하자. 학생 이 10 명이므로 10 개의변수가필요하다. int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; 하지만만약학생이 100 명이라면어떻게해야하는가? int s0, s1, s2, s3, s4,

More information

PowerPoint Presentation

PowerPoint Presentation 자바프로그래밍 1 클래스와메소드심층연구 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 접근제어 class A { private int a; int b; public int c; // 전용 // 디폴트 // 공용 public class Test { public static void main(string args[]) { A obj = new

More information

Microsoft PowerPoint - 2강

Microsoft PowerPoint - 2강 컴퓨터과학과 김희천교수 학습개요 Java 언어문법의기본사항, 자료형, 변수와상수선언및사용법, 각종연산자사용법, if/switch 등과같은제어문사용법등에대해설명한다. 또한 C++ 언어와선언 / 사용방법이다른 Java의배열선언및사용법에대해서설명한다. Java 언어의효과적인활용을위해서는기본문법을이해하는것이중요하다. 객체지향의기본개념에대해알아보고 Java에서어떻게객체지향적요소를적용하고있는지살펴본다.

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 3 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

JAVA PROGRAMMING 실습 09. 예외처리

JAVA PROGRAMMING 실습 09. 예외처리 2015 학년도 2 학기 예외? 프로그램실행중에발생하는예기치않은사건 예외가발생하는경우 정수를 0으로나누는경우 배열의크기보다큰인덱스로배열의원소를접근하는경우 파일의마지막부분에서데이터를읽으려고하는경우 예외처리 프로그램에문제를발생시키지않고프로그램을실행할수있게적절한조치를취하는것 자바는예외처리기를이용하여예외처리를할수있는기법제공 자바는예외를객체로취급!! 나뉨수를입력하시오

More information

Network Programming

Network Programming Part 5 확장된 Network Programming 기술 1. Remote Procedure Call 2. Remote Method Invocation 3. Object Request Broker 2. Java RMI

More information

ch09

ch09 9 Chapter CHAPTER GOALS B I G J A V A 436 CHAPTER CONTENTS 9.1 436 Syntax 9.1 441 Syntax 9.2 442 Common Error 9.1 442 9.2 443 Syntax 9.3 445 Advanced Topic 9.1 445 9.3 446 9.4 448 Syntax 9.4 454 Advanced

More information

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

모든스윙컴포넌트에는텍스트옆에이미지를추가로표시할수있다. ImageIcon image = new ImageIcon(image.gif); JLabel label = new JLabel( 이미지레이블 ); label.seticon(image); JAVA Programming Spring, 2016 Dongwoo Kang 모든스윙컴포넌트에는텍스트옆에이미지를추가로표시할수있다. ImageIcon image = new ImageIcon("image.gif"); JLabel label = new JLabel(" 이미지레이블 "); label.seticon(image); 이미지버튼을표시하고사용자가버튼을누르면레이블의텍스트를이미지로바꾸어서표시하는프로그램을작성해보자.

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 11 장상속 1. 상속의개념을이해한다. 2. 상속을이용하여자식클래스를작성할수있다. 3. 상속과접근지정자와의관계를이해한다. 4. 상속시생성자와소멸자가호출되는순서를이해한다. 이번장에서만들어볼프로그램 class Circle { int x, y; int radius;... class Rect { int x, y; int width, height;... 중복 상속의개요

More information

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

Microsoft PowerPoint - java1-lecture10.ppt [호환 모드] 그래픽사용자인터페이스 그래픽사용자인터페이스이벤트객체, 리스너 그래픽사용자인터페이스 (Graphical User Interface, 간단히 GUI) 는컴포넌트들로구성된다. 514760-1 2018 년봄학기 5/15/2018 박경신 자바에서 GUI 의종류 AWT(Abatract Windows Toolkit) 운영체제가제공하는자원을이용하여서컴포넌트를생성한다. SWING

More information

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

(Microsoft PowerPoint - LZVNQBAJWGTC.ppt [\310\243\310\257 \270\360\265\345]) GUI 인터페이스의이벤트 학습목표 윈도우환경에서작성된 GUI 인터페이스의이벤트개념을이해한다. 다양한컴포넌트에대한이벤트를처리한다 이벤트란? 자바이벤트란 사용자가키보드, 마우스등의장치로부터 AWT 컴포넌트에발생시키는모든사건을의미 이벤트주도형프로그램은사용자로부터발생된이벤트를처리하여사용자와상호작용을가능하게함 자바이벤트모델 컴퓨터 키보드 운영체제 마우스 이벤트객체자바가상머신이벤트소스객체이벤트리스너객체애플리케이션

More information

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

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public Chapter 9 Lab 문제정답 1. public class Circle private double radius; static final double PI=3.141592; // PI 이름으로 3.141592 로초기화된정적상수 (1) public Circle(double r) radius = r; (2) public double getradius() return

More information

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

Microsoft PowerPoint - java1-lecture11.ppt [호환 모드] Overview Swing Component 514760-1 2018 년봄학기 5/22/2018 박경신 JLabel, ImageIcon JTextField, JTextArea JButton, JCheckBox, JRadioButton JSlider, JComboBox JPanel, JScrollPane, JOptionPane JTable Timer JFileChooser,

More information

신림프로그래머_클린코드.key

신림프로그래머_클린코드.key CLEAN CODE 6 11st Front Dev. Team 6 1. 2. 3. checked exception 4. 5. 6. 11 : 2 4 : java (50%), javascript (35%), SQL/PL-SQL (15%) : Spring, ibatis, Oracle, jquery ? , (, ) ( ) 클린코드를 무시한다면 . 6 1. ,,,!

More information

슬라이드 1

슬라이드 1 이벤트 () 란? - 사용자가입력장치 ( 키보드, 마우스등 ) 등을이용해서발생하는사건 - 이벤트를처리하는프로그램은이벤트가발생할때까지무한루프를돌면서대기상태에있는다. 이벤트가발생하면발생한이벤트의종류에따라특정한작업을수행한다. - 이벤트관련프로그램작성을위해 java.awt.event.* 패키지가필요 - 버튼을누른경우, 1 버튼클릭이벤트발생 2 발생한이벤트인식 ( 이벤트리스너가수행

More information

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드] - Socket Programming in Java - 목차 소켓소개 자바에서의 TCP 프로그램작성방법 주요클래스와메소드 HTTP 프로토콜을이용한예제 에코프로그램 Q/A 에코프로그램 - EchoServer 에코프로그램 - EchoClient TCP Programming 1 소켓소개 IP, Port, and Socket 포트 (Port): 전송계층에서통신을수행하는응용프로그램을찾기위한주소

More information

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Spring Boot/JDBC JdbcTemplate/CRUD 예제 Spring Boot/JDBC JdbcTemplate/CRUD 예제 오라클자바커뮤니티 (ojc.asia, ojcedu.com) Spring Boot, Gradle 과오픈소스인 MariaDB 를이용해서 EMP 테이블을만들고 JdbcTemplate, SimpleJdbcTemplate 을이용하여 CRUD 기능을구현해보자. 마리아 DB 설치는다음 URL 에서확인하자.

More information

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android 2 xmlns:tools=http://schemas.android. 10 차시파일처리 1 학습목표 내장메모리의파일을처리하는방법을배운다. SD 카드의파일을처리하는방법을배운다. 2 확인해볼까? 3 내장메모리파일처리 1) 학습하기 [ 그림 10-1] 내장메모리를사용한파일처리 2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1

More information

02 C h a p t e r Java

02 C h a p t e r Java 02 C h a p t e r Java Bioinformatics in J a va,, 2 1,,,, C++, Python, (Java),,, (http://wwwbiojavaorg),, 13, 3D GUI,,, (Java programming language) (Sun Microsystems) 1995 1990 (green project) TV 22 CHAPTER

More information

Microsoft PowerPoint - 06-Chapter09-Event.ppt

Microsoft PowerPoint - 06-Chapter09-Event.ppt AWT 이벤트처리하기 1. 이벤트처리방식 2. 이벤트클래스와리스너 3. 이벤트어댑터 4. 이벤트의종류 이벤트 (Event) 이벤트 사용자가 UI 컴포넌트에대해취하는행위로인한사건이벤트기반프로그래밍 무한루프를돌면서사용자의행위로인한이벤트를청취하여응답하는형태로작동하는프로그래밍 java.awt.event 이벤트처리 AWT 컴포넌트에서발생하는다양한이벤트를처리하기위한인터페이스와클래스제공

More information

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

Microsoft PowerPoint - [JAVA프로그래밍]9장GUI 명품 JAVA Programming 1 제 9 장자바 GUI 기초, AWT 와스윙 (SWING) 자바의 GUI(Graphical User Interface) 2 GUI 목적 그래픽이용, 사용자에게이해하기쉬운모양으로정보제공 사용자는마우스나키보드를이용하여쉽게입력 자바 GUI 특징 강력한 GUI 컴포넌트제공 쉬운 GUI 프로그래밍 자바의 GUI 프로그래밍방법 GUI

More information

쉽게 풀어쓴 C 프로그래밊

쉽게 풀어쓴 C 프로그래밊 Power Java 제 27 장데이터베이스 프로그래밍 이번장에서학습할내용 자바와데이터베이스 데이터베이스의기초 SQL JDBC 를이용한프로그래밍 변경가능한결과집합 자바를통하여데이터베이스를사용하는방법을학습합니다. 자바와데이터베이스 JDBC(Java Database Connectivity) 는자바 API 의하나로서데이터베이스에연결하여서데이터베이스안의데이터에대하여검색하고데이터를변경할수있게한다.

More information

Microsoft PowerPoint - 03-TCP Programming.ppt

Microsoft PowerPoint - 03-TCP Programming.ppt Chapter 3. - Socket in Java - 목차 소켓소개 자바에서의 프로그램작성방법 주요클래스와메소드 HTTP 프로토콜을이용한예제 에코프로그램 에코프로그램 - EchoServer 에코프로그램 - EchoClient Q/A 1 1 소켓소개 IP,, and Socket 포트 (): 전송계층에서통신을수행하는응용프로그램을찾기위한주소 소켓 (Socket):

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Graphical User Interface 배효철 th1g@nate.com 1 목차 자바의 GUI AWT와 Swing 패키지 Swing 클래스의특징 컨테이너와컴포넌트 Swing GUI 만들기 컨테이너와배치 2 자바의 GUI GUI 목적 그래픽이용, 사용자에게이해하기쉬운모양으로정보제공 사용자는마우스나키보드를이용하여쉽게입력 자바 GUI 특징 강력한 GUI 컴포넌트제공

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스와메소드심층연구 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 접근제어 class A { private int a; int b; public int c; // 전용 // 디폴트 // 공용 public class Test { public static void main(string args[]) { A obj = new

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 기본예제 예외클래스를정의하고사용하는예제 class NewException extends Exception { public class ExceptionTest { static void methoda() throws NewException { System.out.println("NewException

More information

슬라이드 1

슬라이드 1 프로세싱 광운대학교로봇학부박광현 프로세싱실행 2 C:\processing-3.2.1 폴더 창나타내기 실행 정지 3 폭 높이 600 400 도형그리기 배경칠하기 5 background(255, 255, 255); R G B background(255, 0, 0); background(255, 122, 0); 선그리기 6 background(255, 122, 0);

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 실습 1 배효철 th1g@nate.com 1 목차 조건문 반복문 System.out 구구단 모양만들기 Up & Down 2 조건문 조건문의종류 If, switch If 문 조건식결과따라중괄호 { 블록을실행할지여부결정할때사용 조건식 true 또는 false값을산출할수있는연산식 boolean 변수 조건식이 true이면블록실행하고 false 이면블록실행하지않음 3

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 인터페이스, 람다식, 패키지 손시운 ssw5176@kangwon.ac.kr 인터페이스 인터페이스 (interafce) 는서로다른장치들이연결되어서상호데이터를주 고받는규격을의미한다 2 자바인터페이스 클래스와클래스사이의상호작용의규격을나타낸것이인터페이스이다 3 인터페이스의예 스마트홈시스템 (Smart Home System) 4 인터페이스의정의 public

More information

자바 프로그래밍

자바 프로그래밍 5 (kkman@mail.sangji.ac.kr) (Class), (template) (Object) public, final, abstract [modifier] class ClassName { // // (, ) Class Circle { int radius, color ; int x, y ; float getarea() { return 3.14159

More information