gridpane

JavaFx GridPane layout how to set margin for an element in row?

Deadly 提交于 2020-01-24 02:57:06
问题 I'm using GridPane layout for positioning things in my application. I'm wondering how I can set margin for an element in row GridPane.setConstraints(chip5, 1, 1, 1, 1, HPos.RIGHT, VPos.TOP); //I want to set // margin for chip5 from top (for example 5px) Is it possible in GridPane? 回答1: You can set the margin for any particular Node : GridPane.setMargin(chip5, new Insets(5, 0, 0, 0)); 回答2: In FXML, you can do it as follows: <TextField fx:id="txtFirstName" GridPane.rowIndex="0" GridPane

Extracting text from dynamically created textfields inside various rows of gridpane

风格不统一 提交于 2020-01-06 07:08:17
问题 I'm trying to create a grid with a textbox on each row where user can enter a number, and corresponding number of new rows are added. This works well, as shown below in the screenshot. Now I'm trying to extract the text from those textfields created based on the question "how many?" and since they are nested within various node elements, I'm having a hard time identifying the right way.Can anyone tell me what I'm doing wrong? I tried testing it using the save button, but I always go into the

Wrapping a GridPane in a ScrollPane or programatically modifying it. Most efficient approach?

痞子三分冷 提交于 2020-01-05 10:32:47
问题 In a game I have a GridPane displaying the Tiles of the world in square cells. The player can, using the keyboard, move what is displayed by a column\row. The approaches I've thought of are: Having the GridPane change programmatically the displayed tiles by moving everything by x steps on player input. Wrapping the GridPane in a ScrollPane and tying the ScrollPane's scroll to Keyboard input. My question is, assuming that things that are off-sight but on the same map are always loaded, what

JavaFX, can't get GridPane to fit in the center of BorderPane

[亡魂溺海] 提交于 2020-01-05 07:18:44
问题 I'm working on a sudoku application but I'm having an issue which hinders my advancement. What I'm trying to do is to make this sudoku-board that I have created with loops, which adds a Label into a StackPane and that StackPane goes into it's designated spot into the GridPane. So I'm trying to force this board have a set size and not grow beyond that point. I've spent the whole evening researching and trying different things, for example putting the GridPane into an AnchorPane and trying to

Unable to Center a Grid Using JavaFX

烂漫一生 提交于 2019-12-25 09:17:28
问题 I'm using grid.setAlignment(Pos.CENTER); to center my grid within the JavaFX scene however it doesn't seem to work. The grid always displays in the top left of the scene no matter what position I give it. Can anyone see what I'm doing wrong? My entire code (minus imports) is as follows: *public class Main extends Application { @Override public void start(Stage stage) throws Exception { Scene scene = new Scene(new Group(), 450, 250); Button btn = new Button(); btn.setText("Run"); final

how to add imageviews to gridpane using a forloop

喜你入骨 提交于 2019-12-24 08:33:16
问题 here's my code.this prompts a exception saying "IllegalArgumentException: Children: duplicate children added: parent = Grid hgap=5.0, vgap=5.0, alignment=TOP_LEFT" File file = new File("D:\SERVER\Server Content\Apps\icons"); File[] filelist1 = file.listFiles(); ArrayList<File> filelist2 = new ArrayList<>(); hb = new HBox(); for (File file1 : filelist1) { filelist2.add(file1); } System.out.println(filelist2.size()); for (int i = 0; i < filelist2.size(); i++) { System.out.println(filelist2.get

JavaFX - Border radius <-> Background color

折月煮酒 提交于 2019-12-23 21:33:23
问题 If I add -fx-border-radius and -fx-border-width CSS to a simple GridPane, in its corner the background will not be "cut down". The CSS: .payload { -fx-hgap: 20px; -fx-padding: 40px; -fx-background-color: #2969c0; -fx-border-radius: 50px; -fx-border-width: 5px; -fx-border-color: black; -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.8), 10, 0, 0, 0); } The picture about the result: How do I fix this ? 回答1: You need to add the radius property as well to define the background fill.

JavaFX: Best way to update GridPane after row deletion?

浪尽此生 提交于 2019-12-23 00:22:30
问题 I am using a GridPane (inside a ScrollPane) as a table with user entries. Each row incorporates a username (Label), an icon depicting its state (ImageView) and two buttons, the second of which is used to delete the user entry. The two images below depict the scroll pane before and after the user entry deletion UPDATE: Code sample below: The obvious issue is that the GridPane items do not get automatically re-arranged and the deleted line still occupies space. Do I have to provide a method to

JavaFX continuous form dynamically add new row with content in gridpane

天大地大妈咪最大 提交于 2019-12-21 06:27:23
问题 I need some help creating a continuous form with a gridpane like in ms access. Initially the gridpane has 1 row and 3 columns | Choicebox | Delete Button | Add Button | public class myGridpane { @FXML private GridPane gp_form; private List<Car> myCars = new ArrayList(); public void initialize() { myCars = loadCars(); initGridpane(myCars); } private initGridpane(List<Car> myCars) { int rowIndex = 0; for (Car myCar : myCars) { Button b_newCar = new Button("+"); Button b_deleteCar = new Button("

JavaFX - get index row and index col by OnClick on GridPane [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 05:23:09
问题 This question already has answers here : Javafx - Determine position of cursor on right click relative to gridpane (1 answer) How to get GridPane Row and Column IDs on Mouse Entered in each cell of Grid in JavaFX? (1 answer) JavaFX : How to get column and row index in gridpane? (1 answer) Closed 2 years ago . I need to get the index of my specified click over my GridPane called myGrid. If I put a piece on board from my coord like here below, it works.. for example: myGrid.add(new ImageView(