public FillPicker(Main manager) { super("X"); this.manager = manager; setPrefWidth(25); setPrefHeight(25); selectedFill = FlatColor.RED; try { popup = buildPanel(); popup.setVisible(false); popupadded = false; } catch (IOException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } }
@Override protected void setPressed(boolean pressed) { super.setPressed(pressed); if (pressed) { if (!popupadded) { Stage stage = getParent().getStage(); stage.getPopupLayer().add(popup); } Point2D pt = NodeUtils.convertToScene(this, 0, getHeight()); popup.setTranslateX(Math.round(Math.max(pt.getX(), 0))); popup.setTranslateY(Math.round(Math.max(pt.getY(), 0))); popup.setVisible(true); EventBus.getSystem().setPressedNode(popup); } else { // popup.setVisible(false); } }
public void hidePopups() { if (popup != null && popup.isVisible()) { popup.setVisible(false); } }