1 18 19 package sync4j.syncclient.demo.logging; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Button ; 23 import java.awt.Panel ; 24 import java.awt.TextArea ; 25 import java.awt.event.ActionEvent ; 26 import java.awt.event.ActionListener ; 27 28 import sync4j.syncclient.common.logging.Handler; 29 30 import sync4j.syncclient.demo.Language; 31 import sync4j.syncclient.demo.MainWindow; 32 33 40 public class PanelHandler extends Panel 41 implements ActionListener , Handler { 42 43 45 47 private MainWindow mw = null ; 51 52 private TextArea syncLog = null ; 53 private Button butOk = null ; 54 55 private Language ln = new Language() ; 56 57 59 60 public void printMessage(String s) { 61 log(s); 62 } 63 64 69 public PanelHandler(MainWindow mw) { 70 71 this.mw = mw; 72 73 setLayout(new BorderLayout ()); 74 75 syncLog = new TextArea (); 76 syncLog.setEditable(false); 77 78 butOk = new Button (ln.getString ("ok") ) ; 79 butOk.setActionCommand ("ok" ) ; 80 butOk.addActionListener (this ) ; 81 butOk.setEnabled (false ) ; 82 83 add (syncLog , BorderLayout.CENTER ) ; 84 add (butOk , BorderLayout.SOUTH ) ; 85 86 } 87 88 93 public void actionPerformed(ActionEvent evt) { 94 if (evt.getActionCommand().equals("ok")) { 95 syncLog.setText(""); 96 mw.refresh(); 97 } 98 } 99 100 105 public void setButton(boolean value) { 106 butOk.setEnabled(value); 107 } 108 109 111 116 protected void log(String msg) { 117 syncLog.append(msg + "\n") ; 118 } 119 120 122 } | Popular Tags |