Java Code Examples for javafx.scene.control.CheckBox#isSelected()
The following examples show how to use
javafx.scene.control.CheckBox#isSelected() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CMultipleChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
@Override public DataElt getDataElt(DataEltType type, String eltname, String objectfieldname) { if (!(type instanceof MultipleChoiceDataEltType)) throw new RuntimeException(String.format( "Only MultipleChoiceDataEltType can be extracted from CMultiChoiceField, but request was %s", type)); MultipleChoiceDataElt< CChoiceFieldValue> multipleelement = new MultipleChoiceDataElt<CChoiceFieldValue>(eltname); for (int i = 0; i < checkboxpanel.size(); i++) { CheckBox thischeckbox = checkboxpanel.get(i); if (thischeckbox.isSelected()) { multipleelement.addChoice(values.get(i)); } } return multipleelement; }
Example 2
Source File: WebViewHyperlinkListenerDemo.java From mars-sim with GNU General Public License v3.0 | 6 votes |
@Override public void start(Stage primaryStage) throws Exception { // controls WebView webView = createWebView(); Label urlLabel = createUrlLabel(); CheckBox listenerAttachedBox = createListenerAttachedBox(); CheckBox cancelEventBox = createCancelEventBox(); // listener WebViewHyperlinkListener listener = event -> { showEventOnLabel(event, urlLabel); return cancelEventBox.isSelected(); }; manageListener(webView, listener, listenerAttachedBox.selectedProperty()); // put together VBox box = new VBox(webView, listenerAttachedBox, cancelEventBox, urlLabel); java.net.CookieHandler.setDefault(null); Scene scene = new Scene(box); primaryStage.setScene(scene); primaryStage.show(); }
Example 3
Source File: TestbedSidePanel.java From jbox2d with BSD 2-Clause "Simplified" License | 6 votes |
public void stateChanged(Control control) { TestbedSetting setting = getClientProperty(control, SETTING_TAG); switch (setting.constraintType) { case BOOLEAN: CheckBox box = (CheckBox) control; setting.enabled = box.isSelected(); break; case RANGE: Slider slider = (Slider) control; setting.value = (int) slider.getValue(); Label label = getClientProperty(slider, LABEL_TAG); label.setText(setting.name + ": " + setting.value); break; } model.getPanel().grabFocus(); }
Example 4
Source File: CMultipleChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public MultipleChoiceDataElt<CChoiceFieldValue> getFieldDataElt() { MultipleChoiceDataElt< CChoiceFieldValue> multipleelement = new MultipleChoiceDataElt<CChoiceFieldValue>(datafieldname); for (int i = 0; i < checkboxpanel.size(); i++) { CheckBox thischeckbox = checkboxpanel.get(i); if (thischeckbox.isSelected()) { multipleelement.addChoice(values.get(i)); } } return multipleelement; }
Example 5
Source File: SelectSongsDialog.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Disable / enable the add button depending on if anything is selected. */ private void checkEnableButton() { for(CheckBox checkBox : checkBoxes) { if(checkBox.isSelected()) { addButton.setDisable(false); return; } } addButton.setDisable(true); }
Example 6
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 5 votes |
public int getSelection(CheckBox cb) { int selection; if (cb.isAllowIndeterminate() && cb.isIndeterminate()) { selection = 1; } else { selection = cb.isSelected() ? 2 : 0; } return selection; }
Example 7
Source File: JavaFXCheckBoxElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void selectCheckboxNotSelectedSelected() throws Throwable { CheckBox checkBoxNode = (CheckBox) getPrimaryStage().getScene().getRoot().lookup(".check-box"); AssertJUnit.assertEquals(false, checkBoxNode.isSelected()); checkBox.marathon_select("checked"); new Wait("Waiting for the check box selection.") { @Override public boolean until() { return checkBoxNode.isSelected(); } }; }
Example 8
Source File: JavaFXCheckBoxElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void selectCheckboxSelectedSelected() throws Throwable { CheckBox checkBoxNode = (CheckBox) getPrimaryStage().getScene().getRoot().lookup(".check-box"); checkBoxNode.setSelected(true); AssertJUnit.assertEquals(true, checkBoxNode.isSelected()); checkBox.marathon_select("checked"); new Wait("Waiting for the check box selection.") { @Override public boolean until() { return checkBoxNode.isSelected(); } }; }
Example 9
Source File: JavaFXCheckBoxElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void selectCheckboxSelectedNotSelected() throws Throwable { CheckBox checkBoxNode = (CheckBox) getPrimaryStage().getScene().getRoot().lookup(".check-box"); checkBoxNode.setSelected(true); AssertJUnit.assertEquals(true, checkBoxNode.isSelected()); checkBox.marathon_select("unchecked"); new Wait("Waiting for the check box deselect.") { @Override public boolean until() { return !checkBoxNode.isSelected(); } }; }
Example 10
Source File: JavaFXCheckBoxElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void selectCheckboxNotSelectedNotSelected() throws Throwable { CheckBox checkBoxNode = (CheckBox) getPrimaryStage().getScene().getRoot().lookup(".check-box"); AssertJUnit.assertEquals(false, checkBoxNode.isSelected()); checkBox.marathon_select("unchecked"); new Wait("Waiting for the check box deselect.") { @Override public boolean until() { return !checkBoxNode.isSelected(); } }; }
Example 11
Source File: JavaFXCheckBoxElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void checkedCheckboxNotSelectedNotSelected() throws Throwable { CheckBox checkBoxNode = findCheckbox("Three state checkbox"); AssertJUnit.assertEquals(false, checkBoxNode.isSelected()); triStateCheckBox.marathon_select("checked"); new Wait("Waiting for the check box deselect.") { @Override public boolean until() { return !checkBoxNode.isIndeterminate() && checkBoxNode.isSelected(); } }; }
Example 12
Source File: LogbooksTagsView.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Sets the field's text based on the selected items list. */ private void setFieldText(ContextMenu dropDown, List<String> selectedItems, TextField field) { // Handle drop down menu item checking. for (MenuItem menuItem : dropDown.getItems()) { CustomMenuItem custom = (CustomMenuItem) menuItem; CheckBox check = (CheckBox) custom.getContent(); // If the item is selected make sure it is checked. if (selectedItems.contains(check.getText())) { if (! check.isSelected()) check.setSelected(true); } // If the item is not selected, make sure it is not checked. else { if (check.isSelected()) check.setSelected(false); } } // Build the field text string. String fieldText = ""; for (String item : selectedItems) { fieldText += (fieldText.isEmpty() ? "" : ", ") + item; } field.setText(fieldText); }
Example 13
Source File: JFXCheckBoxSkin.java From JFoenix with Apache License 2.0 | 5 votes |
@Override protected void layoutChildren(final double x, final double y, final double w, final double h) { final double labelOffset = getLabelOffset(); final CheckBox checkBox = getSkinnable(); final double boxWidth = snapSize(box.prefWidth(-1)); final double boxHeight = snapSize(box.prefHeight(-1)); final double computeWidth = Math.max(checkBox.prefWidth(-1), checkBox.minWidth(-1)); final double labelWidth = Math.min(computeWidth - boxWidth, w - snapSize(boxWidth)) + labelOffset; final double labelHeight = Math.min(checkBox.prefHeight(labelWidth), h); final double maxHeight = Math.max(boxHeight, labelHeight); final double xOffset = computeXOffset(w, labelWidth + boxWidth, checkBox.getAlignment().getHpos()) + x; final double yOffset = computeYOffset(h, maxHeight, checkBox.getAlignment().getVpos()) + x; if (invalid) { if (checkBox.isIndeterminate()) { playIndeterminateAnimation(true, false); } else if (checkBox.isSelected()) { playSelectAnimation(true, false); } invalid = false; } layoutLabelInArea(xOffset + boxWidth + labelOffset, yOffset, labelWidth, maxHeight, checkBox.getAlignment()); rippler.resize(boxWidth, boxHeight); positionInArea(rippler, xOffset, yOffset, boxWidth, maxHeight, 0, checkBox.getAlignment().getHpos(), checkBox.getAlignment().getVpos()); }
Example 14
Source File: BooleanParameter.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
@Override public void setValueFromComponent(CheckBox component) { value = component.isSelected(); }
Example 15
Source File: GameElimniationController.java From MyBox with Apache License 2.0 | 4 votes |
@FXML protected void okRulersAction() { if (isSettingValues) { return; } catButton.setSelected(false); try { countedChesses.clear(); String s = ""; for (Node node : countedImagesPane.getChildren()) { CheckBox cbox = (CheckBox) node; if (cbox.isSelected()) { int index = (int) cbox.getUserData(); countedChesses.add(index); ImageItem item = getImageItem(index); if (s.isBlank()) { s += item.getAddress(); } else { s += "," + item.getAddress(); } } } if (countedChesses.isEmpty()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(getBaseTitle()); alert.setContentText(AppVariables.message("SureNoScore")); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); ButtonType buttonSure = new ButtonType(AppVariables.message("Sure")); ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel")); alert.getButtonTypes().setAll(buttonSure, buttonCancel); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(true); stage.toFront(); Optional<ButtonType> result = alert.showAndWait(); if (result.get() != buttonSure) { return; } } AppVariables.setUserConfigValue("GameEliminationCountedImages", s); scoreRulers.clear(); s = ""; for (int i = 0; i < scoreRulersData.size(); ++i) { ScoreRuler r = scoreRulersData.get(i); scoreRulers.put(r.adjacentNumber, r.score); if (!s.isEmpty()) { s += ","; } s += r.adjacentNumber + "," + r.score; } AppVariables.setUserConfigValue("GameElimniationScoreRulers", s); tabPane.getSelectionModel().select(playTab); newGame(true); } catch (Exception e) { logger.debug(e.toString()); } }
Example 16
Source File: Main.java From ShootOFF with GNU General Public License v3.0 | 4 votes |
private boolean showFirstRunMessage() { final Label hardwareMessageLabel = new Label("Fetching hardware status to determine how well ShootOFF\n" + "will run on this machine. This may take a moment..."); new Thread(() -> { final String cpuName = HardwareData.getCpuName(); final Optional<Integer> cpuScore = HardwareData.getCpuScore(); final long installedRam = HardwareData.getMegabytesOfRam(); if (cpuScore.isPresent()) { if (logger.isDebugEnabled()) logger.debug("Processor: {}, Processor Score: {}, installed RAM: {} MB", cpuName, cpuScore.get(), installedRam); Platform.runLater(() -> setHardwareMessage(hardwareMessageLabel, cpuScore.get())); } else { if (logger.isDebugEnabled()) logger.debug("Processor: {}, installed RAM: {} MB", cpuName, installedRam); Platform.runLater(() -> setHardwareMessage(hardwareMessageLabel, installedRam)); } }).start(); final Alert shootoffWelcome = new Alert(AlertType.INFORMATION); shootoffWelcome.setTitle("Welcome to ShootOFF"); shootoffWelcome.setHeaderText("Please Ensure Your Firearm is Unloaded!"); shootoffWelcome.setResizable(true); final FlowPane fp = new FlowPane(); final Label lbl = new Label("Thank you for choosing ShootOFF for your training needs.\n" + "Please be careful to ensure your firearm is not loaded\n" + "every time you use ShootOFF. We are not liable for any\n" + "negligent discharges that may result from your use of this\n" + "software.\n\n" + "We upload most errors that cause crashes to our servers to\n" + "help us detect and fix common problems. We do not include any\n" + "personal information in these reports, but you may uncheck\n" + "the box below if you do not want to support this effort.\n\n"); final CheckBox useErrorReporting = new CheckBox("Allow ShootOFF to Send Error Reports"); useErrorReporting.setSelected(true); fp.getChildren().addAll(hardwareMessageLabel, lbl, useErrorReporting); shootoffWelcome.getDialogPane().contentProperty().set(fp); shootoffWelcome.showAndWait(); return useErrorReporting.isSelected(); }