private Label createNoMatchingUsersLabel() { Label noMatchingUsersLabel = new Label(MESSAGE_NO_MATCHES); noMatchingUsersLabel.setPrefHeight(40); noMatchingUsersLabel.setPrefWidth(398); noMatchingUsersLabel.setAlignment(Pos.CENTER); return noMatchingUsersLabel; }
private Label createNoExistingAssigneeLabel() { Label noExistingAssignee = new Label(MESSAGE_NO_ASSIGNEE); noExistingAssignee.setPrefHeight(40); FontLoader fontLoader = Toolkit.getToolkit().getFontLoader(); double width = fontLoader.computeStringWidth(noExistingAssignee.getText(), noExistingAssignee.getFont()); noExistingAssignee.setPrefWidth(width); return noExistingAssignee; }
private void adjustWorkspace() { final Bounds backgroundBounds, extensionBounds; final Object userSceneGraph; if (fxomDocument == null) { userSceneGraph = null; } else { userSceneGraph = fxomDocument.getSceneGraphRoot(); } if ((userSceneGraph instanceof Node) && (layoutException == null)) { final Node rootNode = (Node) userSceneGraph; final Bounds rootBounds = rootNode.getLayoutBounds(); if (rootBounds.isEmpty() || (rootBounds.getWidth() == 0.0) || (rootBounds.getHeight() == 0.0)) { backgroundBounds = new BoundingBox(0.0, 0.0, 0.0, 0.0); extensionBounds = new BoundingBox(0.0, 0.0, 0.0, 0.0); } else { final double scale; if ((rootBounds.getDepth() > 0) && autoResize3DContent) { // Content is 3D final double scaleX = AUTORESIZE_SIZE / rootBounds.getWidth(); final double scaleY = AUTORESIZE_SIZE / rootBounds.getHeight(); final double scaleZ = AUTORESIZE_SIZE / rootBounds.getDepth(); scale = Math.min(scaleX, Math.min(scaleY, scaleZ)); } else { scale = 1.0; } contentGroup.setScaleX(scale); contentGroup.setScaleY(scale); contentGroup.setScaleZ(scale); final Bounds contentBounds = rootNode.localToParent(rootBounds); backgroundBounds = new BoundingBox( 0.0, 0.0, contentBounds.getMinX() + contentBounds.getWidth(), contentBounds.getMinY() + contentBounds.getHeight()); final Bounds unclippedRootBounds = computeUnclippedBounds(rootNode); assert unclippedRootBounds.getHeight() != 0.0; assert unclippedRootBounds.getWidth() != 0.0; assert rootNode.getParent() == contentGroup; final Bounds unclippedContentBounds = rootNode.localToParent(unclippedRootBounds); extensionBounds = computeExtensionBounds(backgroundBounds, unclippedContentBounds); } } else { backgroundBounds = new BoundingBox(0.0, 0.0, 320.0, 150.0); extensionBounds = new BoundingBox(0.0, 0.0, 0.0, 0.0); } backgroundPane.setPrefWidth(backgroundBounds.getWidth()); backgroundPane.setPrefHeight(backgroundBounds.getHeight()); extensionRect.setX(extensionBounds.getMinX()); extensionRect.setY(extensionBounds.getMinY()); extensionRect.setWidth(extensionBounds.getWidth()); extensionRect.setHeight(extensionBounds.getHeight()); contentSubScene.setWidth(contentGroup.getLayoutBounds().getWidth()); contentSubScene.setHeight(contentGroup.getLayoutBounds().getHeight()); }
@Override public void start(Stage primaryStage) throws Exception { GridPane grid = new GridPane(); // grid.setAlignment(Pos.CENTER); Label display = new Label(); display.setText("Display"); display.setPrefHeight(50); display.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); Button[] buttons = new Button[16]; CalculatorButton[] buttonPressed = new CalculatorButton[] { newButton("7", Element.OPERAND), newButton("8", Element.OPERAND), newButton("9", Element.OPERAND), newButton("+", Element.OPERATOR), newButton("4", Element.OPERAND), newButton("5", Element.OPERAND), newButton("6", Element.OPERAND), newButton("-", Element.OPERATOR), newButton("1", Element.OPERAND), newButton("2", Element.OPERAND), newButton("3", Element.OPERAND), newButton("*", Element.OPERATOR), newButton("DEL", Element.CLEANER), newButton("0", Element.OPERAND), newButton("=", Element.OPERATOR), newButton("/", Element.OPERATOR), }; for (int i = 0; i < buttons.length; i++) { if (i % 4 == 0) rows++; buttons[i] = new Button(); buttons[i].setPrefSize(50, 50); buttons[i].setText(buttonPressed[i].getButtonValue()); final int finalI = i; buttons[i].setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { switch (buttonPressed[finalI].getElementType()) { case CLEANER: display.setText("0"); firstValue = ""; secondValue = ""; hasOperator = false; operatorString = ""; break; case OPERAND: if (hasOperator) { secondValue += buttonPressed[finalI].getButtonValue(); display.setText(secondValue); } else { firstValue += buttonPressed[finalI].getButtonValue(); display.setText(firstValue); } break; case OPERATOR: if (hasOperator) { if (firstValue.length() > 0 && secondValue.length() > 0) { display.setText( Integer.toString( brain.operation(firstValue, operatorString, secondValue))); firstValue = Integer.toString( brain.operation(firstValue, operatorString, secondValue)); operatorString = buttonPressed[finalI].getButtonValue(); secondValue = ""; } else { operatorString = buttonPressed[finalI].getButtonValue(); } System.out.println("has operator"); } else { if (firstValue.length() > 0) { operatorString = buttonPressed[finalI].getButtonValue(); hasOperator = true; display.setText(operatorString); System.out.println("first operator"); } else { preOperator = buttonPressed[finalI].getButtonValue(); } } break; } System.out.println( "first value: " + firstValue + " operator: " + operatorString + " second value: " + secondValue); } }); grid.add(buttons[i], i % 4, rows); } grid.add(display, 0, 0, 4, 1); Scene scene = new Scene(grid); primaryStage.setTitle("Calculator"); primaryStage.setScene(scene); primaryStage.show(); }
public entryView(Object object) { getChildren().clear(); getStylesheets().add("css/entryView.css"); giveNode(object); BorderPane mainpane = new BorderPane(); BorderPane centerpane = new BorderPane(); BorderPane bottompane = new BorderPane(); GridPane divgrid = new GridPane(); GridPane maingrid = new GridPane(); Label emptylab = new Label(); Label divlab = new Label(); VBox options = new VBox(); VBox tlist = new VBox(); Button ok = new Button("ok"); Periods periods = new Periods(); TList loadteacher = new TList(); DatePicker date = new DatePicker(); BorderPane datepane = new BorderPane(); BorderPane nextpane = new BorderPane(); Button next = new Button("next"); options.setId("options"); tlist.setId("tlist"); divgrid.setId("divgrid"); bottompane.setId("bottompane"); periods.setId("period"); divlab.setId("divlabel"); datepane.setId("datepane"); nextpane.setId("nextpane"); emptylab.setPrefHeight(100); bottompane.setStyle("-fx-background-color:#ecf0f1;"); StringConverter converter = new StringConverter<LocalDate>() { DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); @Override public String toString(LocalDate date) { if (date != null) { return dateFormatter.format(date); } else { return ""; } } @Override public LocalDate fromString(String string) { if (string != null && !string.isEmpty()) { return LocalDate.parse(string, dateFormatter); } else { return null; } } }; date.setConverter(converter); date.setPromptText("dd-MM-yyyy".toLowerCase()); date.setValue(LocalDate.now()); maingrid = div.loadDiv(); list = (ListView) div.takelist(); periods.period(); list.getSelectionModel().select(0); divlab.setText((String) list.getItems().get(0)); list.setOnMouseClicked( e -> { divlab.setText((String) list.getSelectionModel().getSelectedItem()); periods.getChildren().clear(); periods.period(); }); final Node node = maingrid.getChildren().get(0); Platform.runLater( new Runnable() { @Override public void run() { node.requestFocus(); } }); next.setOnAction( e -> { // list.getSelectionModel().getSelectedIndex()+1 list.getSelectionModel().select(list.getSelectionModel().getSelectedIndex() + 1); divlab.setText((String) list.getSelectionModel().getSelectedItem()); }); nextpane.setRight(next); datepane.setRight(date); options.getChildren().clear(); options.getChildren().add(maingrid); divgrid.setHgap(5); // divgrid.add(emptylab, 0, 1); divgrid.add(datepane, 1, 0); divgrid.add(divlab, 0, 2); divgrid.add(periods, 1, 2); divgrid.add(nextpane, 1, 3); divgrid.setAlignment(Pos.TOP_CENTER); mainpane.setCenter(centerpane); mainpane.setLeft(options); mainpane.setRight(loadteacher); centerpane.setCenter(divgrid); centerpane.setBottom(bottompane); bottompane.setRight(ok); addCloseButton cb = new addCloseButton(); cb.addxb(1); setTop(cb); setCenter(mainpane); }