javascript.JSObject ¿¹Á¦..


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :¿ìÈñ¼º 2000³â 3¿ù 07ÀÏ 05:08:24

In Reply to: ¾ÖÇø´¿¡¼­ ½ºÅ©¸³Æ® ÇÔ¼ö È£Ãâ!! posted by °­Áö°æ on 2000³â 3¿ù 06ÀÏ 16:00:13:

==================================================
Ȥ½Ã Àúó·³ °í»ýÇϽô ºÐ °è½Ç±îºÁ ¿¹Á¦¸¦ ¿Ã¸³´Ï´Ù.
netscape.javascript.JSObject;´Â ³Ý½ºÄÉÀÌÇÁ¸¦ ¼³Ä¡ÇÏ
½Ã°í ã±â Çغ¸½Ã¸é ³ª¿É´Ï´Ù.
==================================================



¿¹Á¦: MatchColor.java
1 import java.applet.Applet;
2 import java.awt.*;
3 import java.awt.event.*;
4 import netscape.javascript.JSObject;
5
6 public class MatchColor extends Applet implements ActionListener {
7 Button red, yellow, blue;
8 JSObject window, document;
9
10 public void init() {
11 setLayout(new BorderLayout());
12 Panel bottom = new Panel();
13 red = new Button("RED");
14 red.addActionListener(this);
15 yellow = new Button("YELLOW");
16 yellow.addActionListener(this);
17 blue = new Button("BLUE");
18 blue.addActionListener(this);
19
20 bottom.add(red);
21 bottom.add(yellow);
22 bottom.add(blue);
23 add("South", bottom);
24 window = JSObject.getWindow(this);
25 document = (JSObject)window.getMember("document");
26 setButtonColor();
27 changeColor();
28 }
29 protected void setButtonColor() {
30 red.setForeground(Color.red);
31 yellow.setForeground(Color.yellow);
32 blue.setForeground(Color.blue);
33 }
34
35 protected void changeColor() {
36 String pageColor = (String)document.getMember("bgColor");
37 int bgColor = Integer.parseInt(pageColor.substring(1, 7), 16);
38 setBackground(new Color(bgColor));
39 }
40
41 public void paint(Graphics g) {
42 Font f = new Font("Courier", Font.BOLD, 36);
43 g.setFont(f);
44 g.setColor(Color.white);
45 g.drawString("Hello ^_*", 25, 25);
46 }
47
48 public void actionPerformed(ActionEvent e) {
49 setButtonColor();
50 Component c = (Component) e.getSource();
51 if(c == red) {
52 String args[] = new String[1];
53 args[0] = "#FF0000";
54 red.setForeground(Color.black);
55 window.call("setBackground", args);
56 } else if(c == yellow) {
57 String args[] = new String[1];
58 args[0] = "#FFFF00";
59 yellow.setForeground(Color.black);
60 window.call("setBackground", args);
61 } else if(c == blue) {
62 String args[] = new String[1];
63 args[0] = "#0000FF";
64 blue.setForeground(Color.black);
65 window.call("setBackground", args);
66 }
67 changeColor();
68 }
69 }





´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]