Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HUDPane extends BorderPane implements Serializable {
- public HUDPane(Parent root) {
- setCenter(root);
- setTop(new MenuBar(new Menu("Pen") {{
- getItems().addAll(new Menu("Color") {{
- getItems().addAll(new MenuItem() {{
- setGraphic(new TilePane(2, 2) {{
- setPrefColumns(8);
- Color[] colors = {
- Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.CYAN, Color.PURPLE, Color.PINK,
- Color.WHEAT, Color.SANDYBROWN, Color.SADDLEBROWN, Color.BLACK, Color.DARKGRAY, Color.GRAY, Color.LIGHTGRAY, Color.WHITE
- };
- ObservableList<Node> children = getChildren();
- for (Color color : colors) {
- children.add(new Button() {{
- setMinSize(16, 16);
- setMaxSize(16, 16);
- setStyle("-fx-background-color: " + toHex(color) + ";");
- setOnAction(event -> penColor = color);
- }});
- }
- }});
- }});
- }}, new Menu("Size") {{
- getItems().addAll(new MenuItem() {{
- }});
- }});
- }}));
- }
- }
- public String toHex(Color color) {
- return String.format("#%02X%02X%02X",
- (int) (color.getRed() * 255),
- (int) (color.getGreen() * 255),
- (int) (color.getBlue() * 255));
- }
Advertisement
Add Comment
Please, Sign In to add comment