대학교 수업/Java 프로그래밍
2022.12.05
1번 import javax.swing.*; public class Chapter14 extends JFrame { public Chapter14() { setTitle("메뉴 만들기"); setDefaultCloseOperation(3); createMenu(); setSize(300,200); setVisible(true); } private void createMenu() { JMenu fileMenu = new JMenu("파일"); JMenu editMenu = new JMenu("편집"); JMenu viewMenu = new JMenu("보기"); viewMenu.add(new JMenuItem("화면확대")); viewMenu.add(new JMenuItem("쪽윤곽")); JMenu in..
대학교 수업/Java 프로그래밍
2022.12.05
1번 import javax.swing.*; import java.util.Scanner; public class Chapter13 extends JFrame { class MyThread implements Runnable { public void run() { System.out.println("스레드 실행 시작"); for(int i=1; i GamePanel.this.getWidth()) target.setLocation(0,0); else target.setLocation(x, y); target.getParent().repaint(); try { sleep(20); } catch(InterruptedException e) { target.setLocation(0, 0); target.getPa..
대학교 수업/Java 프로그래밍
2022.11.22
1-1 번 import java.awt.*; import javax.swing.*; public class Chapter12 extends JFrame { Chapter12(){ setTitle("이미지 그리기 연습"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setContentPane(new MyPanel()); setSize(300,300); setVisible(true); } class MyPanel extends JPanel { ImageIcon icon = new ImageIcon("src/back.jpg"); Image img = icon.getImage(); public MyPanel() { setLayout(new FlowLayout()); a..
대학교 수업/Java 프로그래밍
2022.10.11
1번 import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.*; class Chapter10 extends JFrame{ Chapter10(){ setTitle("마우스 올리기 내리기"); setDefaultCloseOperation(3); Container c = getContentPane(); c.setLayout(new FlowLayout()); JLabel label = new JLabel("Love Java"); label.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e)..
대학교 수업/Java 프로그래밍
2022.10.11
import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.*; class Challenge10 extends JFrame{ Challenge10(){ setTitle("Open Challenge 10"); setDefaultCloseOperation(3); Container c = getContentPane(); c.setLayout(null); JLabel labels[] = new JLabel[3]; JLabel result = new JLabel("시작합니다."); result.setSize(200, 20); result.setLocation(180, 250); this...
대학교 수업/Java 프로그래밍
2022.10.11
import java.awt.*; import javax.swing.*; class Challenge9 extends JFrame{ Challenge9(){ setTitle("Open Challenge9"); setDefaultCloseOperation(3); Container c = getContentPane(); c.setLayout(new BorderLayout()); c.add(new NorthPanel(), BorderLayout.NORTH); c.add(new CenterPanel(), BorderLayout.CENTER); setSize(400, 500); setVisible(true); } class NorthPanel extends JPanel{ NorthPanel(){ setBackgr..
대학교 수업/Java 프로그래밍
2022.10.05
1번 import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; public class Chapter10 extends JFrame { Chapter10(){ setTitle("CheckBox Practice"); setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); JCheckBox disableButton = new JCheckBox("버튼 비활성화"); JCheckBox hideButton = new JCheckBox("버튼 감추기"..
대학교 수업/Java 프로그래밍
2022.10.03
1번 import javax.swing.*; public class Chapter9 extends JFrame { Chapter9(){ setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Let's study Java"); setSize(400, 200); setVisible(true); } public static void main(String args[]){ new Chapter9(); } } 2번 import javax.swing.*; import java.awt.*; public class Chapter9 extends JFrame { Chapter9(){ setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Border..