[Re] ¼Ò½º ÄÚµå


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

±Û¾´ÀÌ :À̼ºÈÆ 1999³â 12¿ù 02ÀÏ 21:22:06

In Reply to: °¡´ÉÇÏ´Ù¸é °¥Å° ÁÖ¼¼¿ä... posted by ÀÌÁ¾È¯ on 1999³â 12¿ù 01ÀÏ 22:11:57:

½ºÀ® ¹öÁ¯À̱ä ÇÏÁö¸¸,
´ë´äÀÌ µÉ¸¸ÇÑ ¼Ò½º¸¦ Á¦°¡ ¾ó¸¶Àü¿¡ ÀÌ°÷ °Ô½ÃÆÇ¿¡ ¿Ã·È´Âµ¥..
´Ù½Ã ¾Ë·Áµå¸®ÁÒ.
±è°Ç¿ì ´ÔÀÇ ¸»¾¸´ë·Î TextArea¿¡¼± ¾ÈµÇ±¸¿ä.
JTextPaneÀ» ¾²¸é µË´Ï´Ù.
Âü°íÀڷḦ Âü°íÇϼ¼¿ä.



/**
* Âü°íÀÚ·á : Swing (by Matthew Robinson and Pavel Vorobiev, Ph.D. -Manning Publications Co.)
*//
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;



public class JTextPaneDemo extends JFrame implements ActionListener{
static SimpleAttributeSet BLACK = new SimpleAttributeSet();
static SimpleAttributeSet RED = new SimpleAttributeSet();
static SimpleAttributeSet BLUE = new SimpleAttributeSet();
JTextPane m_editor = new JTextPane();
JTextField tf = new JTextField(20);
int i=0;


static { StyleConstants.setForeground(RED, Color.red);
StyleConstants.setForeground(BLUE, Color.blue);
StyleConstants.setForeground(BLACK, Color.black); }



public JTextPaneDemo() {
super("JTextPane Demo");
tf.addActionListener(this);
getContentPane().add(new JScrollPane(m_editor), BorderLayout.CENTER);
getContentPane().add(tf, BorderLayout.SOUTH);
setSize(500,450);
setVisible(true);
}



public void actionPerformed(ActionEvent ae) {
if( i == 0 ) { insertText( tf.getText() + "\n", RED); }
if( i == 1) { insertText( tf.getText() + "\n", BLACK); }
if( i == 2) { insertText( tf.getText() + "\n", BLUE); }
i++;
i %= 3;
}



protected void insertText(String text, AttributeSet set) {
try {
m_editor.getDocument().insertString( m_editor.getDocument().getLength(), text, set );
} catch (BadLocationException e) {
e.printStackTrace();
}
}



public static void main(String argv[]) {
new JTextPaneDemo();
}
}


´ÙÀ½ ±Ûµé:



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

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


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