MapleStory Finger Point

🟀 JAVA/πŸ“šλͺ…ν’ˆ JAVA_ESSENTIAL

[λͺ…ν’ˆ JAVA ESSENTIAL] CH8 μ‹€μŠ΅λ¬Έμ œ

HYEJU01 2022. 4. 17. 16:51
"κ°œμ •νŒ: λͺ…ν’ˆ JAVAESSENTIAL(ν™©κΈ°νƒœ)"κ΅μž¬μ— 수둝된 λ¬Έμ œλ“€μ„ ν’€μ–΄μ„œ μ˜¬λ¦½λ‹ˆλ‹€.
문제의 번호만 ν‘œκΈ°ν•˜κ³  λ‹΅μ•ˆλ§Œ μ λŠ” ν˜•νƒœλ‘œ μ—…λ‘œλ“œ ν•˜κ³ μžˆμŠ΅λ‹ˆλ‹€.
개인 ν’€μ΄μ΄λ―€λ‘œ μ˜€λ‹΅μ΄ μžˆμ„ 수 있으며 μ˜€λ‹΅ 발견 μ‹œ λŒ“κΈ€ λ‚¨κ²¨μ£Όμ‹œλ©΄ κ°μ‚¬ν•˜κ² μŠ΅λ‹ˆλ‹€πŸ˜Š
-
#이 ν‘œμ‹œλœ 건 아직 풀지 λͺ»ν•œ 문제 or ν—·κ°ˆλ¦¬λŠ” λ¬Έμ œμž…λ‹ˆλ‹€!
좔후에 λ‹€μ‹œ ν’€μ–΄μ„œ 올릴 μ˜ˆμ •μ΄μ—μš”!

-ujeyhx-

 

πŸ”Žμ‹€μŠ΅λ¬Έμ œ

 

 

 

1) 

import javax.swing.*;
import java.awt.*;

public class TEST2 extends JFrame {
	public TEST2() {
		setTitle("Let's study java");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		setSize(400,200);
		setVisible(true);
	
}



public static void main (String[] args) {
	new TEST2();
}
}


2)

 

import javax.swing.*;
import java.awt.*;

public class TEST2 extends JFrame {
	public TEST2() {
		setTitle("BorderLayout Practice");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Container c = getContentPane();
		
		c.setLayout(new BorderLayout(50,5)); //μˆ˜ν‰μˆ˜μ§ 간격
		c.add(new JButton("Center"),BorderLayout.CENTER);
		c.add(new JButton("South"),BorderLayout.SOUTH);
		c.add(new JButton("North"),BorderLayout.NORTH);
		c.add(new JButton("East"),BorderLayout.EAST);
		c.add(new JButton("West"),BorderLayout.WEST);
		
		
		setSize(500,300);
		setVisible(true);
	
}



public static void main (String[] args) {
	new TEST2();
}
}

 


3)

import javax.swing.*;
import java.awt.*;

public class TEST2 extends JFrame {
	public TEST2() {
		setTitle("FlowLayout Practice");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Container c = getContentPane();
		
		c.setLayout(new FlowLayout());
		
		c.add(new JLabel("100 + 200"));
		c.add(new JButton("="));
		c.add(new JLabel("300"));
		
		setSize(400,100);
		setVisible(true);
	
}



public static void main (String[] args) {
	new TEST2();
}
}


 

4)


import javax.swing.*;
import java.awt.*;

public class TEST2 extends JFrame {

	public TEST2() {
		
		setTitle("Ten Color");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	
		Container c = getContentPane();	
		c.setLayout(new GridLayout(1,10));
		
	
	
		Color [] cl = {Color.RED, Color.ORANGE, Color.YELLOW, 
				Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.GRAY,
				Color.PINK, Color.LIGHT_GRAY};

		for(int i=0; i<10; i++) {
			
			JButton btn = new JButton(Integer.toString(i));
			btn.setOpaque(true); //배경색 보이게 μ„€μ •
			btn.setBackground(cl[i]);

			
			c.add(btn); 
		}
	
		setSize(500,300);
		setVisible(true);
}



public static void main (String[] args) {
	new TEST2();
}
}


5)

import javax.swing.*;
import java.awt.*;

public class TEST2 extends JFrame {

	public TEST2() {
		
		setTitle("4x4");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	
		Container c = getContentPane();	
		c.setLayout(new GridLayout(4,4));
		
	
		JLabel [] la = new JLabel[16];
		Color [] color = {Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN,
				Color.CYAN, Color.BLUE, Color.MAGENTA, Color.GRAY,
				Color.PINK, Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY,
				Color.BLACK, Color.ORANGE, Color.BLUE,Color.MAGENTA}; 


		for(int i=0; i<=15; i++) {
			
			la[i] = new JLabel(Integer.toString(i));
			la[i].setOpaque(true); //배경색 보이게 μ„€μ •
			la[i].setBackground(color[i]);

			c.add(la[i]); 
		}
	
		setSize(500,300);
		setVisible(true);
}



public static void main (String[] args) {
	new TEST2();
}
}

 

 


6)

import javax.swing.*;
import java.awt.*;

public class TEST2 extends JFrame {

	public TEST2() {
		
		setTitle("Rd");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	
		Container c = getContentPane();	
	
		
		for(int i=0; i<20; i++) {
			
		JLabel la = new JLabel(Integer.toString(i));
		int x = (int)(Math.random()*220) +30;
		int y = (int)(Math.random()*220) +30;
		
		la.setLocation(x,y);
		la.setSize(20,20);
		la.setForeground(Color.MAGENTA);
		
		c.add(la);
		}
	
		
		setSize(300,400);
		setVisible(true);
}



public static void main (String[] args) {
	new TEST2();
}
}

 


7) κΈ°λŠ₯ κ΅¬ν˜„μ€ λ”°λ‘œ μ•ˆ ν–ˆκ³ , λ ˆμ΄μ•„μ›ƒλ§Œ λ§Œλ“€μ—ˆμŠ΅λ‹ˆλ‹Ή πŸ‘©

 

import javax.swing.*;
import java.awt.*;


class TopPanel extends JPanel {
	public TopPanel () {
		setLayout(new FlowLayout());
		add(new JButton("μƒˆλ‘œλ°°μΉ˜"));
		add(new JButton("μ’…λ£Œ"));
		
	}
}

class CenterPanel extends JPanel {
	public CenterPanel () {

		setLayout(null);
		for(int i=0; i<10; i++) {
		JLabel la = new JLabel("*");
		int x = (int)(Math.random()*220) +30;
		int y = (int)(Math.random()*220) +30;
		la.setLocation(x,y);
		la.setSize(20,20);
		la.setForeground(Color.MAGENTA);
		add(la);
		}
		
	}
}


class BottomPanel extends JPanel {
	public BottomPanel () {
		setLayout(new FlowLayout());
		add(new JButton("λ³„κ°œμˆ˜ μˆ˜μ •"));
		add(new JTextField(12));
	}
}



public class TEST2 extends JFrame {

	public TEST2() {
		
		setTitle("3개의 νŒ¨λ„");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		add(new TopPanel(), BorderLayout.NORTH); 
		add(new CenterPanel(), BorderLayout.CENTER); 
		add(new BottomPanel(), BorderLayout.SOUTH); 

		setSize(300,400);
		setVisible(true);
}



public static void main (String[] args) {
	new TEST2();
}
}