AppleTree iOS

java - 15일재(source) awt 본문

JAVA/기초 JAVA

java - 15일재(source) awt

사과나무 2010. 7. 28. 15:50

package console.base.readline;

import java.util.HashMap;
import java.util.HashSet;

import java.util.ArrayList;

//static 는객체보다 먼저vm 로딩됩니다
//먼저 뜨기때문에  this.으로는 접근을 못합니다
//static 은 클래스명.변수나 메소드 또는 inner class을 불러올수있습니다
//static 은 모든 객체에서 공유할수 있다

public class Test {
 public static int commonint = 3;
 public String userid;
 public String passwd;

 public static int getCommonInt() {
  return Test.commonint;
 }

 public static void setCommonInt(int commonint) {
  Test.commonint = commonint;
 }

 public Test(int commonint) {
  Test.commonint = commonint;
 }

 public Test() {
 }
 
 public Test(Test test){
  
 }
 
 public Test(String userid,String passwd){
  this.userid=userid;
  this.passwd=passwd;
 }

 public static void main(String[] args) {

  //무명클래스
  //무명클래스는 이름이 없는 클래스입니다.
  //원본객체
  
  Test test=new Test("kim","1234");
  
  HashSet set=new HashSet();
  set.add("맥주");
  set.add("생성");
  set.add("안주");
  set.add("과일");
 
  for (int i = 0; i < set.size(); i++) {
  Object ob[] = set.toArray();
  //현재담겨진 값은 초기값은 1
  System.out.println("현재리스트:"+ob[i]);
  
  }
  
  for (int i = 0; i < set.size(); i++) {
   //현재담겨진 값은 초기값은 1
   
   set.remove("맥주");
   set.remove("안주");
   set.remove("과일");
   Object ob[] = set.toArray();
   System.out.println("뺀값:"+ob[i]);
   
  
  }
  //java.util.Iterator itnext=set.iterator();
  
  
  /*
  while(itnext.hasNext()){
  }
  */
  
  //HashMap
  // index 로 가지않습니다
  // 초기값을자기가 설정할수있습니다
  // 키값을 어떤형이든 넣을수있습니다
  // hash.put(Object,Object);
/*
  HashMap hash = new HashMap(1024);
  hash.put(1, 1);
  hash.put(2, 2);
  hash.put(3, 3);
  hash.put(4, 4);
  hash.put(5, 5);

  for (Integer i = 1; i <= hash.size(); i++) {
   Integer result = (Integer) hash.get(i); //??

   if (result == i) {
   //hash.remove(1);
   //hash.remove(2);
   
    if(result==1){
     
     
    }
    
   //hash.remove(3);
  // hash.remove(4);
   
    
    
   System.out.println(result);
      
   }

  }
  
  
  //HashSet
  //Removes the specified element from this set if it is present.
  
  //HashMap
  //Removes the mapping for the specified key from this map if present.
  
  /*
  for (Integer i = 1; i <= hash.size(); i++) {
   Integer result = (Integer) hash.get(i);
   System.out.println("뺀값:"+result);
   
  } 
  */
  /*
   * ArrayList array=new ArrayList(); array.add(1,1); array.add(2,2);
   * array.add(3,3); array.add(4,4);
   */

  // 변수와 메소드을 static 선언으로 해서 모든 객체에서 같이공유할수있게 선언했다
  // Test.setCommonInt(10);

  /*
   * Test te=new Test(1); Test te2=new Test(2); Test te3=new Test(3);
   *
   *
   *
   * System.out.println(te.getCommonInt());
   * System.out.println(te2.getCommonInt());
   * System.out.println(te3.getCommonInt());
   */

 }

}







package console.awt;

import java.awt.Frame;
import java.awt.Button;
import java.awt.Panel;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class AwtExaple extends  WindowAdapter{
  public void windowClosing(WindowEvent e){
   System.exit(0);
  } 
 
 
 public AwtExaple(){
  //우리윈도우창을 하나 만듭니다
  Frame fr=new Frame("안드로이드 ");
  //윈도우에 대한 layout 을설정입니다
  //BorderLayout 동서남북
  //FlowLayout 가로방향으로설정
  //fr.setLayout(new FlowLayout());
  //fr.setLayout(new BorderLayout());
  fr.setLayout(new GridLayout(3,2,3,4));
  /*
  Button bu=new Button("north");
  Button bu2=new Button("south ");
  Button bu3=new Button("east ");
  Button bu4=new Button("west ");
  Button bu5=new Button("center ");
  */
  
  
  for(int i=1;i<=6;i++){
   fr.add(new Button(String.valueOf(i)));
  }
  
  
  //Frame 에 버튼을 담는다
  /*
  fr.add(bu,BorderLayout.NORTH);
  fr.add(bu2,BorderLayout.SOUTH);
  fr.add(bu3,BorderLayout.EAST);
  fr.add(bu4,BorderLayout.WEST);
  fr.add(bu5,BorderLayout.CENTER);
  */
  /*
  
      add(new Button("North"), BorderLayout.NORTH);
      add(new Button("South"), BorderLayout.SOUTH);
      add(new Button("East"), BorderLayout.EAST);
      add(new Button("West"), BorderLayout.WEST);
      add(new Button("Center"), BorderLayout.CENTER);
   */
  //자기자신에대한 윈도우이벤트을걸겠다
  fr.addWindowListener(this);
  fr.setSize(640,480);
  fr.setVisible(true);
 
 }
 
 
 public static void main(String[] args) {
  
  
  
  AwtExaple an=new AwtExaple();
  

  
 }

}







package console.awt;

import java.awt.Frame;
import java.awt.Panel;
import java.awt.Label;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.TextArea;
import java.awt.Button;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class AndroidPhone extends Frame {
 public Panel bodypanel;
 public Panel bottompanel;
 public Panel centerpanel;
 
 public Label toplabel;
 public Label leftlabel;
 public Label rightlabel;

 public TextArea centerview;
 public Button callphone;
 public Button backaction;
 public Button stopaction;

 public AndroidPhone() {
  super("안드로이드2.2");
  setLayout(new FlowLayout());

  bodypanel = new Panel();
  bottompanel = new Panel();
  toplabel = new Label("안드로이드 ",Label.CENTER);
  leftlabel = new Label(" ");
  rightlabel = new Label(" ");

  centerview = new TextArea();
  centerpanel=new Panel();
  centerpanel.setSize(150,150);
  centerpanel.add(centerview);
  callphone = new Button("전화");
  backaction = new Button("백");
  stopaction = new Button("중지");

  bodypanel.setLayout(new BorderLayout());
  bodypanel.add(toplabel, BorderLayout.NORTH);
  bodypanel.add(centerview, BorderLayout.CENTER);
  bodypanel.add(leftlabel, BorderLayout.WEST);
  bodypanel.add(rightlabel, BorderLayout.EAST);
  bottompanel.setLayout(new FlowLayout());

  bottompanel.add(callphone);
  bottompanel.add(backaction);
  bottompanel.add(stopaction);

  bodypanel.add(bottompanel, BorderLayout.SOUTH);
  add(bodypanel);

  addWindowListener(new WindowAction());
  setSize(170, 280);
  setVisible(true);

 }

 public class WindowAction extends WindowAdapter {

  @Override
  public void windowClosing(WindowEvent e) {
   System.exit(0);
  }
 }

 public static void main(String[] args) {

  AndroidPhone an=new AndroidPhone();
  
  
 }

}






'JAVA > 기초 JAVA' 카테고리의 다른 글

java - 16일째(source)  (0) 2010.07.29
java -(source) AwtLogin  (0) 2010.07.29
java - 14일째(source)  (0) 2010.07.27
Address 비교 선생님꺼 내꺼  (0) 2010.07.27
java - 13일째(source)  (0) 2010.07.26
Comments