public class MyTable1 extends JFrame { MyTable1 mytable; Object[][] data; JTable tb; JScrollPane scp; int MAXH=100,MAXC=100; public MyTable1() { // Header names String[] Colnames = {"Index", "Time","Tem","Hum","Rain","Wind","Level"}; //Col index data = new Object[MAXH][MAXC]; for(int j=0;j<=MAXH-1;j++){ data[j][0]=j+1; } // Col Time Date tg = new Date(); final SimpleDateFormat TimeFormat = new SimpleDateFormat(" dd/MM/yyyy HH:mm:ss"); for(int j=0;j<=MAXH-1;j++){ data[j][1]=TimeFormat.format(tg.getTime()); } //Col Temperature Random rand = new Random(); for(int j=0;j<=MAXH-1;j++){ int value = rand.nextInt(30)+10; data[j][2]=value; } //Col Humidity for(int j=0;j<=MAXH-1;j++){ int value = rand.nextInt(80)+20; data[j][3]=value; } //Col Rain for(int j=0;j<=MAXH-1;j++){ int value = rand.nextInt(2); if (value == 1){ data[j][4]="Rain";} else data[j][4] = "Not"; } //Col wind speed for(int j=0;j<=MAXH-1;j++){ int value = rand.nextInt(9)+1; data[j][5]=value; } tb = new JTable(data, Colnames); tb.setFillsViewportHeight(true); scp = new JScrollPane(tb); ...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)