<html>
<head>
</head>
<body>
<h1>웹 브라우저 객체</h1>
<ul>window
<li>frame
<li>location
<li>history
<li>event
<li>navigatro
<li>document
<ul>
<li>applet
<li>link
<li>anchor
<li>area
<li>image
<li>all
<li>layer
<li>form
<ul>
<li>checkbox
<li>button
<li>radio
<li>reset
<li>submit
<li>hidden
<li>passowrd
<li>fileupload
<li>text
<li>textarea
<li>select
<ul>
<li>option
</ul>
</ul>

</ul>
</ul>
<h2>Document 하위 객체들</h2>
<h3>Form 객체</h3>
폼과 입력양식접근 위해 사용.<br>
태그에 name속성 부과.<br>
document.폼의이름.속성<br>
<ul>
<li>속성
<ul>
<li>action : 전송될 데이터를 처리할 url
<li>elements : 폼안에 있는 실질적인 입력양식 -??
<li>encoding : 데이터 인코딩 타입 - 타입들 찾아봐야함.
<li>method : 전송방식(get/post)
<li>name : 폼의 이름 -> [object]로 출력됨
<li>target : 서버로 보내고 처리결과를 받아볼 창
</ul>
<li>메소드
<ul>
<li>submit() : 입력된 데이터를 서버로 전송
<li>reset() : 입력 양식 초기화
</ul>
<ul>
<li>이벤트
<ul>
<li>onSubmit() : 데이터가 전송되기전에 발생하는 이벤트
<li>onReset() : 초기화전에 발생하는 이벤트
</ul>
</ul>
</ul>
<br>
<h3>Text 객체</h3>
<ul>입력상자의 정보를 제공하는 객체<br>형식<br>
document.폼의이름.텍스상자이름.속성/메소드()
<li>속성
<ul>
<li>type : 해당 입력 양식타입
<li>name : 텍스트 상자 이름
<li>value : 텍스트 상자에 입력된 값
<li>defaultvalue : 텍스트 상자의 초기값
</ul>
<li>메소드
<ul>
<li>focus : 텍스트 상자에 커서를 위치
<li>blur : 텍스트 상자에서 커서 사라지게함
<li>select : 텍스트 상자에 선택된 값 모두 선택
</ul>
<li>이벤트
<ul>
<li>onBlur() : 텍스트 상자에서 다르곳에 커서위치하게되면 발생 이벤트.
<li>onChange() : 텍스트 상자의 내용이 바뀌면 발생이벤트
<li>onFocus() : 텍스트 상자에 커서 위치하면 발생이벤트
<li>onSelect() : 텍스트 상자에 입력된 값 선택할때 발생이벤트
</ul>
</ul>
<xmp>앞쪽 input에 글자 넣고 옆 버튼 누르면. 앞쪽내용복사, 뒷쪽 들어가면 전체선택, 수정하면 대문자로 바꿈.
<form name="form1">
<input type="text" name="box1" size="10">
<input type="button" value="->" onClick="this.form.box2.value=this.form.box1.value">
<input type="text" name="box2" size="10" onfocus="this.select()" onChange="this.value=this.value.toUpperCase();">
</form>
</xmp>
<form name="form1">
<input type="text" name="box1" size="10">
<input type="button" value="->" onClick="this.form.box2.value=this.form.box1.value">
<input type="text" name="box2" size="10" onfocus="this.select()" onChange="this.value=this.value.toUpperCase();">
</form>
<br>
<h3>Password 객체</h3>
*표시로 입력문자 가려주고, 자동으로 한글을 제외한 영문/숫자를 받음.<br>
//onSubmit 먼저호출후 action 페이지로 넘어감.
<xmp>
<script type="text/jscript">
function check1()
{
//아래내용은 설명들은것이나, 이해가 안감  // 추후 요건물랐네에 포함됨
//여기서 eval은 객체를 만들어줌.
//var inform = eval("document.passwordform");

//위에거랑 차이점 못느낌.
var inform = document.passwordform;

if(!inform.id.value)
{
alert("id를 넣어주세요");
inform.id.focus();
return false;
}
}
</script>
<form name="passwordform" method="post" action="#" onSubmit="return check1()">
ID : <input type="text" name="id"><br>
Pwd : <input type="password" name="pwd" onBlur="this.form.recivepwd.value=this.value">
<input type="text" name="recivepwd"><br>
<input type="submit"><input type="reset">
</form>
</xmp>
<script type="text/jscript">
function check1()
{
//아래내용은 설명들은것이나, 이해가 안감
//여기서 eval은 객체를 만들어줌.
//var inform = eval("document.passwordform");

//위에거랑 차이점 못느낌.
var inform = document.passwordform;

if(!inform.id.value)
{
alert("id를 넣어주세요");
inform.id.focus();
return false;
}
}
</script>
<form name="passwordform" method="post" action="#" onSubmit="return check1()">
ID : <input type="text" name="id"><br>
Pwd : <input type="password" name="pwd" onBlur="this.form.recivepwd.value=this.value">
<input type="text" name="recivepwd"><br>
<input type="submit"><input type="reset">
</form>
<br>
<h3>Textarea 객체</h3>
document.폼이름.textarea이름.속성/메소드();<br>
text와 동일 속성/메소드 이여서 생략한것일까?<br>
</body>
</html>

Posted by 말없제이
,

문득 수업시간에 들은 eval 너 객체 만들어주는거 맞어?
생각이 들어서..
eval없으면 객체를 만들어주지 못하는거 아래 걸루 보면 알어.

<script type="text/jscript">
var opt2 = "option"+b; //일반 개첵할당 안되고 스트링+수자로 스트링 인식.
var opt1 = eval("option"+b);  // 과감히 객체로 인식 option1, option2....
a.form.t1.value = opt2;
a.form.t2.value = opt1;

for(var j=0;j<opt1.length;j++)
{
 sel1.options[j]=new Option(opt1[j].text, opt1[j].value, opt1[j].defaultSelected, opt1[j].selected);
}

}
</script>
<form name="single">
<input type="radio" name="id" onClick="onMp3(this,1);">1 : A면
<input type="radio" name="id" onClick="onMp3(this,2);">2 : B면
<select name="selMp3"></select><br>
<br>
<font color="red">요걸몰랐네~~!</font><br>
eval("option"+b).. 너 객체의문이였지만.. ^^. 아래로 해결.<br>
String으로 인식하면 문자가 뜰것이고, 객체로 인식하면 배열로 뜰것이고..<br>
"option"+b<input type="type" name="t1">eval("option"+b)<input type="text" name="t2">
<select name="selMp32"></select>
</form>

Posted by 말없제이
,
문득 찾을려면 안보이는..
그래서 위치가...
창 > 환경설정 ..
사용자 삽입 이미지

Java > 고급스타일 > 포맷터 ... > 표시 클릭.
사용자 삽입 이미지

중괄호탭 > 내용 다음줄 하면 중괄호다음은  무조건 개행이되겠지요.
사용자 삽입 이미지
Posted by 말없제이
,

package ch11;

import java.awt.Frame;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.Button;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Ch1106 extends Frame {

 private static final long serialVersionUID = 1L;
 private Label label1 = null;
 //서브윈도우에서 접근할 수도록 하기 위해...
 public TextField txtId = null;
 private Button button1 = null;
 
 //서브윈도우에 전달할 클래스 자기자신을 멤버변수로
 //선언
 private Ch1106 main;
 /**
  * This is the default constructor
  */
 public Ch1106() {
  super();
  //클래스 자기자신을 멤버변수main에 대입
  main=this;
  initialize();
 }

 /**
  * This method initializes this
  *
  * @return void
  */
 private void initialize() {
  label1 = new Label();
  label1.setBounds(new Rectangle(18, 43, 45, 23));
  label1.setText("아이디");
  this.setLayout(null);
  this.setSize(300, 200);
  this.setTitle("메인윈도우");

  this.setVisible(true);
  this.add(label1, null);
  this.add(getTxtId(), null);
  this.add(getButton1(), null);
  this.addWindowListener(new WindowAdapter() {
   @Override
   public void windowClosing(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
    dispose();
   }
  });
 }

 /**
  * This method initializes txtId
  *  
  * @return java.awt.TextField
  */
 private TextField getTxtId() {
  if (txtId == null) {
   txtId = new TextField();
   txtId.setBounds(new Rectangle(73, 45, 128, 23));
   txtId.setEditable(false);
  }
  return txtId;
 }

 /**
  * This method initializes button1
  *  
  * @return java.awt.Button
  */
 private Button getButton1() {
  if (button1 == null) {
   button1 = new Button();
   button1.setBounds(new Rectangle(213, 45, 58, 23));
   button1.setLabel("ID검사");
   button1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
     // TODO 자동 생성된 메소드 스텁
     new Ch1106sub(main);
    }
   });
  }
  return button1;
 }

}

****** Ch1106sub.java *******
package ch11;

import java.awt.Frame;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.Button;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Ch1106sub extends Frame {

 private static final long serialVersionUID = 1L;
 private Label label1 = null;
 private TextField txtId = null;
 private Button button1 = null;
 //메인윈도우를 보관할 멤버변수의 선언
 private Ch1106 main;
 /**
  * This is the default constructor
  */
 public Ch1106sub() {
  super();
 }
 
 public Ch1106sub(Ch1106 main)
 {
  //인자없는 생성자 호출
  this();
  //메인윈도우개체를 멤버변수에 보관
  this.main=main;
  initialize();
 }

 /**
  * This method initializes this
  *
  * @return void
  */
 private void initialize() {
  label1 = new Label();
  label1.setBounds(new Rectangle(18, 43, 45, 23));
  label1.setText("아이디");
  this.setLayout(null);
  this.setSize(300, 200);
  this.setTitle("서브윈도우");

  this.setVisible(true);
  this.add(label1, null);
  this.add(getTxtId(), null);
  this.add(getButton1(), null);
  this.addWindowListener(new WindowAdapter() {
   @Override
   public void windowClosing(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
    dispose();
   }
  });
 }

 /**
  * This method initializes txtId
  *  
  * @return java.awt.TextField
  */
 private TextField getTxtId() {
  if (txtId == null) {
   txtId = new TextField();
   txtId.setBounds(new Rectangle(73, 45, 128, 23));
  }
  return txtId;
 }

 /**
  * This method initializes button1
  *  
  * @return java.awt.Button
  */
 private Button getButton1() {
  if (button1 == null) {
   button1 = new Button();
   button1.setBounds(new Rectangle(213, 45, 58, 23));
   button1.setLabel("ID검사");
   button1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
     // TODO 자동 생성된 메소드 스텁
     //메인윈도우의 id에 현재 서브윈도우의 id의 값을 대입
     main.txtId.setText(txtId.getText());
     dispose();
    }
   });
  }
  return button1;
 }

}

Posted by 말없제이
,

package ch11;

import java.awt.Frame;
import java.awt.Dimension;
import java.awt.Button;
import java.awt.Rectangle;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Ch1105 extends Frame implements ActionListener
{

 private static final long serialVersionUID = 1L;
 private Button button1 = null;
 private Button button2 = null;
 private Button button3 = null;
 private TextArea textArea = null;
 /**
  * This is the default constructor
  */
 public Ch1105() {
  super();
  initialize();
 }

 /**
  * This method initializes this
  *
  * @return void
  */
 private void initialize() {
  this.setLayout(null);
  this.setSize(351, 229);
  this.setTitle("Frame");

  this.add(getButton1(), null);
  this.add(getButton2(), null);
  this.add(getButton3(), null);
  this.add(getTextArea(), null);
 }

 /**
  * This method initializes button1
  *  
  * @return java.awt.Button
  */
 private Button getButton1() {
  if (button1 == null) {
   button1 = new Button();
   button1.setBounds(new Rectangle(20, 40, 91, 31));
   button1.setLabel("내용1");
   //클래스 자신이 ActionListener인터페이스의 하위 클래스이므로.
   button1.addActionListener(this);
  }
  return button1;
 }

 /**
  * This method initializes button2
  *  
  * @return java.awt.Button
  */
 private Button getButton2() {
  if (button2 == null) {
   button2 = new Button();
   button2.setBounds(new Rectangle(140, 40, 81, 31));
   button2.setLabel("내용2");
   button2.addActionListener(this);
  }
  return button2;
 }

 /**
  * This method initializes button3
  *  
  * @return java.awt.Button
  */
 private Button getButton3() {
  if (button3 == null) {
   button3 = new Button();
   button3.setBounds(new Rectangle(250, 40, 81, 31));
   button3.setLabel("내용3");
   button3.addActionListener(this);
  }
  return button3;
 }

 /**
  * This method initializes textArea
  *  
  * @return java.awt.TextArea
  */
 private TextArea getTextArea() {
  if (textArea == null) {
   textArea = new TextArea();
   textArea.setBounds(new Rectangle(20, 91, 311, 120));
  }
  return textArea;
 }

 public void actionPerformed(ActionEvent e) {
  // TODO 자동 생성된 메소드 스텁
  //이벤트 클래스의 getSource메서드는
  //이벤트가 발생한 진원지 컴포넌트를 반환.
  Button b = (Button)e.getSource();
  textArea.append(b.getLabel()+"\r\n");
 
 }

}  //  @jve:decl-index=0:visual-constraint="10,10"

Posted by 말없제이
,

package ch11;

import java.awt.Frame;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.TextField;
import java.awt.Button;
import java.awt.TextArea;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Dimension;

public class Ch1104 extends Frame {

 private static final long serialVersionUID = 1L;
 //키포인트 == 어너미클래스는 멤버변수때문에 접근이 가능....
 private Label label1 = null;
 private TextField textname = null;
 private Button button1 = null;
 private TextArea text = null;
 /**
  * This is the default constructor
  */
 public Ch1104() {
  super();
  initialize();
 }

 /**
  * This method initializes this
  *
  * @return void
  */
 private void initialize() {
  label1 = new Label();
  label1.setText("이름");
  label1.setBounds(new Rectangle(10, 30, 51, 21));
  this.setLayout(null);
  this.setSize(300, 200);
  this.setTitle("Frame");

  this.add(label1, null);
  this.add(getTextname(), null);
  this.add(getButton1(), null);
  this.add(getText(), null);
 }

 /**
  * This method initializes textname
  *  
  * @return java.awt.TextField
  */
 private TextField getTextname() {
  if (textname == null) {
   textname = new TextField();
   textname.setBounds(new Rectangle(70, 30, 161, 21));
  }
  return textname;
 }

 /**
  * This method initializes button1
  *  
  * @return java.awt.Button
  */
 private Button getButton1() {
  if (button1 == null) {
   button1 = new Button();
   button1.setLabel("추가");
   button1.setBounds(new Rectangle(240, 30, 50, 21));
   button1.addActionListener(new ActionListener() {

    public void actionPerformed(ActionEvent e) {
     // TODO 자동 생성된 메소드 스텁
     //getText를 사용하면 입력값을 얻어올 수 있다.
     //System.out.println(textname.getText());
     String value=textname.getText();
     //setText를 사용하면 컴포넌트에 값을 대입할 수 있다.
     //text.setText(value);
     //TextArea에서는 append가 지원됨.
     //★ Anonymous Class는 메인클래스의 멤버변수의 접근이 자유롭다.
     text.append(value+"\r\n");
     textname.setText("");
    }});
  }
  return button1;
 }

 /**
  * This method initializes text
  *  
  * @return java.awt.TextArea
  */
 private TextArea getText() {
  if (text == null) {
   text = new TextArea();
   text.setName("textarea");
   text.setBounds(new Rectangle(10, 60, 281, 131));
  }
  return text;
 }

}  //  @jve:decl-index=0:visual-constraint="77,6"

Posted by 말없제이
,

1.사용할 컴포넌트 개체는 전부 멤버변수로 할당해야함.
ex)private Button button1;

2. VE에서는 컴포넌트를 Get방식멤버변수에서 생성하고
   이를 반환하도록 설계되어있다.
ex) private Button getButton1()
 {
  if(button1==null)
  {
   button1 = new Button();
 ..................
   });
  }
  return button1;

이렇게 구조를 잡으면 VE로도 인식가능.
***************************************
package ch11;

import java.awt.*;
import java.awt.event.*;

import javax.swing.JOptionPane;

//VE에서는 윈도우폼을 만들때 Frame 클래스를 상속받도록 한다.
public class Ch1103 extends Frame
{
 //VE에서는 사용할 컴포넌트 개체는 전부 멤버변수로
 //등록하여 관리함.
 private Button button1;
 
 public Ch1103()
 {
  // TODO 자동 생성된 생성자 스텁
  //VE에서는 생성자에 super()호출 및 initialize()호출
  super();
  initialize();
 }
 
 private void initialize()
 {
  // TODO 자동 생성된 메소드 스텁
  setVisible(true);
  setBounds(0,0,320,200);
  setLayout(null);
  setTitle("수동으로 작성한");
  setBackground(new Color(150,150,50));
 
  add(getButton1());
 
 }


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

 /**
  * VE에서는 컴포넌트를 Get방식멤버변수에서 생성하고
  * 이를 반환하도록 설계되어있다.
  * @return button1
  */
 private Button getButton1()
 {
  if(button1==null)
  {
   button1 = new Button();
   button1.setLabel("버튼1");
   button1.setBounds(70, 70, 150, 100);
   button1.addActionListener(new ActionListener() {

    public void actionPerformed(ActionEvent e) {
     // TODO 자동 생성된 메소드 스텁
     JOptionPane.showMessageDialog(null, "Hello");
     
    }});
  }
  return button1;
 }
}

Posted by 말없제이
,

버튼 찍고 늘려서 생성.
속성 들어가서 설정..

********* 아래코드는 전부 자동생성. ***********
package ch11;

import java.awt.Frame;
import java.awt.Panel;
import java.awt.GridBagLayout;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.Color;

import javax.swing.JOptionPane;

public class Ch1102 extends Frame {

 private static final long serialVersionUID = 1L;
 private Button button = null;
 /**
  * This is the default constructor
  */
 public Ch1102() {
  super();
  initialize();
 }

 /**
  * This method initializes this
  *
  * @return void
  */
 private void initialize() {
  this.setLayout(null);
  this.setSize(300, 200);
  this.setBackground(new Color(153, 204, 0));
  this.setTitle("AWT 윈도우");

  this.setVisible(true);
  this.add(getButton(), null);
  this.addWindowListener(new java.awt.event.WindowAdapter() {
   public void windowClosing(java.awt.event.WindowEvent e) {
    System.out.println("windowClosing()"); // TODO Auto-generated Event stub windowClosing()
    dispose();
   }
  });
 
 }

 /**
  * This method initializes button
  *  
  * @return java.awt.Button
  */
 private Button getButton() {
  if (button == null) {
   button = new Button();
   button.setBounds(new Rectangle(81, 69, 148, 47));
   button.setLabel("버튼 1");
   button.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent e) {
     System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
     JOptionPane.showMessageDialog(null, "Hello");
    }
   });
  }
  return button;
 }

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

}

Posted by 말없제이
,

package ch11;

//AWT윈도우 프로그램밍을 하려면 아래 패키지를 import
import java.awt.*;
import java.awt.event.*;

import javax.swing.JOptionPane;

//나쁜점 : Frame 종속적인 프로그램이 됨.
public class Ch1101 extends Frame
{
 //클래스 요소 이해하기 쉬워서 winform배움.
 public Ch1101()
 {
  //컨테이너 : 컴포턴트에 다른 컴포넌트를 포함시킬수 있는 컴포넌트를 건테이너라 부른다.
  // TODO 자동 생성된 생성자 스텁
//  Frame frame = new Frame();
//  //winform 여부..
//  frame.setVisible(true);
//  //winform 크기조정.
//  frame.setBounds(0, 0, 640, 480);
//  //제목넣기
//  frame.setTitle("윈도우 제목");
//  //배경색상 넣
//  frame.setBackground(new Color(125,120,150));
 
  //숙제 -- jframe 소유로 처리..  frame클래스로 계승받아 처리하도록.
  super();
  int x=10, y=10, width=640, height=480;
  String title="윈도우 제목";
  Color c=new Color(125,120,150);
  this.setBounds(x, y, width, height);
  this.setTitle(title);
  this.setBackground(c);
  //null을 지정시 컴포넌트 배치를 절대좌표체계를 따름
  setLayout(null);
  Button button1 = new Button();
  button1.setBounds(100,100,150,200);
  button1.setLabel("버튼1");
  button1.addActionListener(new ActionListener() {

   public void actionPerformed(ActionEvent e) {
    // TODO 자동 생성된 메소드 스텁
    JOptionPane.showMessageDialog(null, "Hello");
   
   }});
  add(button1);
 
  //어너미머스 -> 인너 -> ...
  //WindowListener() {} : Anonymous class (어너미머스 클래스 = 이름이 없는 클래스)
  addWindowListener(new WindowListener() {

   public void windowActivated(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
   
   }

   public void windowClosed(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
   
   }

   public void windowClosing(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
    //Frame클래스(상위클래스)의 dispose함수 호출;
    dispose();
   }

   public void windowDeactivated(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
   
   }

   public void windowDeiconified(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
   
   }

   public void windowIconified(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
   
   }

   public void windowOpened(WindowEvent e) {
    // TODO 자동 생성된 메소드 스텁
   
   }
  });
 
 }
 
 public static void main(String[] args)
 {
  new Ch1101();
 }
}

Posted by 말없제이
,

package ch10;

public class Ch1004
{
 public static void main(String[] args)
 {
  //JDK 5.0에서는  new Object 생성없이 가변형인자. 바로 가능, String.Format도 사용가능.
  System.out.printf("Hello %s %d\r\n","java",10);
  System.out.print(String.format("Hello %s %d\r\n","java",10));
 
 }
}

Posted by 말없제이
,