tooltip - using CSS to change node design -
i dont know i'am doing wrong adding css style node.
i have main application window. click menu item , modal window opens below(modalwindow
extends stage
):
fxmlloader loader = new fxmlloader(getclass().getresource(constants.root_user_edit.string)); borderpane editpane; try { editpane = new borderpane(loader.load()); modalwindow editwindow = new modalwindow(main.mainstage, editpane, "edit user"); //its new stage new scene, need load file again editwindow.getscene().getstylesheets().add(getclass().getresource(constants.css_path.string).toexternalform()); userdata userdata = (userdata)userstable.getselectionmodel().getselecteditem(); usereditwindowcontroller usereditwindowcontroller = loader.getcontroller(); usereditwindowcontroller.fillwithdata(userdata); editwindow.initmodality(modality.application_modal); editwindow.showandwait(); } catch (ioexception exception) { exceptiondialog exceptiondialog = new exceptiondialog("couldn't load usereditwindow",exception); exceptiondialog.showandwait(); }
this css file added:
#greeninfotip { -fx-graphic-text-gap: 20; -fx-font-size: 44.0px ; -fx-background: green; -fx-background-color: rgb(128,255,128); }
and try in root controller class:
infotip.setid("greeninfotip");
but no effect. there i'm doing wrong?
edit itachiuchiha here precisely looks like:
method inside usereditwindowcontroller class:
@fxml private void buttsaveaction(actionevent event){ //check if login , password doesn't contain spaces , 4-16 characters long string login = textflogin.gettext(); string password = textfpassword.gettext(); boolean hasloginwhitespace = iscontainingwhitespace(login); boolean haspasswordwhitespace = iscontainingwhitespace(password); boolean isloginmorethan3 = (login.length() > 3)? true : false; boolean isloginlessthan17 = (login.length() < 17)? true : false; boolean ispasswordmorethan3 = (password.length() > 3)? true : false; boolean ispasswordlessthan17 = (password.length() < 17)? true : false; infotip infotip = new infotip(); if( hasloginwhitespace == false){ if( haspasswordwhitespace == false ){ if( isloginmorethan3 == true && isloginlessthan17 == true){ if( ispasswordmorethan3 == true && ispasswordlessthan17 == true ){ //========login , password correct string query = "update users set login = ?, password = ? employee_id = ?;"; try( connection connection = main.datasource.getconnection() ){ try( preparedstatement preparedstatement = connection.preparestatement(query) ){ preparedstatement.setstring(1, login); preparedstatement.setstring(2, password); preparedstatement.setint(3, currentuser.getid()); preparedstatement.executeupdate(); currentuser.setlogin(login); currentuser.setpassword(password); infotip.getinfotip().setid("greeninfotip"); infotip.showtip((button)event.getsource(), "saved"); } }catch(exception exception){ exceptiondialog exceptiondialog = new exceptiondialog("error while loading data database",exception); exceptiondialog.showandwait(); }; }else{ //password has less 4 or more 16 characters infotip.showtip(textfpassword, "no more 16 , no less 4 characters!"); } }else{ //login has less 4 or more 16 characters infotip.showtip(textflogin, "no more 16 , no less 4 characters!"); } }else{ //password has white space infotip.showtip(textfpassword, "no spaces!"); } }else{ //login has white space infotip.showtip(textflogin, "no spaces!"); } } public class infotip { private tooltip infotip; public infotip(){ infotip = new tooltip(); } private static point2d getnodepos(node node){ //getting node coordination on screen scene nodescene = node.getscene(); final point2d windowpos = new point2d(nodescene.getwindow().getx(), nodescene.getwindow().gety()); final point2d scenepos = new point2d(nodescene.getx(), nodescene.gety()); final point2d nodepos = node.localtoscene(0.0, 0.0); final point2d nodeposonscreen = new point2d(windowpos.getx() + scenepos.getx() + nodepos.getx(), windowpos.gety() + scenepos.gety() + nodepos.gety()); return nodeposonscreen; } public void showtip(node node, string text){ point2d nodeposonscreen = getnodepos(node); infotip = new tooltip(text); infotip.setfont(new font(15)); infotip.setopacity(0.9); infotip.setautofix(true); infotip.setautohide(true); infotip.show(node, nodeposonscreen.getx()-30, nodeposonscreen.gety() - 40); } public tooltip getinfotip(){ return infotip; } }
the issue with
infotip = new tooltip(text);
inside howtip(node node, string text)
.
you over-writing old tooltip id new object. try using
infotip.settext(text);