java - Immovable alert window -
i'm trying stop users being able move alert pops up. have found 1 option set style undecorated
remove border click on move alert, think looks ugly.
are there other options?
i suggest going stagestyle.undecorated
, adding decoration want inside.
not having system decoration, in case, benefit. because people used standard controls (close button, moving dragging title, etc) , removing them give clear sign don't want windows movable.
small example:
stage alert = new stage(stagestyle.undecorated); alert.initmodality(modality.application_modal); vbox root = new vbox(30); root.setstyle("-fx-background-color: antiquewhite"); root.setalignment(pos.center); root.setpadding(new insets(25)); root.setborder(new border(new borderstroke(color.black, borderstrokestyle.solid, cornerradii.empty, borderwidths.default))); button btn = new button("got it!"); btn.setonaction((e)-> {alert.close();}); label label = new label("alert!"); label.setfont(font.font("verdana", 20)); root.getchildren().addall(label, btn); alert.setscene(new scene(root, 200, 150));
which gives next window:
Comments
Post a Comment