⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gaalog.java

📁 Java实现的遗传算法工具集:GA Playground
💻 JAVA
字号:
import java.awt.*;
import java.util.Date;

public class GaaLog extends Frame implements java.awt.event.WindowListener

{
  TextArea ta;
  public static boolean inLog;
  Date StartDate, EndDate;
  Font font;


  public GaaLog(String title)
  {
    super(title);
    addWindowListener(this);

		font = new Font("Courier",Font.PLAIN,12);
		
    ta = new TextArea(50,100);
    ta.setText("");
    ta.setFont(font);
    setLayout(new BorderLayout());
    add("Center", ta);
    inLog = true;
    
    this.pack();
    //show();
  }


  public void start()
  {
		StartDate = new Date();
		if (inLog)
	    ta.appendText("Session Started at: " + StartDate.toString()+"\n\n");
  }


  public void end()
  {
		EndDate = new Date();
		if (inLog)
	    ta.appendText("End at: " + EndDate.toString());
  }


	public void setFont(Font f) {
		
		ta.setFont(f);
		
	}

	public void setForeground(Color c) {
		
		ta.setForeground(c);
		
	}
			
		
	public String getText() {
		
		return ta.getText();
		
	}
	
	
  public void showMsg(String msg)
  {
			ta.appendText(msg + '\n');
  }


  public void debug(String msg)
  {
		if (inLog)
			try {
				ta.appendText(msg + '\n');
			}
			catch (Exception e) {
				String t = e.toString();
			}
  }


  public void showMsg(Object obj)
  {
		if (inLog)
	    ta.appendText(String.valueOf(obj) + '\n');
  }


  public void showMsg(int n)
  {
		if (inLog)
	    ta.appendText(String.valueOf(n) + '\n');
  }


  public void clear()
  {
		if (inLog)
			ta.setText("");
  }


  public void clear(String msg)
  {
		if (inLog)
	    ta.setText(msg);
  }
  
  
    public void windowClosing(java.awt.event.WindowEvent ev)
    {
    	hide();
    }
    
    public void windowClosed(java.awt.event.WindowEvent ev)
     {}
    public void windowActivated(java.awt.event.WindowEvent ev)
    {}
    public void windowDeactivated(java.awt.event.WindowEvent ev)
    {}
    public void windowOpened(java.awt.event.WindowEvent ev)
    {}
    public void windowIconified(java.awt.event.WindowEvent ev)
    {}
    public void windowDeiconified(java.awt.event.WindowEvent ev)
    {}
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -