JDK 1.1ÀÇ InternationalizationÀ» »ç¿ëÇϼ¼¿ä..


[ Follow Ups ] [ Post Followup ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

Posted by À±°æ±¸ on May 09, 1997 at 13:55:29:

In Reply to: chatting & netedit ÇÁ·Î±×·¥»ó¿¡¼­ÀÇ ÇÑ±Û ÀÔÃâ·ÂÀº ¾î¶»°Ô? posted by ¶ó¼º±Ô on May 07, 1997 at 03:44:23:

ÀÚ¹Ù 1.0À¸·Î ÇÑ±Û ÀÔÃâ·ÂÀ» Á¦´ë·Î ±¸ÇöÇÏ´Â °ÍÀº »ó´çÈ÷ ±î´Ù·Ó½À´Ï´Ù.
ÇÏÁö¸¸ JDK 1.1À» »ç¿ëÇϸé ÇÑ±Û ÀÔÃâ·Â¿¡ º° ¹«¸®°¡ ¾ø½À´Ï´Ù.
¾Æ·¡ »çÀÌÆ®¸¦ ÂüÁ¶Çϼ¼¿ä.
Character streams in JDK 1.1
ÇÑ±Û ÆÄÀÏ ÀÔÃâ·ÂÀ» À§ÇØ ¿¹Àü¿¡ ²ôÀû°Å¸° ¼Ò½º°¡ À־ ÇÔ²² ¿Ã¸³´Ï´Ù.
FileWriter Ŭ·¡½º¸¦ ÀÌ¿ëÇÏ¿© test.txt ÆÄÀÏÀ» ¸¸µé¾î ¾²µµ·Ï ÇÏ°í ÀÖ½À´Ï´Ù.


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

public class DialogWindow extends Frame
implements ActionListener {
private boolean inAnApplet = true;
private SimpleDialog dialog;
private TextArea textArea;
private FileWriter fw;

public DialogWindow() {
textArea = new TextArea(5, 40);
textArea.setEditable(true);
add("Center", textArea);
Button button = new Button("Click to bring up dialog");
button.addActionListener(this);
Panel panel = new Panel();
panel.add(button);
add("South", panel);
// create new file and character stream
try {
fw=new FileWriter("test.txt", true /* append */);
} catch (IOException ie) {
System.out.println("File Writer creation err.");
}
// verify default encoding (Maybe KSC5601)
System.out.println("Encoding:"+fw.getEncoding());

addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
if (inAnApplet) {
dispose();
} else {
System.exit(0);
}
}
});
}

public void actionPerformed(ActionEvent event) {
if (dialog == null) {
dialog = new SimpleDialog(this, "A Simple Dialog");
}
dialog.setVisible(true);
}

public void setText(String text) {
textArea.append(text + "\n");
try {
fw.write(text);
fw.flush();
} catch (IOException ie) {
System.out.println("File write err.");
}
}

public static void main(String args[]) {
DialogWindow window = new DialogWindow();
window.inAnApplet = false;

window.setTitle("DialogWindow Application");
window.pack();
window.setVisible(true);
}
}

class SimpleDialog extends Dialog implements ActionListener {
TextField field;
DialogWindow parent;
Button setButton;

SimpleDialog(Frame dw, String title) {
super(dw, title, false);
parent = (DialogWindow)dw;

//Create middle section.
Panel p1 = new Panel();
Label label = new Label("Enter random text here:");
p1.add(label);
field = new TextField(40);
field.addActionListener(this);
p1.add(field);
add("Center", p1);

//Create bottom row.
Panel p2 = new Panel();
p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
Button b = new Button("Cancel");
b.addActionListener(this);
setButton = new Button("Set");
setButton.addActionListener(this);
p2.add(b);
p2.add(setButton);
add("South", p2);

//Initialize this dialog to its preferred size.
pack();
}

public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if ( (source == setButton)
| (source == field)) {
parent.setText(field.getText());
}
field.selectAll();
setVisible(false);
}
}





Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]