Rectangle[] arr = new Rectangle[10]; for(int i = 0; i < 10; i++) { Rectangle r = new Rectangle(); r.setWidth((Math.random()*40)+10); r.setHeight((Math.random()*40)+10); arr[i] = r; }
Rectangle clip = new Rectangle(); product.layoutBoundsProperty().addListener((observable, oldValue, newValue) -> { clip.setWidth(newValue.getWidth()); clip.setHeight(newValue.getHeight()); }); product.setClip(clip);
public void foo(final Rectangle r) { r.setWidth(12); System.out.println(r.getWidth() + ", " + r.getHeight()); } final Square s = new Square(5); foo(s);
for (int row = 0; row < rowNum; row++) { for (int col = 0; col < colNum; col++) { int n = rand.nextInt(4); Rectangle rec = new Rectangle(); rec.setWidth(2); rec.setHeight(2); rec.setFill(colors[n]); GridPane.setRowIndex(rec, row); GridPane.setColumnIndex(rec, col); grid.getChildren().addAll(rec); } }
public static void main(String[] args) { ArrayList<Shape> shapeArr = new ArrayList<Shape>(4); Circle c = new Circle(); c.setRadius(10); Rectangle r = new Rectangle(); r.setHeight(10); r.setWidth(5); shapeArr.add(c); shapeArr.add(r); }
public void handle(MouseEvent mouseEvent) { Rectangle rect = new Rectangle(); rect.setWidth(RECTANGLE_DEFAULT_WIDTH); rect.setHeight(RECTANGLE_DEFAULT_HEIGHT); rect.setFill(null); rect.setStroke(Color.BLACK); Text text = new Text("mockText"); StackPane stackPane = new StackPane(); stackPane.getChildren().addAll(rect, text); stackPane.setLayoutX(mouseEvent.getX()); stackPane.setLayoutY(mouseEvent.getY()); root.getChildren().add(stackPane); }
Image p = new Image("Peices/Black/0.png"); ImagePattern pat = new ImagePattern(p); Rectangle r1 = new Rectangle(); r1.setX(50); r1.setY(50); r1.setWidth(50); r1.setHeight(50); r1.setFill(pat); Rectangle r = new Rectangle(); r.setX(50); r.setY(50); r.setWidth(50); r.setHeight(50); r.setFill(Color.BLUE); r.setBlendMode(BlendMode.ADD);
shadowPane.layoutBoundsProperty().addListener((observable, oldBounds, newBounds) -> { innerBounds.relocate(newBounds.getMinX() + shadowSize, newBounds.getMinY() + shadowSize); innerBounds.setWidth(newBounds.getWidth() - shadowSize * 2); innerBounds.setHeight(newBounds.getHeight() - shadowSize * 2); outerBounds.setWidth(newBounds.getWidth()); outerBounds.setHeight(newBounds.getHeight());
innerHealthRect.setWidth( outerHealthRect.getWidth() * value);
Rectangle dragBox = new Rectangle(0, 0, 0, 0); dragBox.setVisible(false); scene.addEventFilter(MouseEvent.ANY, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if(mouseEvent.getEventType() == MouseEvent.MOUSE_CLICKED){ dragBox.setVisible(true); dragBox.setTranslateX(mouseEvent.getX()); dragBox.setTranslateY(mouseEvent.getY()); } if(mouseEvent.getEventType() == MouseEvent.MOUSE_MOVED && dragBox.isVisible()){ dragBox.setWidth(mouseEvent.getX() - dragBox.getTranslateX()); dragBox.setHeight(mouseEvent.getY() - dragBox.getTranslateY()); } if(mouseEvent.getEventType() == MouseEvent.MOUSE_RELEASED) dragBox.setVisible(false); } });
final Rectangle background = new Rectangle(0, 0, 0, 0); root.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() { @Override public void changed(ObservableValue<? extends Bounds> observable, Bounds oldValue, Bounds newValue) { background.setX(newValue.getMinX()); background.setY(newValue.getMinY()); background.setWidth(newValue.getWidth()); background.setHeight(newValue.getHeight()); } }); background.setFill(null); background.setStroke(Color.RED); pane.getChildren().add(background);
public boolean isRowVisible(JTable table, int rowIndex) { if (!(table.getParent() instanceof JViewport)) { return true; } JViewport viewport = (JViewport)table.getParent(); // This rectangle is relative to the table where the // northwest corner of cell (0,0) is always (0,0) Rectangle rect = table.getCellRect(rowIndex, 1, true); // The location of the viewport relative to the table Point pt = viewport.getViewPosition(); // Translate the cell location so that it is relative // to the view, assuming the northwest corner of the // view is (0,0) rect.setLocation(rect.x-pt.x, rect.y-pt.y); rect.setLeft(0); rect.setWidth(1); // Check if view completely contains the row return new Rectangle(viewport.getExtentSize()).contains(rect); }
r.setWidth(100); r.heightProperty().bind(slider.valueProperty()); root.getChildren().add(r);
if (!empty && item != null) { rectangle.setWidth((item[1] - item[0]) * BAR_SIZE); rectangle.setTranslateX(item[0] * BAR_SIZE); rectangle.setVisible(true);
public void start(final Stage stage) throws Exception { Group root = new Group(); final Menu menu1 = new Menu("File"); MenuBar menuBar = new MenuBar(); menuBar.getMenus().add(menu1); MenuItem menu12 = new MenuItem("Open"); menu1.getItems().add(menu12); Rectangle rect = new Rectangle(); rect.setHeight(100); rect.setWidth(100); Tooltip t = new Tooltip("A Rectangle ToolTip"); Tooltip.install(rect, t); CustomMenuItem customMenuItem = new CustomMenuItem(rect); customMenuItem.setHideOnClick(false); menu1.getItems().add(customMenuItem); root.getChildren().add(menuBar); Scene scene = new Scene(root,800,600); stage.setScene(scene); stage.show(); }
square.setWidth(50); square.setHeight(50); square.setStyle("-fx-fill: red;");
border.setX(b.getMinX() - 1); border.setY(b.getMinY() - 1); border.setWidth(b.getWidth()+2); border.setHeight(b.getHeight()+2);