Changeset 25709
- Timestamp:
- 12/02/08 22:47:53 (5 weeks ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/java/IRCKit/trunk/src/com/mac/tarchan/irc/client/IRCConsole.java
r25708 r25709 21 21 import javax.swing.JTextField; 22 22 import javax.swing.JTextPane; 23 import javax.swing.text.AttributeSet;24 23 import javax.swing.text.BadLocationException; 24 import javax.swing.text.Style; 25 import javax.swing.text.StyleContext; 25 26 import javax.swing.text.StyledDocument; 26 27 … … 33 34 { 34 35 /** 35 * @param args 36 * チャットコンソールを起動します。 37 * 38 * @param args 引数 36 39 */ 37 40 public static void main(String[] args) … … 39 42 IRCConsole console = new IRCConsole(); 40 43 console.createChatWindow(); 41 //console.test();44 console.test(); 42 45 } 46 47 /** 改行コード */ 48 protected final String LF = System.getProperty("line.separator"); 49 50 /** ドキュメント */ 51 protected StyledDocument doc; 52 53 /** 表示スタイル */ 54 protected Style style = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); 43 55 44 56 /** … … 53 65 textPane.setEditable(false); 54 66 textPane.setPreferredSize(new Dimension(320, 240)); 55 final StyledDocument doc = textPane.getStyledDocument(); 56 final String LF = System.getProperty("line.separator"); 67 doc = textPane.getStyledDocument(); 57 68 58 69 // スクロールパネル … … 66 77 public void actionPerformed(ActionEvent evt) 67 78 { 68 try 69 { 70 // 入力テキストを取得 71 String str = evt.getActionCommand(); 79 // 入力テキストを取得 80 String str = evt.getActionCommand(); 72 81 73 // 入力フィールドをクリア74 textField.setText("");82 // 入力フィールドをクリア 83 textField.setText(""); 75 84 76 // 表示エリアに1行追加 77 AttributeSet style = null; 78 doc.insertString(doc.getLength(), str + LF, style); 79 // textPane.setCaretPosition(doc.getLength()); 80 } 81 catch (BadLocationException e) 82 { 83 e.printStackTrace(); 84 } 85 // 表示エリアに1行追加 86 appendLine(str); 85 87 } 86 88 }); … … 103 105 104 106 /** 107 * 指定された文字列を表示エリアに追加します。 108 * 109 * @param str 文字列 110 */ 111 public void appendLine(String str) 112 { 113 try 114 { 115 // 表示エリアに1行追加 116 doc.insertString(doc.getLength(), str + LF, style); 117 // textPane.setCaretPosition(doc.getLength()); 118 } 119 catch (BadLocationException e) 120 { 121 e.printStackTrace(); 122 } 123 } 124 125 /** 105 126 * IRCKitの接続テスト 106 127 */ 107 128 public void test() 108 129 { 109 System.out.println("Welcome to IRCKit!");130 appendLine("Welcome to IRCKit!"); 110 131 try 111 132 { … … 122 143 { 123 144 // TODO 受信したメッセージを表示 145 appendLine(msg.toString()); 124 146 } 125 147 });
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)