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

📄 htmltable.java

📁 《湖泊生态的简单模拟》(Simulation Of Living Beings In A Lake )。这是我修读美国卡耐基梅隆大学Carnegie Mellon University(CMU)课程s
💻 JAVA
字号:
/**
 * Class that builds the HTML source for a HTML table element.
 *
 * @author	张维
 * @version 1.0.0
 */
public class HtmlTable {
	private boolean heading;
	private String tableBody;

	/**
	 *	Constructor : overloaded constructors
	 *
	 */
	public HtmlTable() {
		tableBody = "<TABLE>";
		heading = false;
	}

	public HtmlTable(int cp) {
		tableBody = "<TABLE cellpadding=" + cp + ">";
		heading = false;
	}

	/**
	 *  Add a header to the table
	 */
	public void addHeader(String colorValue) {
		tableBody = tableBody + "<THEAD bgcolor='" + colorValue + "'>";
		heading = true;
	}

	/**
	 *  Start building a row
	 */	
	public void startRow() {
		tableBody = tableBody + "<TR>";
	}

	/**
	 *  Stop building a row
	 */
	public void endRow() {
		tableBody = tableBody + "</TR>";
	}

	/**
	 *  Add a cell to an existing row
	 */
	public void addCell(String cellData) {
		tableBody = tableBody + "<TD>";
		tableBody = tableBody + cellData;
		tableBody = tableBody + "</TD>";
	}


	/**
	 *  Add a cell to an existing row
	 */
	public void addCell(String cellColor, String cellData) {
		tableBody = tableBody + "<TD bgcolor='" + cellColor + "'>";
		tableBody = tableBody + cellData;
		tableBody = tableBody + "</TD>";
	}

	/**
	 *  Construct the HTML source
	 */
	public String buildHtml() {
		if (heading)
			tableBody = tableBody + "</THEAD>";
			
		tableBody = tableBody + "</TABLE>";

		return tableBody;
	}
}

⌨️ 快捷键说明

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