2010년 3월 9일 화요일

Browser 객체

웹서핑(Web Surfing)을 하다 보면 흔히 만나게 되는 것이 광고나 Event, 여러 가지 공지사항 등을 작은 창에 띄우는 것입니다. 자바스크립트를 이용하면 이와같은 Window들을 다양한 방법으로 제어할 수 있습니다.

 

I. Window Open

[형식]

winObject = window.open("url", "name", "options");

 

* winObject open window를 가리키는 reference변수이다.

* url (반드시 있어야 한다)

새로 만들어진 window에 나타날 web문서의 URL을 적는다. 적당한 url이 없을 경우 ""로 표시한다.

* name (반드시 있어야 한다)

새로 만들어진 window의 이름을 지정한다. 적당한 name을 붙이지 않으려면 ""로 표시하면 된다. name위치에 입력한 이름은 <FORM>이나 <A>태그에서 사용하는 Target속성으로 연결할 수 있다.

* options (생략가능하며 생략하는 경우 default값이 적용된다)

1. menubar : window menubar표시 여부 (yes/no or 1/0)

2. toolbar : window toolbar표시 여부 (yes/no or 1/0)

3. location : window location box표시여부 (yes/no or 1/0)

4. directories : window directory button들의 출력여부 (yes/no or 1/0)

5. status : window의 상태표시줄 표시 여부 (yes/no or 1/0)

6. scrollbars : window의 가로, 세로 scrollbar표시 여부 (yes/no or 1/0)

7. resizable : window의 크기가 조절 될 수 있는지 결정 (yes/no or 1/0)

8. width : Display window의 너비 결정 (단위 pixel)

9. height : Display window의 높이 결정 (단위 pixel)

10. left : Display window의 좌측 상단의 x좌표 (단위 pixel)

11. top : Display window의 좌측 상단의 x좌표 (단위 pixel)

 

II. Window Close

[형식]

window.close();

 

* window를 종료할 때는 반드시 Window open이 되었는지 check한 다음 close하도록 한다.

2009년 7월 22일 수요일

AWT를 이용한 간단한 - 계산기 -

import java.awt.Frame;
import java.awt.TextField;
import java.awt.Button;
import java.awt.Panel;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.Color;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Calculator extends Frame implements WindowListener, ActionListener{
 TextField result;
 Button[] button;
 boolean num_state = true;
 boolean operator_state=true;
 String op_temp;
 String num_temp;

 public void init() {
  result = new TextField("0", 30);
  result.setEditable(false);
  String[] buttonTitle = {"7", "8", "9", "/",
             "4", "5", "6", "*",
             "1", "2", "3", "-",
             "C", "0", "=", "+"};
  button = new Button[16];
  Panel p = new Panel();

  p.setLayout(new GridLayout(4,4,3,3));

  for (int i=0; i<button.length; i++ ) {
   button[i] = new Button(buttonTitle[i]);
   button[i].setBackground(new Color(58, 226, 206));
   p.add(button[i]);
   button[i].addActionListener(this);
  } //for

  this.add("North", result);
  this.add("Center", p);
  this.setTitle("Calculator");
  this.setBounds(600,300,200,200);
  this.setVisible(true);
  this.addWindowListener(this);
 }//init()
 
 public void windowActivated(WindowEvent e) { }
 public void windowClosed(WindowEvent e) { }
 public void windowClosing(WindowEvent e) {
  System.exit(0);
 }
 public void windowDeactivated(WindowEvent e) { }
 public void windowDeiconified(WindowEvent e) { }
 public void windowIconified(WindowEvent e) { }
 public void windowOpened(WindowEvent e) { }
 
 public void actionPerformed(ActionEvent e) {
  String in = e.getActionCommand();

  if(in.equals("C")){
   result.setText("0");
   num_state = true;
  }else if('0' <= in.charAt(0) && in.charAt(0) <= '9') {
   if (num_state)
    result.setText(in);
   else
    result.setText(result.getText() +in);
   num_state = false;
  }

   if(in.equals("/") || in.equals("*") || in.equals("-") || in.equals("+")) {
    num_temp = result.getText();
    op_temp = in;
    num_state=true;
   }else if(in.equals("=")) {
    if(operator_state) {
     double num1 = Double.parseDouble(num_temp);
     double num2 = Double.parseDouble(result.getText());

     if(op_temp.equals("+")) {
      result.setText("" + (num1+num2));
     }else if(op_temp.equals("-")) {
      result.setText("" + (num1-num2));
     }else if(op_temp.equals("*")) {
      result.setText("" + (num1*num2));
     }else if(op_temp.equals("/")) {
      result.setText("" + (num1/num2));
     }
    }
   }
 }

 public static void main(String[] args) {
  Calculator ct = new Calculator();
  ct.init();
  }
 }

Swing을 이용한 간단한 - 그림판 -

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
import javax.swing.JButton;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import java.awt.FlowLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.*;

class GraphicTest extends JFrame implements ActionListener {
 JLabel x1L, y1L, x2L, y2L, z1L, z2L;
 JTextField x1T, y1T, x2T, y2T, z1T, z2T;
 JCheckBox fill;
 JRadioButton line, circle, rect, roundR, arc;
 JButton draw;
 DrCanvas can;
 JComboBox combo;

 int x1, y1, x2, y2, z1, z2;
 
 public GraphicTest() {
  super("간단 그림판");//setTitle("간단 그림판"); //super는 맨위쪽

  x1L = new JLabel("x1L");
  y1L = new JLabel("y1L");
  x2L = new JLabel("x2L");
  y2L = new JLabel("y2L");
  z1L = new JLabel("z1L");
  z2L = new JLabel("z2L");

  x1T = new JTextField("100",4);
  y1T = new JTextField("150",4);
  x2T = new JTextField("200",4);
  y2T = new JTextField("250",4);
  z1T = new JTextField("80",4);
  z2T = new JTextField("80",4);

  fill = new JCheckBox("채우기");

  line = new JRadioButton("선");
  circle = new JRadioButton("원");
  rect = new JRadioButton("사각형", true);
  roundR = new JRadioButton("둥근사각형");
  arc = new JRadioButton("호");

  ButtonGroup bg = new ButtonGroup();
  bg.add(line);
  bg.add(circle);
  bg.add(rect);
  bg.add(roundR);
  bg.add(arc);

  draw = new JButton("그리기");
 
  can = new DrCanvas();

  String[] color = {"빨강", "초록", "파랑", "검정", "보라"};
  combo = new JComboBox(color);

  JPanel p = new JPanel(); //FlowLayout(순서배치)    

  p.add(x1L); p.add(x1T);
  p.add(y1L); p.add(y1T);
  p.add(x2L); p.add(x2T);
  p.add(y2L); p.add(y2T);
  p.add(z1L); p.add(z1T);
  p.add(z2L); p.add(z2T);
  p.add(fill);  

  JPanel p2 = new JPanel();

  p2.add(line);
  p2.add(circle);
  p2.add(rect);
  p2.add(roundR);
  p2.add(arc);
  p2.add(combo);
  p2.add(draw);

  getContentPane().add("North", p);
  getContentPane().add("South", p2);
  getContentPane().add("Center", can);

  setBounds(500,100,600,500);
  setVisible(true);
  setDefaultCloseOperation(EXIT_ON_CLOSE);  

  //이벤트 처리
  draw.addActionListener(this);
  line.addActionListener(this);
  circle.addActionListener(this);
  rect.addActionListener(this);
  roundR.addActionListener(this);
  arc.addActionListener(this);    
  can.addMouseListener(new MouseAdapter() {
   public void mousePressed(MouseEvent e) {
    x1T.setText(String.valueOf(e.getX()));
    y1T.setText(String.valueOf(e.getY()));
    can.repaint();
   }
  });
  can.addMouseMotionListener(new MouseMotionAdapter(){
   public void mouseDragged(MouseEvent e){
    x2T.setText(String.valueOf(e.getX()));
    y2T.setText(String.valueOf(e.getY()));
    can.repaint();
   }
  });
 }//GraphicTest( )
 
 //ActionListner override
 public void actionPerformed(ActionEvent e){
   can.repaint(); //update () -> paint() 순서로 호출
 }

 class DrCanvas extends Canvas {
  public  DrCanvas() {
   this.setBackground(new Color(255,255,100)); //바탕색 -연한노랑
   setForeground(new Color(255,0,0));//글자색
  }//DrCanvas( )

  public void paint(Graphics g) {
   //좌표 얻어오기
   x1 = Integer.parseInt(x1T.getText().trim()); //trim - 앞뒤공백제거
   y1 = Integer.parseInt(y1T.getText().trim());
   x2 = Integer.parseInt(x2T.getText().trim());
   y2 = Integer.parseInt(y2T.getText().trim());
   z1 = Integer.parseInt(z1T.getText().trim());
   z2 = Integer.parseInt(z2T.getText().trim());    
   
   //색
   switch(combo.getSelectedIndex()) {
    case 0: this.setForeground(new Color (255,0,0));
     break;    
    case 1: this.setForeground(new Color (0,255,0));
     break;
    case 2: this.setForeground(new Color (0,0,255));
     break;
    case 3: this.setForeground(new Color (0,0,0));
     break;
    case 4: this.setForeground(new Color (255,0,255));
     break;
   }//switch

   int startX = x1 < x2 ? x1 : x2;
   int startY = y1 < y2 ? y1 : y2;
   int width = x1 < x2 ? x2-x1 : x1-x2;
   int height = y1 < y2 ? y2-y1 : y1-y2;

   //도형 그리기
   if(fill.isSelected()) {  //채우기 선택
    if(line.isSelected())
     g.drawLine(x1, y1, x2, y2);
    else if(circle.isSelected())
     g.fillOval(startX, startY, width, height);
    else if(rect.isSelected())
     g.fillRect(startX, startY, width, height);
    else if(roundR.isSelected())
     g.fillRoundRect(startX, startY, width, height, z1, z2);
    else if(arc.isSelected())
     g.fillArc(startX, startY, width, height, z1, z2);
   }else { //채우기 해제
    if(line.isSelected())
     g.drawLine(x1, y1, x2, y2);
    else if(circle.isSelected())
     g.drawOval(startX, startY, width, height);
    else if(rect.isSelected())
     g.drawRect(startX, startY, width, height);
    else if(roundR.isSelected())
     g.drawRoundRect(startX, startY, width, height, z1, z2);
    else if(arc.isSelected())
     g.drawArc(startX, startY, width, height, z1, z2);
   }//else  
  }//paint( )
 } //DrCanvas

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

2009년 7월 12일 일요일

Yasu 야수 1.6.9040 released

 

 

Yasu 1.6버전이 릴리즈 되었습니다.

 

Version History:

Modified Y.A.S.U for exclusive use of DAEMON-Tools devices

(Please copy YASU.exe to your DAEMON-Tools directory).

 

Created for DAEMON Tools Lite v4.30.3 (or newer, will NOT work with older versions).
 
 Current version of Y.A.S.U v1.6.9040 was tested with DAEMON Tools Lite v4.30.3 &
 DAEMON Tools Pro v4.30.304.47 with SPTD 1.56.

 Run Y.A.S.U click "Cloak" to hide your devices, run your game without any hassles
 from the protection scheme (SecuROM/SafeDisc).
 To restore your settings simply click "Uncloak" and/or close/quit Y.A.S.U.

 

실행 방법 :

1.  Damon-Tools가 인스톨 된 디렉토리에 Yasu.exe파일을 복사합니다.

2. Yasu.exe파일을 실행합니다.

3. Cloak버튼을 누른다음 게임을 실행 하면 됩니다.

USB 메모리에 CD영역 만들기 - UCDExec

이 글은 Furyheimdall 에 의해 furyheimdall.tistory.com 에서 작성되었습니다.

 

USB 메모리에 CD 영역을 만들 수 있는 프로그램입니다.

USB 메모리 일부를 CD 영역으로 할당하는 방식인데 바이오스 상태에서도 USB CD-ROM 으로 인식하기

때문에 윈도우 설치본을 넣어두거나 다른 CD미디어 자체를 요구하는데 매우 요긴합니다.

프로그램 자체는 USB 메모리 특성을 꽤나 타기 때문에 만약 이 프로그램으로 되지 않는다면

USBOFFICE.KR 에서 찾아보시기 바랍니다

프로그램 사용법은 프로그램을 실행하시면 나오는 창에서 ISO File 을 지정해주고 Burn을 하면

자동으로 영역이 할당되면서 지정한 이미지 내용이 별도의 CD_ROM 으로 인식하게 됩니다.
주의하실점은 포맷하게 되기 때문에 굽기(?)전에 꼭 기존 내용을 백업하세요.

현재 지원되는 모델은 어떤게 있는지 모르겠습니다만 제 USB 메모리 Zyrus 스윙캡 8GB 모델의 경우 지원이 되더군요.  제 경우는 Office.kr 에서 MDPT 를 사용하라고 했지만 오히려 그게 제 메모리를 인식하지 못해서 다른 프로그램을 찾다가 이 프로그램을 발견하게 되었습니다.

이 프로그램을 실행했을때 장치를 못찾았다고 하면 그건 지원되지 않는 모델이기 때문에 다른 프로그램을 찾아보세요.