diff --git a/PROJECT221019/.idea/.gitignore b/PROJECT221019/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/PROJECT221019/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/PROJECT221019/.idea/misc.xml b/PROJECT221019/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/PROJECT221019/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PROJECT221019/.idea/modules.xml b/PROJECT221019/.idea/modules.xml new file mode 100644 index 0000000..d142cf8 --- /dev/null +++ b/PROJECT221019/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/PROJECT221019/.idea/uiDesigner.xml b/PROJECT221019/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/PROJECT221019/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PROJECT221019/.idea/vcs.xml b/PROJECT221019/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/PROJECT221019/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PROJECT221019/PROJECT221019.iml b/PROJECT221019/PROJECT221019.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/PROJECT221019/PROJECT221019.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/PROJECT221019/out/production/PROJECT221019/BorderLayoutEx.class b/PROJECT221019/out/production/PROJECT221019/BorderLayoutEx.class new file mode 100644 index 0000000..65ec004 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/BorderLayoutEx.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/CenterPanel.class b/PROJECT221019/out/production/PROJECT221019/CenterPanel.class new file mode 100644 index 0000000..5555712 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/CenterPanel.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/CenterPanel2.class b/PROJECT221019/out/production/PROJECT221019/CenterPanel2.class new file mode 100644 index 0000000..c884ee8 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/CenterPanel2.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/ContentPaneEx.class b/PROJECT221019/out/production/PROJECT221019/ContentPaneEx.class new file mode 100644 index 0000000..cf3161f Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/ContentPaneEx.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/FlowLayoutEx.class b/PROJECT221019/out/production/PROJECT221019/FlowLayoutEx.class new file mode 100644 index 0000000..fc1baa1 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/FlowLayoutEx.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/GridLayoutEx.class b/PROJECT221019/out/production/PROJECT221019/GridLayoutEx.class new file mode 100644 index 0000000..4649efc Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/GridLayoutEx.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex01.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex01.class new file mode 100644 index 0000000..334bd55 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex01.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex02.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex02.class new file mode 100644 index 0000000..d934d97 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex02.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex03.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex03.class new file mode 100644 index 0000000..f219023 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex03.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex04.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex04.class new file mode 100644 index 0000000..d2509a1 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex04.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex05.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex05.class new file mode 100644 index 0000000..d72d05d Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex05.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex06.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex06.class new file mode 100644 index 0000000..63b2bd8 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex06.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex07.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex07.class new file mode 100644 index 0000000..918f87d Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex07.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/Lab08Ex08.class b/PROJECT221019/out/production/PROJECT221019/Lab08Ex08.class new file mode 100644 index 0000000..9aab3f3 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/Lab08Ex08.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/MyFrame.class b/PROJECT221019/out/production/PROJECT221019/MyFrame.class new file mode 100644 index 0000000..4abf059 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/MyFrame.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/NorthPanel.class b/PROJECT221019/out/production/PROJECT221019/NorthPanel.class new file mode 100644 index 0000000..b40fa80 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/NorthPanel.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/NorthPanel2.class b/PROJECT221019/out/production/PROJECT221019/NorthPanel2.class new file mode 100644 index 0000000..1cb2e32 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/NorthPanel2.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/NullContainerEx.class b/PROJECT221019/out/production/PROJECT221019/NullContainerEx.class new file mode 100644 index 0000000..0a61eb6 Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/NullContainerEx.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/OpenChallenge.class b/PROJECT221019/out/production/PROJECT221019/OpenChallenge.class new file mode 100644 index 0000000..987d8bf Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/OpenChallenge.class differ diff --git a/PROJECT221019/out/production/PROJECT221019/SouthPanel2.class b/PROJECT221019/out/production/PROJECT221019/SouthPanel2.class new file mode 100644 index 0000000..24f0bad Binary files /dev/null and b/PROJECT221019/out/production/PROJECT221019/SouthPanel2.class differ diff --git a/PROJECT221019/src/BorderLayoutEx.java b/PROJECT221019/src/BorderLayoutEx.java new file mode 100644 index 0000000..08ed055 --- /dev/null +++ b/PROJECT221019/src/BorderLayoutEx.java @@ -0,0 +1,20 @@ +import javax.swing.*; +import java.awt.*; +public class BorderLayoutEx extends JFrame { + public BorderLayoutEx() { + setTitle("BorderLayout Sample"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + 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); + setSize(300, 200); // 프레임 크기 300×200 설정 + setVisible(true); // 프레임을 화면에 출력 + } + public static void main(String[] args) { + new BorderLayoutEx(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/ContentPaneEx.java b/PROJECT221019/src/ContentPaneEx.java new file mode 100644 index 0000000..ba004de --- /dev/null +++ b/PROJECT221019/src/ContentPaneEx.java @@ -0,0 +1,19 @@ +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(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/FlowLayoutEx.java b/PROJECT221019/src/FlowLayoutEx.java new file mode 100644 index 0000000..3188240 --- /dev/null +++ b/PROJECT221019/src/FlowLayoutEx.java @@ -0,0 +1,20 @@ +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); + } + public static void main(String[] args) { + new FlowLayoutEx(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/GridLayoutEx.java b/PROJECT221019/src/GridLayoutEx.java new file mode 100644 index 0000000..56ed785 --- /dev/null +++ b/PROJECT221019/src/GridLayoutEx.java @@ -0,0 +1,25 @@ +import javax.swing.*; +import java.awt.*; +public class GridLayoutEx extends JFrame { + public GridLayoutEx() { + setTitle("GridLayout Sample"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + 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(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/Lab08Ex01.java b/PROJECT221019/src/Lab08Ex01.java new file mode 100644 index 0000000..4c2ddcb --- /dev/null +++ b/PROJECT221019/src/Lab08Ex01.java @@ -0,0 +1,26 @@ +import java.awt.BorderLayout; +import java.awt.Container; +import javax.swing.JButton; +import javax.swing.JFrame; + +public class Lab08Ex01 extends JFrame { + Lab08Ex01() { + setTitle("BorderLayout Practice"); + setSize(400, 200); + setDefaultCloseOperation(EXIT_ON_CLOSE); + + Container c=getContentPane(); + c.setLayout(new BorderLayout(5,7)); + + c.add(new JButton("North"), BorderLayout.NORTH); //대문자 + c.add(new JButton("West"), BorderLayout.WEST); + c.add(new JButton("Center"), BorderLayout.CENTER); + c.add(new JButton("East"), BorderLayout.EAST); + c.add(new JButton("South"), BorderLayout.SOUTH); + setVisible(true); + } + + public static void main(String[] args) { + new Lab08Ex01(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/Lab08Ex02.java b/PROJECT221019/src/Lab08Ex02.java new file mode 100644 index 0000000..0c8724a --- /dev/null +++ b/PROJECT221019/src/Lab08Ex02.java @@ -0,0 +1,24 @@ +import javax.swing.*; +import java.awt.*; + +public class Lab08Ex02 extends JFrame { + Lab08Ex02() { + setTitle("BorderLayout Practice"); + setSize(400, 200); + setDefaultCloseOperation(EXIT_ON_CLOSE); + + Container c=getContentPane(); + c.setLayout(new BorderLayout(5,7)); + + c.add(new JButton("North"), BorderLayout.NORTH); + c.add(new JButton("West"), BorderLayout.WEST); + c.add(new JButton("Center"), BorderLayout.CENTER); + c.add(new JButton("East"), BorderLayout.EAST); + c.add(new JButton("South"), BorderLayout.SOUTH); + setVisible(true); + } + + public static void main(String[] args) { + new Lab08Ex02(); + } +} diff --git a/PROJECT221019/src/Lab08Ex03.java b/PROJECT221019/src/Lab08Ex03.java new file mode 100644 index 0000000..7cb6d22 --- /dev/null +++ b/PROJECT221019/src/Lab08Ex03.java @@ -0,0 +1,22 @@ +import javax.swing.*; +import java.awt.*; + +public class Lab08Ex03 extends JFrame { + Lab08Ex03() { + setTitle("BorderLayout Practice"); + setSize(600, 300); + setDefaultCloseOperation(EXIT_ON_CLOSE); + + Container c=getContentPane(); + c.setLayout(new GridLayout(1,10)); + + for(int i=0; i<10; i++) { + c.add(new JButton(i + "")); + } + setVisible(true); + } + + public static void main(String[] args) { + new Lab08Ex03(); + } +} diff --git a/PROJECT221019/src/Lab08Ex04.java b/PROJECT221019/src/Lab08Ex04.java new file mode 100644 index 0000000..7bbc5f2 --- /dev/null +++ b/PROJECT221019/src/Lab08Ex04.java @@ -0,0 +1,28 @@ +import java.awt.*; +import javax.swing.*; + +public class Lab08Ex04 extends JFrame { + Lab08Ex04() { + setTitle("Ten Color Buttons Frame"); + setSize(600, 300); + setDefaultCloseOperation(EXIT_ON_CLOSE); + + Container c=getContentPane(); + c.setLayout(new GridLayout(1,10)); + + for(int i=0; i<10; i++) { + Color[] col= {Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, + Color.CYAN, Color.BLUE, Color.MAGENTA, + Color.GRAY, Color.PINK, Color.LIGHT_GRAY}; + String text=Integer.toString(i); + JButton b=new JButton(text); + b.setOpaque(true); + b.setBackground(col[i]); + c.add(b); + } + setVisible(true); + } + public static void main(String[] args) { + new Lab08Ex04(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/Lab08Ex05.java b/PROJECT221019/src/Lab08Ex05.java new file mode 100644 index 0000000..0a55303 --- /dev/null +++ b/PROJECT221019/src/Lab08Ex05.java @@ -0,0 +1,30 @@ +import java.awt.*; +import javax.swing.*; + +public class Lab08Ex05 extends JFrame { + Lab08Ex05() { + setTitle("Ten Color Buttons Frame"); + setSize(600, 300); + setDefaultCloseOperation(EXIT_ON_CLOSE); + + Container c=getContentPane(); + c.setLayout(new GridLayout(4,4)); + + for(int i=0; i<16; i++) { + + Color[] col= {Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, + Color.CYAN, Color.BLUE, Color.MAGENTA, + Color.GRAY, Color.PINK, Color.LIGHT_GRAY, + Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, + Color.CYAN, Color.BLUE}; + JLabel label=new JLabel(i+""); + label.setBackground(col[i]); + label.setOpaque(true); + c.add(label); + } + setVisible(true); + } + public static void main(String[] args) { + new Lab08Ex05(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/Lab08Ex06.java b/PROJECT221019/src/Lab08Ex06.java new file mode 100644 index 0000000..1050fb0 --- /dev/null +++ b/PROJECT221019/src/Lab08Ex06.java @@ -0,0 +1,28 @@ +import java.awt.*; +import javax.swing.*; + +public class Lab08Ex06 extends JFrame { + + public Lab08Ex06() { + setTitle("Random Labels"); + setSize(300, 300); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + Container c = getContentPane(); + c.setLayout(null); + + for (int i = 0; i < 20; i++) { + int x = (int) (Math.random() * 200) + 50; + int y = (int) (Math.random() * 200) + 50; + JLabel label = new JLabel((int)(Math.random() * 100)+""); + label.setBounds(x, y, 20, 20); + label.setOpaque(true); + label.setBackground(Color.blue); + c.add(label); + } + setVisible(true); + } + public static void main(String[] args) { + new Lab08Ex06(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/Lab08Ex07.java b/PROJECT221019/src/Lab08Ex07.java new file mode 100644 index 0000000..0c25335 --- /dev/null +++ b/PROJECT221019/src/Lab08Ex07.java @@ -0,0 +1,54 @@ +import java.awt.*; +import javax.swing.*; + +public class Lab08Ex07 extends JFrame { + + Lab08Ex07() { + setTitle("계산기 프레임"); + setSize(400, 400); + setDefaultCloseOperation(EXIT_ON_CLOSE); + + Container c=getContentPane(); + JPanel pn=new JPanel(); + JPanel ps=new JPanel(); + JPanel pc=new JPanel(); + + pn.setBackground(Color.LIGHT_GRAY); + pc.setLayout(new GridLayout(4,4)); + ps.setBackground(Color.YELLOW); + + c.add(pc); + c.add(pn, BorderLayout.NORTH); + c.add(ps, BorderLayout.SOUTH); + + JLabel l1=new JLabel("수식입력"); + JTextField tf1=new JTextField(10); + pn.add(l1); + pn.add(tf1); + + JLabel l2=new JLabel("계산결과"); + JTextField tf2=new JTextField(10); + ps.add(l2); + ps.add(tf2); + + for(int i=0; i<16; i++) { + JButton b=new JButton(); + String[] str= {"CE","계산","+","-","x","/"}; + pc.add(b); + if(i<10) { + b.setText(i+""); + }else { + b.setText(str[i-10]); + } + if(i>11) { + b.setBackground(Color.CYAN); + b.setOpaque(true); + } + } + setVisible(true); + } + + public static void main(String[] args) { + new Lab08Ex07(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/Lab08Ex08.java b/PROJECT221019/src/Lab08Ex08.java new file mode 100644 index 0000000..a06e3d1 --- /dev/null +++ b/PROJECT221019/src/Lab08Ex08.java @@ -0,0 +1,53 @@ +import java.awt.*; +import javax.swing.*; + +class NorthPanel2 extends JPanel{ + public NorthPanel2() { + setBackground(Color.LIGHT_GRAY); + add(new JButton("열기")); + add(new JButton("닫기")); + add(new JButton("나가기")); + } +} +class CenterPanel2 extends JPanel{ + public CenterPanel2() { + setLayout(null); + for (int i = 0; i < 20; i++) { + int x = (int)(Math.random()*250); + int y = (int)(Math.random()*250); + JLabel label=new JLabel("*"); + label.setForeground(Color.GREEN); + label.setLocation(x,y); + label.setSize(20, 20); + label.setOpaque(true); + add(label); + } + } +} +class SouthPanel2 extends JPanel{ + public SouthPanel2() { + setBackground(Color.YELLOW); + add(new JButton("Word Input")); + add(new TextField(15)); + } +} + +public class Lab08Ex08 extends JFrame{ + Lab08Ex08(){ + setTitle("여러 개의 패널을 가진 프레임"); + setSize(300, 300); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + NorthPanel2 nP=new NorthPanel2(); + CenterPanel2 nC=new CenterPanel2(); + SouthPanel2 nS=new SouthPanel2(); + add(nP, BorderLayout.NORTH); + add(nS, BorderLayout.SOUTH); + add(nC); + setVisible(true); + } + + public static void main(String[] args) { + new Lab08Ex08(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/MyFrame.java b/PROJECT221019/src/MyFrame.java new file mode 100644 index 0000000..123f1c3 --- /dev/null +++ b/PROJECT221019/src/MyFrame.java @@ -0,0 +1,11 @@ +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(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/NullContainerEx.java b/PROJECT221019/src/NullContainerEx.java new file mode 100644 index 0000000..0ce730b --- /dev/null +++ b/PROJECT221019/src/NullContainerEx.java @@ -0,0 +1,25 @@ +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(); + } +} \ No newline at end of file diff --git a/PROJECT221019/src/OpenChallenge.java b/PROJECT221019/src/OpenChallenge.java new file mode 100644 index 0000000..59c8052 --- /dev/null +++ b/PROJECT221019/src/OpenChallenge.java @@ -0,0 +1,51 @@ +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Container; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +public class OpenChallenge extends JFrame{ + OpenChallenge() { + setTitle("Open Challenge 9"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Container c = getContentPane(); + c.setLayout(new BorderLayout()); + c.add(new NorthPanel(),BorderLayout.NORTH); + c.add(new CenterPanel(),BorderLayout.CENTER); + setSize(300,300); + setVisible(true); + + } + public static void main(String[] args) { + new OpenChallenge(); + } + +} +class NorthPanel extends JPanel{ + NorthPanel(){ + setBackground(Color.LIGHT_GRAY); + this.add(new JButton("Open")); + this.add(new JButton("Read")); + this.add(new JButton("Close")); + } +} +class CenterPanel extends JPanel{ + CenterPanel(){ + this.setLayout(null); + String text[] = {"Hello", "Java", "Love"}; + int x; + int y; + JLabel label; + for(int i=0;i<3;i++) { + x = (int)(Math.random()*250); + y = (int)(Math.random()*250); + label = new JLabel(text[i]); + label.setLocation(x, y); + label.setSize(50,10); + this.add(label); + } + } +} \ No newline at end of file diff --git a/open_calender/.idea/.gitignore b/open_calender/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/open_calender/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/open_calender/.idea/misc.xml b/open_calender/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/open_calender/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/open_calender/.idea/modules.xml b/open_calender/.idea/modules.xml new file mode 100644 index 0000000..1a6e9ab --- /dev/null +++ b/open_calender/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/open_calender/.idea/uiDesigner.xml b/open_calender/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/open_calender/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/open_calender/.idea/vcs.xml b/open_calender/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/open_calender/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/open_calender/open_calender.iml b/open_calender/open_calender.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/open_calender/open_calender.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/open_calender/src/Login/Login.java b/open_calender/src/Login/Login.java new file mode 100644 index 0000000..6b7bf7e --- /dev/null +++ b/open_calender/src/Login/Login.java @@ -0,0 +1,131 @@ +package Login; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +public class Login extends JFrame { + + private JPanel contentPane; + private JTextField txtId; + private JTextField txtPw; + + private String sID = ""; + private String sPW = ""; + + public Login() { + + setTitle("Login System Test"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 522, 164); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + + JLabel lblId = new JLabel("ID"); + lblId.setHorizontalAlignment(SwingConstants.CENTER); + lblId.setBounds(40, 30, 47, 15); + contentPane.add(lblId); + + txtId = new JTextField(); + txtId.setText(""); + // sID = txtId.getText(); + txtId.setBounds(99, 27, 167, 21); + contentPane.add(txtId); + txtId.setColumns(10); + + JLabel lblPw = new JLabel("PW"); + lblPw.setHorizontalAlignment(SwingConstants.CENTER); + lblPw.setBounds(40, 55, 47, 15); + contentPane.add(lblPw); + + txtPw = new JTextField(); + txtPw.setText(""); + // sPW = txtId.getText(); + txtPw.setBounds(99, 52, 167, 21); + contentPane.add(txtPw); + txtPw.setColumns(10); + + JButton btnNewButton_Login = new JButton("로그인"); +// btnNewButton_Login.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// // 로그인 했을 때 작업 +// boolean bLoginChk = false; +// GetIdandPw(txtId, txtPw); // 입력된 값 각각 넘겨 주기 +// LogIn_Chk loginchk = new LogIn_Chk(); +// bLoginChk = loginchk.LogInList_Chk(sID, sPW); // false면 로그인 실패 +// +// if (!bLoginChk) { // 로그인 실패s +// JOptionPane.showMessageDialog(null, "아이디 또는 비밀번호를 확인 후\n다시 로그인해주세요."); +// } else { // 로그인 성공 +// LoginMain.login.setVisible(false); // 기존의 로그인 화면 꺼주기 +// } +// // 이곳에 새로운 화면 구현 +// } +// }); + btnNewButton_Login.setBounds(274, 27, 102, 46); + contentPane.add(btnNewButton_Login); + + JButton btnNewButton_Sign = new JButton("회원 가입"); +// btnNewButton_Sign.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// // // 회원가입 했을 때 작업 +// // LoginMain.login.setVisible(false); // 기존의 로그인 화면 꺼주기 +// +// LoginMain.join.setVisible(true); // 회원 가입 화면 켜주기 +// } +// }); + btnNewButton_Sign.setBounds(274, 80, 102, 30); + contentPane.add(btnNewButton_Sign); + + JButton button_FindID = new JButton("ID 찾기"); +// button_FindID.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// // ID찾기 했을 때 작업 +// // LoginMain.login.setVisible(false); // 로그인 화면 off +// LoginMain.findId.setVisible(true); +// } +// }); + button_FindID.setBounds(40, 80, 109, 30); + contentPane.add(button_FindID); + +// JButton button_Findepw = new JButton("PW찾기"); +// button_Findepw.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// // PW찾기 했을 때 작업 +// // LoginMain.login.setVisible(false); // 로그인 화면 off +// LoginMain.findpw.setVisible(true); +// } +// }); +// button_Findepw.setBounds(152, 80, 118, 30); +// contentPane.add(button_Findepw); +// +// JButton button = new JButton("게스트 입장"); +// button.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// LoginMain.login.setVisible(false); // 기존의 로그인 화면 꺼주기 +// } +// }); +// button.setBounds(388, 26, 102, 84); +// contentPane.add(button); + + } + + private void GetIdandPw(JTextField txtId, JTextField txtPw) { + // TODO Auto-generated method stub + sID = txtId.getText(); + sPW = txtPw.getText(); + } +} + diff --git a/open_calender/src/Login/Login_edit.java b/open_calender/src/Login/Login_edit.java new file mode 100644 index 0000000..e0ee0f9 --- /dev/null +++ b/open_calender/src/Login/Login_edit.java @@ -0,0 +1,71 @@ +package Login; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; + +public class Login_edit extends JFrame { + + private JPanel contentPane; + private JTextField txtId; + private JTextField txtPw; + + private String sID = ""; + private String sPW = ""; + + public Login_edit() { + + setTitle("Login System Test"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 522, 164); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + + JLabel lblId = new JLabel("ID"); + lblId.setHorizontalAlignment(SwingConstants.CENTER); + lblId.setBounds(40, 30, 47, 15); + contentPane.add(lblId); + + txtId = new JTextField(); + txtId.setText(""); + // sID = txtId.getText(); + txtId.setBounds(99, 27, 167, 21); + contentPane.add(txtId); + txtId.setColumns(10); + + JLabel lblPw = new JLabel("PW"); + lblPw.setHorizontalAlignment(SwingConstants.CENTER); + lblPw.setBounds(40, 55, 47, 15); + contentPane.add(lblPw); + + txtPw = new JTextField(); + txtPw.setText(""); + // sPW = txtId.getText(); + txtPw.setBounds(99, 52, 167, 21); + contentPane.add(txtPw); + txtPw.setColumns(10); + + JButton btnNewButton_Login = new JButton("로그인"); + + btnNewButton_Login.setBounds(274, 27, 102, 46); + contentPane.add(btnNewButton_Login); + + JButton btnNewButton_Sign = new JButton("회원 가입"); + + btnNewButton_Sign.setBounds(274, 80, 102, 30); + contentPane.add(btnNewButton_Sign); + + JButton button_FindID = new JButton("ID 찾기"); + + button_FindID.setBounds(40, 80, 109, 30); + contentPane.add(button_FindID); + } + + private void GetIdandPw(JTextField txtId, JTextField txtPw) { + // TODO Auto-generated method stub + sID = txtId.getText(); + sPW = txtPw.getText(); + } +} + diff --git a/simple-calender/.idea/.gitignore b/simple-calender/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/simple-calender/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/simple-calender/.idea/misc.xml b/simple-calender/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/simple-calender/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/simple-calender/.idea/modules.xml b/simple-calender/.idea/modules.xml new file mode 100644 index 0000000..75cb431 --- /dev/null +++ b/simple-calender/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/simple-calender/.idea/vcs.xml b/simple-calender/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/simple-calender/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/simple-calender/images/program_icon.png b/simple-calender/images/program_icon.png new file mode 100644 index 0000000..0cdd1a8 Binary files /dev/null and b/simple-calender/images/program_icon.png differ diff --git a/simple-calender/lib/mysql-connector-java-8.0.29.jar b/simple-calender/lib/mysql-connector-java-8.0.29.jar new file mode 100644 index 0000000..5f9f134 Binary files /dev/null and b/simple-calender/lib/mysql-connector-java-8.0.29.jar differ diff --git a/simple-calender/out/production/simple-calender/JPanel01$MyActionListener.class b/simple-calender/out/production/simple-calender/JPanel01$MyActionListener.class new file mode 100644 index 0000000..45e5395 Binary files /dev/null and b/simple-calender/out/production/simple-calender/JPanel01$MyActionListener.class differ diff --git a/simple-calender/out/production/simple-calender/JPanel01.class b/simple-calender/out/production/simple-calender/JPanel01.class new file mode 100644 index 0000000..34d77a2 Binary files /dev/null and b/simple-calender/out/production/simple-calender/JPanel01.class differ diff --git a/simple-calender/out/production/simple-calender/JPanel02$MyActionListener.class b/simple-calender/out/production/simple-calender/JPanel02$MyActionListener.class new file mode 100644 index 0000000..5fa491d Binary files /dev/null and b/simple-calender/out/production/simple-calender/JPanel02$MyActionListener.class differ diff --git a/simple-calender/out/production/simple-calender/JPanel02.class b/simple-calender/out/production/simple-calender/JPanel02.class new file mode 100644 index 0000000..d2343ed Binary files /dev/null and b/simple-calender/out/production/simple-calender/JPanel02.class differ diff --git a/simple-calender/out/production/simple-calender/JPanelTest.class b/simple-calender/out/production/simple-calender/JPanelTest.class new file mode 100644 index 0000000..923c02e Binary files /dev/null and b/simple-calender/out/production/simple-calender/JPanelTest.class differ diff --git a/simple-calender/out/production/simple-calender/SimpleCalendar$1.class b/simple-calender/out/production/simple-calender/SimpleCalendar$1.class new file mode 100644 index 0000000..96cd661 Binary files /dev/null and b/simple-calender/out/production/simple-calender/SimpleCalendar$1.class differ diff --git a/simple-calender/out/production/simple-calender/SimpleCalendar$2.class b/simple-calender/out/production/simple-calender/SimpleCalendar$2.class new file mode 100644 index 0000000..b52167f Binary files /dev/null and b/simple-calender/out/production/simple-calender/SimpleCalendar$2.class differ diff --git a/simple-calender/out/production/simple-calender/SimpleCalendar$3.class b/simple-calender/out/production/simple-calender/SimpleCalendar$3.class new file mode 100644 index 0000000..e8ef460 Binary files /dev/null and b/simple-calender/out/production/simple-calender/SimpleCalendar$3.class differ diff --git a/simple-calender/out/production/simple-calender/SimpleCalendar$MyActionListener.class b/simple-calender/out/production/simple-calender/SimpleCalendar$MyActionListener.class new file mode 100644 index 0000000..ffb98e5 Binary files /dev/null and b/simple-calender/out/production/simple-calender/SimpleCalendar$MyActionListener.class differ diff --git a/simple-calender/out/production/simple-calender/SimpleCalendar.class b/simple-calender/out/production/simple-calender/SimpleCalendar.class new file mode 100644 index 0000000..990e42a Binary files /dev/null and b/simple-calender/out/production/simple-calender/SimpleCalendar.class differ diff --git a/simple-calender/simple-calender.iml b/simple-calender/simple-calender.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/simple-calender/simple-calender.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/simple-calender/src/Login.java b/simple-calender/src/Login.java new file mode 100644 index 0000000..710bda0 --- /dev/null +++ b/simple-calender/src/Login.java @@ -0,0 +1,113 @@ +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; + +class JPanel01 extends JPanel { // 1번째 패널 + + private JButton jButton1; + private JScrollPane jScrollPane1; + private JTextArea jTextArea1; + private JPanelTest win; + + public JPanel01(JPanelTest win) { + this.win = win; + setLayout(null); + + jButton1 = new JButton("버튼"); + jButton1.setSize(70, 20); + jButton1.setLocation(10, 10); + add(jButton1); + + jTextArea1 = new JTextArea(); + + jScrollPane1 = new JScrollPane(jTextArea1); + jScrollPane1.setSize(200, 150); + jScrollPane1.setLocation(10, 40); + add(jScrollPane1); + + jButton1.addActionListener(new MyActionListener()); + } + + class MyActionListener implements ActionListener { // 버튼 키 눌리면 패널 2번 호출 + + @Override + public void actionPerformed(ActionEvent e) { + win.change("panel02"); + } + } +} + +class JPanel02 extends JPanel { // 2번째 패널 + + private JTextField textField; + private JPasswordField passwordField; + private JPanelTest win; + + public JPanel02(JPanelTest win) { + setLayout(null); + this.win = win; + JLabel lblLbl = new JLabel("아이디:"); + lblLbl.setBounds(31, 40, 67, 15); + add(lblLbl); + + textField = new JTextField(); + textField.setBounds(123, 40, 116, 21); + add(textField); + textField.setColumns(10); + + JLabel lblLbl_1 = new JLabel("암호:"); + lblLbl_1.setBounds(31, 84, 67, 15); + add(lblLbl_1); + + passwordField = new JPasswordField(); + passwordField.setBounds(123, 84, 116, 21); + add(passwordField); + + JButton btn = new JButton("버튼"); + btn.setSize(70, 20); + btn.setLocation(10, 10); + add(btn); + btn.addActionListener(new MyActionListener()); + } + + class MyActionListener implements ActionListener { // 버튼 키 눌리면 패널 1번 호출 + + @Override + public void actionPerformed(ActionEvent e) { + win.change("panel01"); + } + } +} + +class JPanelTest extends JFrame { + + public JPanel01 jpanel01 = null; + public JPanel02 jpanel02 = null; + + public void change(String panelName) { // 패널 1번과 2번 변경 후 재설정 + if (panelName.equals("panel01")) { + getContentPane().removeAll(); + getContentPane().add(jpanel01); + revalidate(); + repaint(); + } else { + getContentPane().removeAll(); + getContentPane().add(jpanel02); + revalidate(); + repaint(); + } + } + + public static void main(String[] args) { + JPanelTest win = new JPanelTest(); + + win.setTitle("frame test"); + win.jpanel01 = new JPanel01(win); + win.jpanel02 = new JPanel02(win); + + win.add(win.jpanel01); + win.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + win.setSize(500, 700); + win.setVisible(true); + } +} diff --git a/simple-calender/src/SimpleCalendar.java b/simple-calender/src/SimpleCalendar.java new file mode 100644 index 0000000..1d0265c --- /dev/null +++ b/simple-calender/src/SimpleCalendar.java @@ -0,0 +1,418 @@ +import java.awt.Color; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingConstants; + +public class SimpleCalendar extends JFrame { + + JFrame jf_scheduleEvent; + + JPanel main_panel, days_panel, scheduleEvent_panel; + JMenuBar menuBar; + JMenu mn_function, mn_exit; + JMenuItem mni_bookmark; + + JLabel lb_dateTitle; + JLabel lb_week[] = new JLabel[7]; + JButton bt_prevMonth, bt_today, bt_nextMonth; + JButton bt_days[] = new JButton[42]; + + JTextField tf_scheduleTitle, tf_scheduleContent; + + String str_week[] = { "일", "월", "화", "수", "목", "금", "토" }; + + int xPos = 0; + int year, month, week, day; + int dayCnt = 1, nextMonthDayCnt = 1; + int monthSet[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int currentYear, currentMonth; + + public SimpleCalendar() { + setTitle("Simple Calendar"); + setSize(1000, 600); + setLocationRelativeTo(null); + setResizable(false); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + //---------------- 일정 등록 관련 JFrame --------------- + jf_scheduleEvent = new JFrame(); + jf_scheduleEvent.setSize(500, 300); + jf_scheduleEvent.setLocationRelativeTo(null); + jf_scheduleEvent.setTitle("일정 등록"); + + scheduleEvent_panel = new JPanel(null); + + tf_scheduleTitle = new JTextField(); + tf_scheduleTitle.setBounds(10, 10, 200, 100); + + tf_scheduleContent = new JTextField(); + tf_scheduleContent.setBounds(10, 130, 200, 100); + + scheduleEvent_panel.add(tf_scheduleTitle); + scheduleEvent_panel.add(tf_scheduleContent); + + jf_scheduleEvent.add(scheduleEvent_panel); + + //----------------------------------------------- + + main_panel = new JPanel(null); + main_panel.setBackground(Color.WHITE); + days_panel = new JPanel(new GridLayout(0, 7)); + days_panel.setBounds(0, 70, 1000, 480); + + menuBar = new JMenuBar(); + + mn_function = new JMenu("기능"); + mn_exit = new JMenu("종료"); + mn_exit.addMouseListener( + new MouseAdapter() { + public void mousePressed(MouseEvent e) { + // 종료 메뉴 클릭시 프로그램 종료 + System.exit(1); + } + } + ); + mni_bookmark = new JMenuItem("북마크 추가"); + + Calendar calendar = Calendar.getInstance(); + SimpleDateFormat formatterYear = new SimpleDateFormat("yyyy"); + SimpleDateFormat formatterMonth = new SimpleDateFormat("MM"); + currentYear = Integer.parseInt(formatterYear.format(calendar.getTime())); + currentMonth = Integer.parseInt(formatterMonth.format(calendar.getTime())); + lb_dateTitle = new JLabel(currentYear + "년 " + currentMonth + "월"); + lb_dateTitle.setFont(new Font("arial", Font.BOLD, 27)); + lb_dateTitle.setBounds(10, 10, 200, 30); + + for (int k = 0; k < 7; k++) { + lb_week[k] = new JLabel(str_week[k]); + lb_week[k].setBounds(125 * (k + 1) + xPos, 10, 100, 100); + xPos += 16.5; + main_panel.add(lb_week[k]); + } + + // + year = currentYear; + month = currentMonth; + + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) monthSet[1] = + 29; else monthSet[1] = 28; // 윤년의 조건. + day = + (year - 1) * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400; + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + week = day % 7 + 1; + + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + for (int k = 0; k < 42; k++) { + if (k == 0) { + for (int z = 0; z < week; z++) { + if (week == 7) break; + bt_days[k] = new JButton(); + if (month - 2 < 0) bt_days[k].setText( + "" + (monthSet[11] - week + k + 1) + "일" + ); else bt_days[k].setText( + "" + (monthSet[month - 2] - week + k + 1) + "일" + ); + bt_days[k].setFont(new Font("arial", Font.PLAIN, 15)); + bt_days[k].setHorizontalAlignment(SwingConstants.RIGHT); + bt_days[k].setVerticalAlignment(SwingConstants.TOP); + bt_days[k].setEnabled(false); + bt_days[k].addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + // String toDos = JOptionPane.showInputDialog( + // null, + // "메모할 내용을 입력해 주세요", + // "할 일 추가", + // JOptionPane.INFORMATION_MESSAGE + // ); + // if (!toDos.equals("")) + } + } + ); + days_panel.add(bt_days[k++]); + } + } + if (dayCnt == 1) bt_days[k] = + new JButton(month + "월 " + dayCnt + "일"); else bt_days[k] = + new JButton(dayCnt + "일"); + bt_days[k].setFont(new Font("arial", Font.PLAIN, 15)); + bt_days[k].setHorizontalAlignment(SwingConstants.RIGHT); + bt_days[k].setVerticalAlignment(SwingConstants.TOP); + if (dayCnt > monthSet[month - 1]) { + if (nextMonthDayCnt == 1) if (month + 1 == 13) bt_days[k].setText( + "1월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText( + month + 1 + "월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText(nextMonthDayCnt + "일"); + bt_days[k].setEnabled(false); + nextMonthDayCnt++; + } + bt_days[k].addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + // String toDos = JOptionPane.showInputDialog( + // null, + // "메모할 내용을 입력해 주세요", + // "할 일 추가", + // JOptionPane.INFORMATION_MESSAGE + // ); + // System.out.println(toDos); + jf_scheduleEvent.setVisible(true); + } + } + ); + days_panel.add(bt_days[k]); + dayCnt++; + week++; + } + // + + bt_prevMonth = new JButton("<"); + bt_prevMonth.setBounds(830, 10, 33, 33); + bt_prevMonth.addActionListener(new MyActionListener()); + + bt_today = new JButton("오늘"); + bt_today.setBounds(860, 10, 100, 33); + bt_today.addActionListener(new MyActionListener()); + + bt_nextMonth = new JButton(">"); + bt_nextMonth.setBounds(957, 10, 33, 33); + bt_nextMonth.addActionListener(new MyActionListener()); + + mn_function.add(mni_bookmark); + + menuBar.add(mn_function); + menuBar.add(mn_exit); + + main_panel.add(lb_dateTitle); + main_panel.add(bt_prevMonth); + main_panel.add(bt_today); + main_panel.add(bt_nextMonth); + + main_panel.add(days_panel); + add(main_panel); + + setJMenuBar(menuBar); + setVisible(true); + } + + class MyActionListener implements ActionListener { + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == bt_prevMonth) { + month--; + if (month == 0) { + year--; + month = 12; + } + lb_dateTitle.setText((year + "년 " + month + "월")); + + dayCnt = 1; + nextMonthDayCnt = 1; + + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) monthSet[1] = + 29; else monthSet[1] = 28; // 윤년의 조건. + day = + (year - 1) * + 365 + + (year - 1) / + 4 - + (year - 1) / + 100 + + (year - 1) / + 400; + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + week = day % 7 + 1; + + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + for (int k = 0; k < 42; k++) { + if (k == 0) { + for (int z = 0; z < week; z++) { + if (week == 7) break; + if (month - 2 < 0) bt_days[k].setText( + "" + (monthSet[11] - week + k + 1) + "일" + ); else bt_days[k].setText( + "" + (monthSet[month - 2] - week + k + 1) + "일" + ); + bt_days[k].setEnabled(false); + k++; + } + } + if (dayCnt == 1) bt_days[k].setText( + month + "월 " + dayCnt + "일" + ); else bt_days[k].setText(dayCnt + "일"); + bt_days[k].setEnabled(true); + if (dayCnt > monthSet[month - 1]) { + if (nextMonthDayCnt == 1) if (month + 1 == 13) bt_days[k].setText( + "1월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText( + month + 1 + "월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText(nextMonthDayCnt + "일"); + bt_days[k].setEnabled(false); + nextMonthDayCnt++; + } + dayCnt++; + week++; + } + } else if (e.getSource() == bt_today) { + Calendar calendar = Calendar.getInstance(); + SimpleDateFormat formatterYear = new SimpleDateFormat("yyyy"); + SimpleDateFormat formatterMonth = new SimpleDateFormat("MM"); + currentYear = + Integer.parseInt(formatterYear.format(calendar.getTime())); + currentMonth = + Integer.parseInt(formatterMonth.format(calendar.getTime())); + lb_dateTitle.setText((currentYear + "년 " + currentMonth + "월")); + + year = currentYear; + month = currentMonth; + dayCnt = 1; + nextMonthDayCnt = 1; + + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) monthSet[1] = + 29; else monthSet[1] = 28; // 윤년의 조건. + day = + (year - 1) * + 365 + + (year - 1) / + 4 - + (year - 1) / + 100 + + (year - 1) / + 400; + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + week = day % 7 + 1; + + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + for (int k = 0; k < 42; k++) { + if (k == 0) { + for (int z = 0; z < week; z++) { + if (week == 7) break; + if (month - 2 < 0) bt_days[k].setText( + "" + (monthSet[11] - week + k + 1) + "일" + ); else bt_days[k].setText( + "" + (monthSet[month - 2] - week + k + 1) + "일" + ); + bt_days[k].setEnabled(false); + k++; + } + } + if (dayCnt == 1) bt_days[k].setText( + month + "월 " + dayCnt + "일" + ); else bt_days[k].setText(dayCnt + "일"); + bt_days[k].setEnabled(true); + if (dayCnt > monthSet[month - 1]) { + if (nextMonthDayCnt == 1) if (month + 1 == 13) bt_days[k].setText( + "1월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText( + month + 1 + "월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText(nextMonthDayCnt + "일"); + bt_days[k].setEnabled(false); + nextMonthDayCnt++; + } + dayCnt++; + week++; + } + } else if (e.getSource() == bt_nextMonth) { + month++; + if (month == 13) { + year++; + month = 1; + } + lb_dateTitle.setText((year + "년 " + month + "월")); + + dayCnt = 1; + nextMonthDayCnt = 1; + + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) monthSet[1] = + 29; else monthSet[1] = 28; // 윤년의 조건. + day = + (year - 1) * + 365 + + (year - 1) / + 4 - + (year - 1) / + 100 + + (year - 1) / + 400; + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + week = day % 7 + 1; + + for (int k = 0; k < month - 1; k++) { + day += monthSet[k]; + } + + for (int k = 0; k < 42; k++) { + if (k == 0) { + for (int z = 0; z < week; z++) { + if (week == 7) break; + if (month - 2 < 0) bt_days[k].setText( + "" + (monthSet[11] - week + k + 1) + "일" + ); else bt_days[k].setText( + "" + (monthSet[month - 2] - week + k + 1) + "일" + ); + bt_days[k].setEnabled(false); + k++; + } + } + if (dayCnt == 1) bt_days[k].setText( + month + "월 " + dayCnt + "일" + ); else bt_days[k].setText(dayCnt + "일"); + bt_days[k].setEnabled(true); + if (dayCnt > monthSet[month - 1]) { // 정해진 날짜를 벗어날 때의 조건 + if (nextMonthDayCnt == 1) if (month + 1 == 13) bt_days[k].setText( + "1월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText( + month + 1 + "월 " + nextMonthDayCnt + "일" + ); else bt_days[k].setText(nextMonthDayCnt + "일"); + bt_days[k].setEnabled(false); + nextMonthDayCnt++; + } + dayCnt++; + week++; + } + } + main_panel.revalidate(); + main_panel.repaint(); + } + } + + public static void main(String[] args) { + new SimpleCalendar(); + } +}