package e4s.tutorial; import e4s.html.*; import e4s.servlet.*; import java.io.*; // import java.awt.*; import java.util.*; import java.text.*; import java.net.*; import java.sql.*; /** * Using <TABLE>-tags. A TABLE tag is created based on other HTML tags, e.g. the <HTML> or * <BODY>-tags. Based on the TABLE tag, you can create TR elements and based on these you create * your TD elements. Output can be sent directly using the print(String) or println(String) function * to the TD elements, or you construct further elements within the TD cells. * * {@tutorial Example_Table} */ public class Example_Table extends E4ModuleImplementation { public static E4Method start = null; public void start(HTML html) { html.setTitle("Table Example"); TABLE table1 = html.TABLE(); table1.setBorder(); table1.setBgColor(new E4Color(0x80,0xFF,0xFF)); for(int r = 1; r < 5; r++ ) { TR tablerow = table1.TR(); if (r == 1) tablerow.setBgColor(E4Color.GREEN); for( int c = 1; c <= 4; c++ ) { TD tablecell = tablerow.TD(); if (c == 3) tablecell.setBgColor(E4Color.BLUE); tablecell.print("row " + r + " col " + c); } } html.P(); TABLE table2 = html.TABLE(); table2.setBorder(); table2.setWidth(0.9f); TR tr = table2.TR(); tr.TD().println("This is a text in a cell, and a table in a cell beside"); TABLE table3 = tr.TD().TABLE(); table3.setBorder(); table3.setCellspacing(0,0); TR row1 = table3.TR(); row1.TD().println("A1"); row1.TD().println("A_Multiple"); TR row2 = table3.TR(); row2.TD().println("B1"); row2.TD().println("B2"); } }