java - JTextField is under image when a new image is loaded -
currently problem have whenever load new image changes jtextfield setvisible true staying behind image , appears if highlight mouse.
the time appears how want first time run program, on first image.
in specific situation problem occurring when go "enter amount deposit/withdraw:". works on first run first time go enter account number.
also, anytime setting visibility true setting opaque true well.
this looks when go new image http://imgur.com/s6aagn8
for reference here code (warning: messy):
@override public void actionperformed(actionevent e) { //jtf.setvisible(false); string str = ""; if (screen == screen.welcome_screen) { screen = screen.enter_acc_screen; numberstring = ""; jtf.setvisible(true); jtf.setopaque(true); repaint(); } if (screen == screen.enter_acc_screen) { jtf.setvisible(true); jtf.setbounds(220, 350, 200, 35); jtf.setopaque(true); if (e.getsource() == bp) { if (cdata.customerlist(numberstring) != null) { screen = screen.main_buttons; repaint(); } else { joptionpane jop = new joptionpane(); jop.showmessagedialog(panel1, "\tinvalid account number.\nno such account exits.\nplease re-enter account number.\n"); numberstring = ""; } } } if (screen == screen.main_buttons) { jtf.setvisible(false); if (e.getsource().equals(l1)) { screen = screen.acc_info_screen; jtextfield checkbal = new jtextfield(); jtextfield savebal = new jtextfield(); double temp = cdata.checkbal(numberstring); string check = string.valueof(temp); panelmain.add(checkbal, borderlayout.center); checkbal.settext(check); checkbal.seteditable(false); checkbal.setvisible(true); checkbal.setfont(new font("arial",1,25)); checkbal.setbounds(340, 125, 200, 25); double temp2 = cdata.savebal(numberstring); string check2 = string.valueof(temp2); panelmain.add(savebal, borderlayout.center); savebal.settext(check2); savebal.seteditable(false); savebal.setvisible(true); savebal.setfont(new font("arial",1,25)); savebal.setbounds(340, 239, 200, 25); repaint(); } else if (e.getsource().equals(l2)) { repaint(); } else if (e.getsource().equals(l3)) { screen = screen.welcome_screen; repaint(); } else if (e.getsource().equals(r1)) { screen = screen.withdraw_screen; repaint(); } else if (e.getsource().equals(r2)) { screen = screen.deposit_screen; repaint(); } else if (e.getsource().equals(r3)) { screen = screen.transfer_screen; repaint(); } } if (screen == screen.acc_info_screen) { if (e.getsource() == l3) { screen = screen.main_buttons; repaint(); } } if (screen == screen.withdraw_screen_2) { if (e.getsource() == l3) { screen = screen.main_buttons; numberstring = ""; repaint(); } } if (screen == screen.enter_acc_screen || screen == screen.withdraw_screen || screen == screen.deposit_screen || screen == screen.transfer_screen || screen == screen.withdraw_screen_2 || screen == screen.transaction) { jtf.setfont(new font("arial",1,25)); jtf.setactioncommand("enter"); jtf.addactionlistener(this); jtf.setvisible(true); string actioncommand = e.getactioncommand(); if (screen == screen.transaction) { if (e.getsource() == r1) { screen = screen.main_buttons; numberstring = ""; repaint(); } else if (e.getsource()== r2) { screen = screen.welcome_screen; numberstring = ""; repaint(); } } if (screen == screen.withdraw_screen) { if (e.getsource() == l1) { screen = screen.withdraw_screen_2; numberstring = ""; jtf.setbounds(390, 90, 200, 50); repaint(); jtf.setvisible(true); jtf.setopaque(true); if (e.getsource() == bp) { int wamount = integer.parseint(numberstring); cdata.subtractcheckbal(numberstring, wamount); screen = screen.transaction; repaint(); if (e.getsource().equals(r1)) { screen = screen.main_buttons; repaint(); } else if (e.getsource().equals(r2)) { screen = screen.welcome_screen; repaint(); } } } else if (e.getsource() == l2) { screen = screen.withdraw_screen_2; repaint(); jtf.setvisible(true); jtf.setopaque(true); numberstring = ""; jtf.setbounds(390, 90, 200, 50); if (e.getsource() == bp) { int wamount = integer.parseint(numberstring); cdata.subtractsavebal(numberstring, wamount); screen = screen.transaction; repaint(); if (e.getsource().equals(r1)) { screen = screen.main_buttons; repaint(); } else if (e.getsource().equals(r2)) { screen = screen.welcome_screen; repaint(); } } } else if (e.getsource() == l3) { screen = screen.main_buttons; repaint(); } } if (screen == screen.deposit_screen) { if (e.getsource() == l1) { screen = screen.withdraw_screen_2; jtf.setvisible(true); jtf.setopaque(true); numberstring = ""; jtf.setbounds(390, 90, 200, 50); repaint(); if (e.getsource() == bp) { int damount = integer.parseint(numberstring); cdata.addcheckbal(numberstring, damount); screen = screen.transaction; repaint(); if (e.getsource().equals(r1)) { screen = screen.main_buttons; repaint(); } else if (e.getsource().equals(r2)) { screen = screen.welcome_screen; repaint(); } } } else if (e.getsource() == l2) { screen = screen.withdraw_screen_2; repaint(); jtf.setvisible(true); jtf.setopaque(true); jtf.setbounds(390, 90, 200, 50); repaint(); if (e.getsource() == bp) { int damount = integer.parseint(numberstring); cdata.addsavebal(numberstring, damount); screen = screen.transaction; repaint(); if (e.getsource().equals(r1)) { screen = screen.main_buttons; repaint(); } else if (e.getsource().equals(r2)) { screen = screen.welcome_screen; repaint(); } } } else if (e.getsource().equals(l3)) { screen = screen.main_buttons; repaint(); } } if (screen == screen.transfer_screen) { if (e.getsource() == l1) { // transfer checking savings screen = screen.withdraw_screen_2; repaint(); jtf.setvisible(true); jtf.setopaque(true); jtf.setbounds(390, 90, 200, 50); if (e.getsource() == bp) { int damount = integer.parseint(numberstring); cdata.addsavebal(numberstring, damount); cdata.subtractcheckbal(numberstring, damount); screen = screen.transaction; repaint(); if (e.getsource().equals(r1)) { screen = screen.main_buttons; repaint(); } else if (e.getsource().equals(l2)) { screen = screen.welcome_screen; } } } else if (e.getsource() == l2) { // transfer savings checking screen = screen.withdraw_screen_2; repaint(); jtf.setvisible(true); //jtf.setbounds int damount = integer.parseint(numberstring); cdata.addcheckbal(numberstring, damount); cdata.subtractsavebal(numberstring, damount); screen = screen.transaction; repaint(); if (e.getsource().equals(r1)) { screen = screen.main_buttons; repaint(); } else if (e.getsource().equals(l2)) { screen = screen.welcome_screen; } } else if (e.getsource().equals(l3)) { screen = screen.transfer_screen; repaint(); jtf.setvisible(false); } } if (e.getsource() == b1) { numberstring += "1"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b2) { numberstring += "2"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b3) { numberstring+= "3"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b4) { numberstring+= "4"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b5) { numberstring+= "5"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b6) { numberstring+= "6"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b7) { numberstring+= "7"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b8) { numberstring+= "8"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b9) { numberstring+= "9"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == b0) { numberstring+= "0"; jtf.settext(numberstring); repaint(); } else if (e.getsource() == ba) { // clear button // clear previous entry if (numberstring.length() > 0) { numberstring = numberstring.substring(0, numberstring.length() - 1); } jtf.settext(numberstring); repaint(); } }
Comments
Post a Comment