java - jbutton not visible at start -
i working on gui sudoku. have app droid (sudokufree) , copy functionality , add 1 small feature (save board in progress, continue, , revert if desired). code has been commented out make more sscce, refer second post if have questions. 2 posts have helped me , borrowed code below them.
building gui sudoku solver (complete ascii example)
my problem jbuttons visible after scolled over. searched previous posts , found references setvisible(true), have done.
thank you
public class runsudokuninja implements runnable{ @override public void run() { //sudokuengineinterface sudokuengine = new sudokuengine(); sudokuview sudokuview = new sudokuview(); //sudokuview.setsudokuimplementation(sudokuengine); sudokuview.setvisible(true); } public static void main(string[] args) { eventqueue.invokelater(new runsudokuninja()); } } public class sudokuview extends jframe{ //sudokucontroller controller; //sudokuengine sudokuengine; private static final int width = 500; private static final int height = 650; private static final int ymar = 100; private static final int xmar = 25; private static final int cellsize = 40; private static final int gridspace = 3; private static final int secspace = 9; public jbutton[][] btnz = new jbutton[9][9]; public sudokuview() { //controller = new sudokucontroller(); //sudokuengine = new sudokuengine(); settitle("sudoku ninja 0.1"); setsize(width, height); setdefaultcloseoperation(jframe.exit_on_close); setlayout(null); setbackground(color.gray); int y=ymar; (int r=0;r<9;r++){ int x=xmar; (int c=0;c<9;c++){ btnz[r][c]=new jbutton("1"); btnz[r][c].setbounds(x,y,cellsize,cellsize); btnz[r][c].setvisible(true); add(btnz[r][c]); if (c==2||c==5){ x = x+cellsize+secspace; }else{ x = x+cellsize+gridspace; } } if (r==2||r==5){ y = y+cellsize+secspace; }else{ y = y+cellsize+gridspace; } } setvisible(true); } @override public void paint(graphics g){ } public void setsudokuimplementation(sudokuengineinterface listener) { //controller.setlistener(listener); } }
you overriding paint
method telling nothing, correct paint()
this:
public void paint(graphics g){ super.paint(g); //do whatever need here }
Comments
Post a Comment