List of usage examples for javafx.scene.control ColorPicker ColorPicker
public ColorPicker()
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new HBox(20), 400, 100); HBox box = (HBox) scene.getRoot();//from ww w . j a v a 2 s. co m final ColorPicker colorPicker = new ColorPicker(); colorPicker.setValue(Color.RED); final Text text = new Text("Color picker:"); text.setFill(colorPicker.getValue()); colorPicker.setOnAction((ActionEvent t) -> { text.setFill(colorPicker.getValue()); }); box.getChildren().addAll(colorPicker, text); stage.setScene(scene); stage.show(); }
From source file:org.jacp.demo.perspectives.ContactPerspective.java
@PostConstruct /**/* w ww .j a v a 2s . c om*/ * create buttons in tool bars; menu entries */ public void PostConstructPerspective(final FXComponentLayout layout, final ResourceBundle resourceBundle) { LOGGER.debug("PostConstructPerspective ressource:" + resourceBundle); // create button in toolbar; button should switch top and bottom id's final JACPToolBar north = layout.getRegisteredToolBar(NORTH); final JACPToolBar south = layout.getRegisteredToolBar(SOUTH); final JACPToolBar west = layout.getRegisteredToolBar(WEST); final JACPToolBar east = layout.getRegisteredToolBar(EAST); final Button custom = new Button("switch"); custom.setTooltip(new Tooltip("Switch Components")); custom.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent e) { context.send(SWITCH_MESSAGE); } }); north.addOnEnd(context.getId(), custom); // TEST OPTIONBUTTON ON NORTH north.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10)); north.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10)); north.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10)); west.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT)); west.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT)); west.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT)); east.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT)); east.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT)); east.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT)); south.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP)); south.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP)); south.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP)); JACPHoverMenu menu = new JACPHoverMenu("Hovermenu", layout); VBox p = new VBox(); p.setPadding(new Insets(10)); Button b = new Button("HELLO"); CheckBox check = new CheckBox("checkbox"); p.getChildren().addAll(b, check); ColorPicker picker = new ColorPicker(); menu.getContentPane().getChildren().add(p); north.addToCenter(context.getId(), menu); north.addToCenter(context.getId(), picker); }
From source file:View.Visualize.java
public void getPieChartData(Integer nameColumn, Integer valueColumn, Table table, PieChart pieChart, Label lbl, Boolean newSeries, Boolean rowCounter) { data.clear();/*from ww w. j a va 2s. co m*/ if (!newSeries) { pieChart.getData().clear(); } addDataFromTable(table, nameColumn, valueColumn, rowCounter); data.entrySet().stream().map(entry -> new PieChart.Data(entry.getKey(), entry.getValue())) .forEach(pieChart.getData()::add); for (PieChart.Data d : pieChart.getData()) { //deretter legger vi animasjon p piecharten.. d.getNode().setOnMouseClicked(new mouseHooverAnimationPieChart.MouseHoverAnimation(d, pieChart)); final Node n = d.getNode(); Tooltip tooltip = new Tooltip(); String toolTipText = "Value : " + d.getPieValue(); tooltip.setText(toolTipText); Tooltip.install(n, tooltip); n.setOnMouseEntered(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(glow); } }); n.setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(null); } }); final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp); contextMenu.getItems().addAll(changeColor, delete); d.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { d.getNode().setStyle(""); } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); d.getNode().setStyle("-fx-background-color: " + hex1 + ";"); } }); contextMenu.show(d.getNode(), t.getScreenX(), t.getScreenY()); } } }); } }
From source file:View.Visualize.java
private void addColorChangeOnIndividual(ObservableList<XYChart.Data> data) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);//from w w w . j a v a2 s. com contextMenu.getItems().addAll(changeColor, delete); for (XYChart.Data d : data) { d.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { d.getNode().setStyle(""); } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); d.getNode().setStyle("-fx-background-color: " + hex1 + ";"); } }); contextMenu.show(d.getNode(), t.getScreenX(), t.getScreenY()); } } }); } }
From source file:View.Visualize.java
private void addColorChangeOnSeries(XYChart.Series series) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);// w w w. jav a2s . c o m contextMenu.getItems().addAll(changeColor, delete); Node d = series.getNode(); d.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle(""); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle(""); } } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle("-fx-fill:" + hex1 + ";"); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle("-fx-stroke:" + hex1 + ";"); } } }); contextMenu.show(d, t.getScreenX(), t.getScreenY()); } } }); }