프로젝트 진행 05

1. 프로그램 실행
처음 프로그램을 실행하면 위와 같이 실행된다.

2. 입고등록 작성 및 저장
입고등록할 내용을 각 항목별로 적어놓고 저장 버튼으로 저장

3. 입고등록 저장된 내용 확인
각 항목별로 넣은 내용들이 잘 저장되어 있음을 알수있다.

4. 출고등록 작성 및 저장
입고등록과 마찬가지로 각 항목에 맞게 작성하여 저장 버튼으로 저장

5. 출고등록 저장된 내용 확인
입고등록과 마찬가지로 각 항목별로 넣은 내용들이 잘 저장되어 있음을 알 수 있다.

6. 정산메뉴

총 입고액에서 총 출고액을 빼서 총 마진을 보여준다.

7.재고현황 메뉴
입고등록된 입고품목과 출고등록된 출고품목을 한눈에 볼 수 있다.

by 무한보더 | 2008/12/02 03:32 | 시스템프로젝트 | 트랙백 | 덧글(1)

프로젝트 진행 04

import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;

public class Project implements ActionListener{  //프로그램 구현
 private CardLayout cardLayout;  //레이아웃은 CardLayout 으로 구성
 private JPanel cardPane;  //CardLayout을 위한 패널
 private int type = 1;  //메인메뉴를 구분하기 위한 구분자
 private String url = "jdbc:mysql://localhost:3306/kys";  //DB 로그인을 위한 경로 설정
 private String user = "root";  //DB 접속 사용자
    private String pwd = "dytc1234";  //DB 접속 패스워드
    private String MySQLDriver = "com.mysql.jdbc.Driver";  //DB 접속 드라이버 로드
 private Connection conn;  //Connection 객체
 private Statement stmt;  //Statement 객체
 private ResultSet rs;  //ResultSet 객체
 private JLabel l[];  //JLabel 배열 객체
 private JTextField tf[];  //JTextField 배열 객체


 public void setType(int type){  //메인 메뉴의 구분을 위해 구분자를 주는 메소드
  this.type = type;
 }
 public int getType(){  //구분자를 불러오기 위한 메소드
  return type;
 }

 public Project(){  //메인 클래스
  JFrame f = new JFrame("재고관리");
  f.setSize(500,350);

  l = new JLabel[30];  //메뉴 구성을 알리기 위해 JLabel 객체 생성
  tf = new JTextField[15];  //입력을 받기 위한 JTextField 객체 생성

  Container contentPane = f.getContentPane();  //Swing 컴포넌트의 추가를 위한 컨테이너 객체 생성

  cardPane = new JPanel();  //CardLayout을 위한 패널 객체 생성
  JPanel p1 = new JPanel();  //cardPane 에 들어갈 각 패널들 생성
  JPanel p2 = new JPanel();
  JPanel p3 = new JPanel();
  JPanel p4 = new JPanel();

  p1.setLayout(new GridLayout(7,1));  //입고등록 패널
  l[0] = new JLabel("입 고 메 뉴");
  l[1] = new JLabel("입고 수량");
  l[2] = new JLabel("입고 일자");
  l[3] = new JLabel("입고 품목");
  l[4] = new JLabel("입고 가격");
  l[5] = new JLabel("입고 메모");
  tf[0] = new JTextField(15);
  tf[1] = new JTextField(15);
  tf[2] = new JTextField(15);
  tf[3] = new JTextField(15);
  tf[4] = new JTextField(15);
  l[6] = new JLabel("개                   ");
  l[7] = new JLabel("(예:2008-11-30)");
  l[8] = new JLabel("                       ");
  l[9] = new JLabel("원                    ");
  l[10] = new JLabel("                      ");
  JButton Inb1 = new JButton("입 고 저 장");  //입고 내용 저장을 위한 JButton 객체 생성
  Inb1.addActionListener(this);  //저장이 되도록 이벤트 처리
  JButton Inb2 = new JButton("입 고 취 소");  //다시 작성하는 JButton 객체 생성
  Inb2.addActionListener(this);  //작성값을 초기화 시키는 이벤트 처리
  JPanel Inone = new JPanel();  //JLabel 과 JTextField 와 JButton 를 넣기 위한 패널 생성
  JPanel Intwo = new JPanel();
  JPanel Inthr = new JPanel();
  JPanel Infou = new JPanel();
  JPanel Infiv = new JPanel();
  JPanel Insix = new JPanel();
  JPanel Insev = new JPanel();
  Inone.add(l[0]);  //각 패널에 JLabel 과 JTextField 와 JButton 컴포넌트 추가
  Intwo.add(l[1]);
  Intwo.add(tf[0]);
  Intwo.add(l[6]);
  Inthr.add(l[2]);
  Inthr.add(tf[1]);
  Inthr.add(l[7]);
  Infou.add(l[3]);
  Infou.add(tf[2]);
  Infou.add(l[8]);
  Infiv.add(l[4]);
  Infiv.add(tf[3]);
  Infiv.add(l[9]);
  Insix.add(l[5]);
  Insix.add(tf[4]);
  Insix.add(l[10]);
  Insev.add(Inb1);
  Insev.add(Inb2);
  p1.add(Inone);
  p1.add(Intwo);
  p1.add(Inthr);
  p1.add(Infou);
  p1.add(Infiv);
  p1.add(Insix);
  p1.add(Insev,"South");

  p2.setLayout(new GridLayout(7,1));  //출고 등록 패널
  l[11] = new JLabel("출 고 메 뉴");
  l[12] = new JLabel("출고 수량");
  l[13] = new JLabel("출고 일자");
  l[14] = new JLabel("출고 품목");
  l[15] = new JLabel("출고 가격");
  l[16] = new JLabel("출고 메모");
  tf[5] = new JTextField(15);
  tf[6] = new JTextField(15);
  tf[7] = new JTextField(15);
  tf[8] = new JTextField(15);
  tf[9] = new JTextField(15);
  l[17] = new JLabel("개                   ");
  l[18] = new JLabel("(예:2008-11-30)");
  l[19] = new JLabel("                       ");
  l[20] = new JLabel("원                    ");
  l[21] = new JLabel("                      ");
  JButton Outb1 = new JButton("출 고 저 장");  //출고 내용 저장을 위한 JButton 객체 생성
  Outb1.addActionListener(this);  //저장이 되도록 이벤트 처리
  JButton Outb2 = new JButton("출 고 취 소");  //다시 작성하는 JButton 객체 생성
  Outb2.addActionListener(this);  //작성값을 초기화 시키는 이벤트 처리
  JPanel Outone = new JPanel();  //JLabel 과 JTextField 와 JButton 를 넣기 위한 패널 생성
  JPanel Outtwo = new JPanel();
  JPanel Outthr = new JPanel();
  JPanel Outfou = new JPanel();
  JPanel Outfiv = new JPanel();
  JPanel Outsix = new JPanel();
  JPanel Outsev = new JPanel();
  Outone.add(l[11]);  //각 패널에 JLabel 과 JTextField 와 JButton 컴포넌트 추가
  Outtwo.add(l[12]);
  Outtwo.add(tf[5]);
  Outtwo.add(l[17]);
  Outthr.add(l[13]);
  Outthr.add(tf[6]);
  Outthr.add(l[18]);
  Outfou.add(l[14]);
  Outfou.add(tf[7]);
  Outfou.add(l[19]);
  Outfiv.add(l[15]);
  Outfiv.add(tf[8]);
  Outfiv.add(l[20]);
  Outsix.add(l[16]);
  Outsix.add(tf[9]);
  Outsix.add(l[21]);
  Outsev.add(Outb1);
  Outsev.add(Outb2);
  p2.add(Outone);
  p2.add(Outtwo);
  p2.add(Outthr);
  p2.add(Outfou);
  p2.add(Outfiv);
  p2.add(Outsix);
  p2.add(Outsev,"South");

  p3.setLayout(new GridLayout(4,1));  //마진 조회를 위한 패널
  l[22] = new JLabel("마 진 정 산");
  l[23] = new JLabel("입 고 총 액");
  l[24] = new JLabel("출 고 총 액");
  l[25] = new JLabel("마진(입고액-출고액)");
  tf[10] = new JTextField(15);
  tf[11] = new JTextField(15);
  tf[12] = new JTextField(15);
  l[26] = new JLabel("원                    ");
  l[27] = new JLabel("원                    ");
  l[28] = new JLabel("원                    ");
  JPanel Dealone = new JPanel();  //JLabel 과 JTextField 를 넣기 위한 패널 생성
  JPanel Dealtwo = new JPanel();
  JPanel Dealthr = new JPanel();
  JPanel Dealfou = new JPanel();
  Dealone.add(l[22]);  //각 패널에 JLabel 과 JTextField 컴포넌트 추가
  Dealtwo.add(l[23]);
  Dealtwo.add(tf[10]);
  Dealtwo.add(l[26]);
  Dealthr.add(l[24]);
  Dealthr.add(tf[11]);
  Dealthr.add(l[27]);
  Dealfou.add(l[25]);
  Dealfou.add(tf[12]);
  Dealfou.add(l[28]);
  p3.add(Dealone);
  p3.add(Dealtwo);
  p3.add(Dealthr);
  p3.add(Dealfou);

  p4.setLayout(new GridLayout(3,1));  //재고현황 조회를 위한 패널
  l[29] = new JLabel("재 고 현 황");
  tf[13] = new JTextField(30);
  tf[14] = new JTextField(30);
  JPanel Totone = new JPanel();
  JPanel Tottwo = new JPanel();
  JPanel Totthr = new JPanel();
  Totone.add(l[29]);
  Tottwo.add(tf[13]);
  Totthr.add(tf[14]);
  p4.add(Totone);
  p4.add(Tottwo);
  p4.add(Totthr);

  cardLayout = new CardLayout();  //CardLayout 객체 생성
  cardPane.setLayout(cardLayout);  //CardLayout 으로 구성

  cardPane.add("입고",p1);
  cardPane.add("출고",p2);
  cardPane.add("정산",p3);
  cardPane.add("재고현황",p4);
  contentPane.add(cardPane,"Center");  //컨테이너에 추가

  JPanel buttonPane = new JPanel();  //왼쪽 메뉴 구성을 위한 패널 생성
  buttonPane.setLayout(new GridLayout(4,1));
  JButton b1 = new JButton("입 고");
  JButton b2 = new JButton("출 고");
  JButton b3 = new JButton("정 산");
  JButton b4 = new JButton("재 고 현 황");

  b1.addActionListener(this);  //각 메뉴 선택에 따른 이벤트 처리
  b2.addActionListener(this);
  b3.addActionListener(this);
  b4.addActionListener(this);

  buttonPane.add(b1);  //패널에 버튼 추가
  buttonPane.add(b2);
  buttonPane.add(b3);
  buttonPane.add(b4);

  contentPane.add(buttonPane,"West");  //컨테이너에 패널 추가

  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  //윈도우 종료

  f.setVisible(true);
 }

 public void actionPerformed(ActionEvent e){  //이벤트 처리 실행 메소드

  int pretype = type;  //왼쪽 메인 메뉴 선택에서 기존 선택에 따라 구분되어지도록 구분자 생성
  String cmd = e.getActionCommand();  //각 액션마다 어떤 액션인지 이벤트에 지정된 이벤트 처리값을 가져오는 메소드

  if(cmd.equals("입 고 저 장")){  //입고등록 메뉴에서 작성된 내용을 DB에 저장
   try {
    Class.forName(MySQLDriver);  //드라이버를 로드하여
    conn = DriverManager.getConnection(url,user,pwd);  //지정된 경로로 접속(Connection 객체 생성)

    stmt = conn.createStatement();  //DB에서 쿼리 수행을 위한 Statement 객체를 생성
    stmt.executeUpdate("insert into input(in_su,in_reg_date,in_item,in_price,in_msg) values('"+tf[0].getText()+"','"+tf[1].getText()+"','"+tf[2].getText()+"','"+tf[3].getText()+"','"+tf[4].getText()+"');");  //DB에 저장이 되도록 쿼리 실행

  stmt.close();  //연결을 종료
conn.close();
   }catch(Exception ae) {ae.printStackTrace();}
  } else if(cmd.equals("입 고 취 소")) {  //입고등록 메뉴에서 작성된 내용을 초기화
   tf[0].setText("");
   tf[1].setText("");
   tf[2].setText("");
   tf[3].setText("");
   tf[4].setText("");
  } else if(cmd.equals("출 고 저 장")) {  출고등록 메뉴에서 작성된 내용을 DB에 저장
   try {
    Class.forName(MySQLDriver);
    conn = DriverManager.getConnection(url,user,pwd);

    stmt = conn.createStatement();
    stmt.executeUpdate("insert into output(out_su,out_reg_date,out_item,out_price,out_msg) values('"+tf[5].getText()+"','"+tf[6].getText()+"','"+tf[7].getText()+"','"+tf[8].getText()+"','"+tf[9].getText()+"');");
    
    stmt.close();
    conn.close();
   }catch(Exception ae) {ae.printStackTrace();}
  } else if(cmd.equals("출 고 취 소")) {  //출고등록 메뉴에서 작성된 내용 초기화
   tf[5].setText("");
   tf[6].setText("");
   tf[7].setText("");
   tf[8].setText("");
   tf[9].setText("");
  }

  if(cmd.equals("입 고")){  //왼쪽 메인 메뉴의 각 선택에 따라 구분자를 줌
   this.setType(1);
  } else if(cmd.equals("출 고")) {
   this.setType(2);
  } else if(cmd.equals("정 산")) {
   this.setType(3);
   try {
    Class.forName(MySQLDriver);
    conn = DriverManager.getConnection(url,user,pwd);

    stmt = conn.createStatement();
    rs = stmt.executeQuery("select sum(in_price) as sum_in_price from input;");  //입고등록된 데이터의 총 입고금액을 조회
    while(rs.next()) {  //총 입고금액을 보여줌
     tf[10].setText(new String(rs.getString("sum_in_price")));
    }
    rs = stmt.executeQuery("select sum(out_price) as sum_out_price from output;");  //출고등록된 데이터의 총 출고금액을 조회
    while(rs.next()) {  //총 출고금액을 보여줌
     tf[11].setText(new String(rs.getString("sum_out_price")));
    }
    int insum = Integer.parseInt(tf[10].getText());
    int outsum = Integer.parseInt(tf[11].getText());

    int sum = insum - outsum;  //총 입고금액에서 총 출고금액을 빼는 마진 계산을 하여
    String Sum = Integer.toString(sum);  //마진 금액을 String 형으로 바꿔서

    tf[12].setText(Sum);  //마진을 보여준다.
    stmt.close();
    conn.close();
   }catch(Exception ae) {ae.printStackTrace();}
  } else if(cmd.equals("재 고 현 황")) {
   this.setType(4);
   try {
    Class.forName(MySQLDriver);
    conn = DriverManager.getConnection(url,user,pwd);

    stmt = conn.createStatement();
    rs = stmt.executeQuery("select in_item from input group by in_item;");  //입고등록된 품목을 보기 위한 쿼리 실행
    String i = "입고품목 : ";
    while(rs.next()) {
     String item = rs.getString("in_item");  //입고품목을 보여주고
     i = i + "," + item;
     tf[13].setText(i);
    }
    rs = stmt.executeQuery("select out_item from output group by out_item;");  //출고등록된 품목을 보기 위한 쿼리 실행
    String j = "출고품목 : ";
    while(rs.next()) {
     String item = rs.getString("out_item");  //출고품목을 보여주고
     j = j + "," + item;
     tf[14].setText(j);
    }
    stmt.close();
    conn.close();
   }catch(Exception ae) {ae.printStackTrace();}
  }

  if(this.getType()==1){  //다른 메뉴에서 넘어왔을때 전에 작성된 내용이 초기화 되도록 한후에 이전 메뉴가 어떤것인지 구분자로 구분하여 해당 메뉴에 맞는 패널을 보여주기 위한 이벤트 처리
   tf[0].setText("");
   tf[1].setText("");
   tf[2].setText("");
   tf[3].setText("");
   tf[4].setText("");
   if(pretype==2){
    cardLayout.previous(cardPane);
   }else if(pretype==3){
    cardLayout.previous(cardPane);
    cardLayout.previous(cardPane);
   }else if(pretype==4){
    cardLayout.next(cardPane);
   }
  } else if(this.getType()==2) {
   tf[5].setText("");
   tf[6].setText("");
   tf[7].setText("");
   tf[8].setText("");
   tf[9].setText("");
   if(pretype==1){
    cardLayout.next(cardPane);
   }else if(pretype==3){
    cardLayout.previous(cardPane);
   }else if(pretype==4){
    cardLayout.previous(cardPane);
    cardLayout.previous(cardPane);
   }
  } else if(this.getType()==3) {
   if(pretype==1){
    cardLayout.next(cardPane);
    cardLayout.next(cardPane);
   }else if(pretype==2){
    cardLayout.next(cardPane);
   }else if(pretype==4){
    cardLayout.previous(cardPane);
   }
  } else {
   if(pretype==1){
    cardLayout.previous(cardPane);
   }else if(pretype==2){
    cardLayout.next(cardPane);
    cardLayout.next(cardPane);
   }else if(pretype==3){
    cardLayout.next(cardPane);
   }
  }
 }

 public static void main(String args[]){
  Project obj = new Project();
 }
}

같은 조원의 취업으로 인한 프로젝트 미참여로 프로그램의 규모적인 면이나 기능적인 면이 많이 축소되었지만
아주 허접한ㅡ,.ㅡ;; 하나의 재고관리 프로그램 탄생~~

by 무한보더 | 2008/12/02 03:10 | 시스템프로젝트 | 트랙백 | 덧글(0)

프로젝트 진행 03

프로젝트 진행 상황
09/09 ~ 09/15  :  프로그램 선택
09/16 ~ 09/23  :  프로그램 구성 계획
09/24 ~ 09/30  :  프로그램 기능 계획 및 역활 분담
10/01 ~ 10/07  :  프로그램 인터페이스 구성
10/08 ~ 10/14  :  프로그램 메인 클래스 구성
10/15 ~ 10/21  :  프로그램 컴포넌트들 구성
10/22 ~ 10/28  :  프로그램 이벤트 처리 없는 인터페이스 완성
10/29 ~ 11/04  :  프로그램 이벤트 처리
11/05 ~ 11/11  :  프로그램 이벤트 처리
11/12 ~ 11/18  :  프로그램 인터페이스 완성
11/19 ~ 11/25  :  프로그램 DB 연동
11/26 ~ 12/02  :  프로그램 최종 수정 및 결과 제출

프로그램의 구성
기본적으로 한개의 프레임안에 왼편에 메인 메뉴(입고,출고,정산,재고현황) 버튼들이 있는 패널과
각 메뉴별로 등록 및 조회를 할 수 있는 각 메뉴별로 패널이 바뀌는 CardLayout 패널로 구성하여
각 메뉴의 기능에 맞게 인터페이스 되며
등록을 하면 등록한 내용이 DB에 저장되어 마진을 조회해 볼 수도 있도록 구성합니다.
컴포넌트들은 Swing 으로 구성합니다.
메인 메뉴에서 각 버튼을 눌렀을때마다 동작을 하게끔 이벤트 처리를 하며
저장 버튼을 눌렀을때도 DB에 각 입력값이 저장이 되도록 이벤트 처리를 합니다.
이에 정산 메뉴에서는 저장되어 있는 입고가격과 출고가격을 계산하여 마진을 보여주며
재고현황에서는 입고된 품목과 출고된 품목을 보여주도록 합니다.

by 무한보더 | 2008/12/02 02:02 | 시스템프로젝트 | 트랙백 | 덧글(0)

프로젝트 진행 02

프로젝트 프로그램

프로그램명
: 재고관리 프로그램

프로그램의 목적
: 재고를 DB 에 저장하여 입고와 출고 및 정산을 한다.

프로그램의 개요
: 메인메뉴(입고,출고,정산,재고현황)의 버튼을 왼편에 각각 배치하고 각 메뉴의 기능은 CardLayout 으로 중앙에 구성되었다.
컴포넌트는 JPanel, JLabel, JTextField, JButton 이 쓰였으며 각 버튼별로 액션이 일어나는 기능을 주었다.
입고 메뉴 - 입고수량과 입고일자, 입고품목, 입고가격, 메모 를 입력할 수 있도록 하였고 저장 버튼을 눌렀을때만 DB에 저장이 된다.
출고 메뉴 - 출고수량과 출고일자, 출고품목, 출고가격, 메모 를 입력할 수 있도록 하였고 저장 버튼을 눌렀을때만 DB에 저장이 된다.
정산 - 입고총액에서 출고총액을 뺀 마진 금액을 각 총액과 함께 보여준다.
재고현황 - 지금까지 저장된 입고품목과 출고품목을 보여준다.

by 무한보더 | 2008/12/01 23:40 | 시스템프로젝트 | 트랙백 | 덧글(0)

프로젝트 진행 01

블로그에도 진행사항을 올려야된다는걸 지금에서야 알고 지금이라도 올려봅니다.
수많은 시행착오를 거쳐서 레이아웃을 다시 잡는일이 반복되었지만 틀은 어느정도 잡혀갑니다.
그동안 수없는 컴파일과 에러메시지들을 보면서 소스를 수없이 고치면서 그때마다 알게된 내용을 바로 블로그에 올리지 못해 최근에 진행된 사항만 올리게 되었네요....

먼저 최근까지 완성된 인터페이스를 보면

소스를 살펴보면 (수많은 주석처리가 수많은 시행착오를 나타내고 있네요...ㅡ,.ㅡ;;)

import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Project extends Frame{  -->처음 구성을 왼쪽에 재고관리를 할수 있는 메뉴들을 넣어놓고 오른쪽에 각 메뉴에 맞는 기능을 할수있도록 구성을 하려고 한다. 사실 프로그램 짜는 중간에 각 메뉴의 기능을 할수 있는건 따로 프레임을 만들어서...즉 프레임위에 또 프래임을 띄어서 하려고 했으나.....맨처음부터 계획했던바가 아니였을뿐더러 그렇게 해봤더니 메인페이지가 너무 휑~해져서 그냥 한프레임안에서 다 해결하기로 결정하였습니다.
 private MyPanel mp;   -->입력을 받는등 메뉴에 맞는 기능을 할 공간
 //private MyPanel2 mp2;   --> 밑에서 보시면 아시겠지만 한공간에 여러 패널을 넣기 위해 많은 시행착오를 거쳤습니다.
 private MenuPanel pane;   -->왼쪽 메뉴 패널
 private Jego j;   -->왼쪽메뉴에서 어떤 메뉴를 선택했는지 알수있게 하기 위한 인수 전달용 클래스

 public Project(){
  super("재고관리");
  j = new Jego(this);
  //mp = new MyPanel();
  mp = new MyPanel(j);
  //mp2 = new MyPanel2(j);
  pane = new MenuPanel(j);

  setSize(280,220);
  add(pane,"West");
  add(mp,"Center");
  //  add(mp2,"Center");
  //  mp2.setVisible(false);
  addWindowListener(new WindowAdapter(){
   public void windowClosing(WindowEvent we){
    System.exit(0);
   }
  });
  //setDefaultCloseOperation(Frame.EXIT_ON_CLOSE);
  setVisible(true);
 }

 public static void main (String args[]){
  Project obj = new Project();
 }
}

class Jego{
 private int type = 0;   -->인수전달용 변수
 public Frame f;

 public Jego(Frame f){   -->패널을 여러개 넣기 위해 만들었던.....하지만 시행착오끝에 이젠 쓸모없게 된.....ㅡ,.ㅡ;;
  this.f = f;
 }

 public void setType(int type){
  this.type = type;
 }

 public int getType(){
  return type;
 }
}

class MenuPanel extends Panel{

 private Jego j;
 //private Panel mp;
 
 public MenuPanel(Jego j){
  super(new GridLayout(4,1));
  this.j = j;
  //this.mp = mp;
  Button b1 = new Button("입고");
  Button b2 = new Button("출고");
  Button b3 = new Button("정산");
  Button b4 = new Button("재고현황");

  MenuListener ml = new MenuListener(j);  -->각 메뉴마다 이벤트를 주고
  
  b1.addActionListener(ml);
  b2.addActionListener(ml);
  b3.addActionListener(ml);
  b4.addActionListener(ml);

  add(b1);
  add(b2);
  add(b3);
  add(b4);
 }
}

class MenuListener implements ActionListener{

 private Jego j;
 private MyPanel mp;
 private CardLayout cardLayout;
 //private MyPanel2 mp2;
 
 public MenuListener(Jego j){
  this.j = j;
  //this.mp = mp;
 }

 public void actionPerformed(ActionEvent e){
  String str = e.getActionCommand();
  if ("입고".equals(e.getActionCommand())){
   j.setType(1);
  } else if ("출고".equals(e.getActionCommand())){
   j.setType(2);
  } else if ("정산".equals(e.getActionCommand())){
   j.setType(3);
  } else if ("재고현황".equals(e.getActionCommand())){
   j.setType(4);
  }

  System.out.println(j.getType());

 

  /*if(j.getType()==1) {    --> 패널을 넣기 위해 이렇게 시도를 했더랍니다...ㅡ,.ㅡ;;
   MyPanel mp = new MyPanel(j);
   j.f.add(mp, "Center");
   j.f.setVisible(true);
  } else if(j.getType() == 2) {
   MyPanel2 mp = new MyPanel2(j);
   j.f.add(mp, "Center");
   j.f.setVisible(true);
  }*/
 }
}

class MyPanel extends Panel{

 private CardLayout cardLayout;
 private Panel cardPane;
 private Jego j;

 //public MyPanel(){
 public MyPanel(Jego j){   -->처음에 cardLayout을 차마 생각치 못해서 프레임을 하나 더 띄울시도...메뉴에 해당되는 각 패널을 다 따로 만들어서 넣어주는 시도...등을 해보는 엄청난 시간낭비를 했었습니다!!ㅠㅠ
  this.j = j;

  //cardPane = new Panel();
  Panel pane01 = new Panel();  //돌아갈 패널을 3개 만들고
  Panel pane02 = new Panel();
  Panel pane03 = new Panel();

  pane01.setBackground(Color.YELLOW);  //구분하기 위해 배경색을 구분지어주고
  pane02.setBackground(Color.RED);
  pane03.setBackground(Color.GREEN);
  cardLayout = new CardLayout();
  //cardPane.setLayout(cardLayout);  //CardLayout에 사용될 패널에 레이아웃을 주고
  setLayout(cardLayout);  //CardLayout에 사용될 패널에 레이아웃을 주고

  /*cardPane.add("1번패널",pane01);  //3개의 패널을 그 패널에 넣는다.
  cardPane.add("2번패널",pane02);
  cardPane.add("3번패널",pane03);*/
  add("1번패널",pane01);  //3개의 패널을 그 패널에 넣는다.
  add("2번패널",pane02);
  add("3번패널",pane03);

  Panel buttonPane = new Panel();  //패널들을 돌려가며 볼수있는 버튼을 만들 공간
  Button prev = new Button("이전");
  Button next = new Button("다음");

  MenuListener ml = new MenuListener(j);
  prev.addActionListener(ml);
  next.addActionListener(ml);

  buttonPane.add(prev);
  buttonPane.add(next);
  add(buttonPane,"South");
  //j.f.add(cardPane,"Center");

  
/*  Panel p1 = new Panel();
  p1.setLayout(new GridLayout(5,1));
  
  Label Su = new Label("수 량");
  Label Da = new Label("일 자");
  Label It = new Label("품 목");
  Label Me = new Label("메 모");

  TextField su = new TextField(15);
  TextField da = new TextField(15);
  TextField it = new TextField(15);
  TextField me = new TextField(15);

  Button b = new Button("저 장");

  Panel one = new Panel();
  Panel two = new Panel();
  Panel thr = new Panel();
  Panel fou = new Panel();
  Panel fiv = new Panel();

  one.add(Su);
  one.add(su);
  two.add(Da);
  two.add(da);
  thr.add(It);
  thr.add(it);
  fou.add(Me);
  fou.add(me);

  p1.add(one);
  p1.add(two);
  p1.add(thr);
  p1.add(fou);
  p1.add(b,"East");

  add(p1);*/
 }
}
/*
class MyPanel2 extends Panel{
 
 private Jego j;

 public MyPanel2(Jego j){
  this.j = j;

  Panel p1 = new Panel();
  p1.setLayout(new GridLayout(5,1));

  Label Su = new Label("수 량2");
  Label Da = new Label("일 자2");
  Label It = new Label("품 목2");
  Label Me = new Label("메 모2");

  TextField su = new TextField(15);
  TextField da = new TextField(15);
  TextField it = new TextField(15);
  TextField me = new TextField(15);

  Button b = new Button("저 장");

  Panel one = new Panel();
  Panel two = new Panel();
  Panel thr = new Panel();
  Panel fou = new Panel();
  Panel fiv = new Panel();

  one.add(Su);
  one.add(su);
  two.add(Da);
  two.add(da);
  thr.add(It);
  thr.add(it);
  fou.add(Me);
  fou.add(me);

  p1.add(one);
  p1.add(two);
  p1.add(thr);
  p1.add(fou);
  p1.add(b,"East");

  add(p1);
 }
}
*/

일단 이 소스는 지금까지 진행해 오면서 시행착오를 겪었던 것을 보여드리기 위해 그나마 남아있는 소스를 보여드린것인데.....
블로그에 이런식으로 진행사항을 올려야 하는게 맞는지 모르겠네요~~
이 다음 게시글부터는 위와 같은 시행착오를 겪고 나서 완성을 향해 가고 있는 프로그램 소스를 올리도록 하겠습니다~~

by 무한보더 | 2008/11/30 05:12 | 시스템프로젝트 | 트랙백 | 덧글(1)

<< 이전 페이지다음 페이지 >>