java - Jtable not showing? -
the table won't show in window. theres outline, no grid! please help!
tetris.java
package com.diesal11; import com.diesal11.board; import java.awt.borderlayout; import javax.swing.jframe; import javax.swing.jscrollpane; public class tetris extends jframe{ private static final long serialversionuid = 1l; public tetris() { this.setsize(200, 400); // this.setresizable(false); this.settitle("tetris"); this.setdefaultcloseoperation(exit_on_close); board board = new board(this); jscrollpane scrollpane = new jscrollpane(board); this.add(scrollpane, borderlayout.center); } public static void main(string[] args) { tetris game = new tetris(); game.setlocationrelativeto(null); game.setvisible(true); } } board.java
package com.diesal11; import javax.swing.jpanel; import javax.swing.jtable; public class board extends jpanel{ private static final long serialversionuid = 1l; tetris parent; int boardwidth = 10; int boardheight = 20; jtable table; public board(tetris parent){ // setfocusable(true); this.parent = parent; this.table = new jtable(this.boardwidth, this.boardheight); this.table.setvalueat("aaa", 0, 0); this.table.setautoresizemode(jtable.auto_resize_off); this.table.getcolumnmodel().getcolumn(1).setheadervalue("test"); } } thanks in advance! im new java apologies if it's simple!
you should add table jpanel:
.... this.table.setautoresizemode(jtable.auto_resize_off); this.table.getcolumnmodel().getcolumn(1).setheadervalue("test"); this.add(table); also, convention start variable names lower case letter.
Comments
Post a Comment