📄 htmltable.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 + -