List of usage examples for javafx.collections ObservableList add
void add(int index, E element);
From source file:de.pixida.logtest.designer.automaton.EditorAutomaton.java
private void createConfigFrame() { final int descriptionInputLines = 8; this.descriptionInput.setPrefRowCount(descriptionInputLines); this.descriptionInput.setWrapText(true); this.descriptionInput.textProperty() .addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { this.setDescription(newValue); this.graph.handleChange(); });//from ww w . j a v a 2 s . com this.configFrame.addOption("Description", this.descriptionInput); final ObservableList<String> options = FXCollections.observableArrayList("JavaScript", "python"); if (!options.contains(Automaton.DEFAULT_SCRIPTING_LANGUAGE)) { options.add(0, Automaton.DEFAULT_SCRIPTING_LANGUAGE); } final ChoiceBox<String> scriptLanguageInput = new ChoiceBox<>(options); scriptLanguageInput .setValue(StringUtils.isBlank(this.scriptLanguage) || !options.contains(this.scriptLanguage) ? Automaton.DEFAULT_SCRIPTING_LANGUAGE : this.scriptLanguage); scriptLanguageInput.getSelectionModel().selectedIndexProperty() .addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> { EditorAutomaton.this.scriptLanguage = scriptLanguageInput.getItems().get((Integer) newValue); this.graph.handleChange(); }); this.configFrame.addOption("Script language", scriptLanguageInput); final int onLoadInputLines = 8; this.onLoadInput.setPrefRowCount(onLoadInputLines); this.onLoadInput.setWrapText(true); this.onLoadInput.setStyle("-fx-font-family: monospace"); this.onLoadInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { this.graph.handleChange(); }); this.configFrame.addOption("On Load", this.onLoadInput); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
void refreshTable(TableView tableView) { final ObservableList items = tableView.getItems(); if (items == null || items.size() == 0) return;/* ww w . j ava2 s . co m*/ Object item = tableView.getItems().get(0); items.remove(item); Platform.runLater(new Runnable() { @Override public void run() { items.add(0, item); } }); }
From source file:com.cyberlogix.mist6020biometrics.RosterController.java
public void printsListener() { long delay = 5 * 1000; final long period = 5 * 1000; Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override/*from w w w.j ava 2s. c om*/ public void run() { Platform.runLater(new Runnable() { @Override public void run() { String b64Print = bio.getImage(rosterImage, rosterPbar, rosterPin, new Stage(), period); System.out.println("Print: " + b64Print); try { if (!b64Print.equalsIgnoreCase("error")) { String url = ServerConnect.STUDENTS_URL + "/verify"; ServerConnect sc = new ServerConnect(); JSONObject req = new JSONObject(); req.put("print", b64Print); ServerResponse msg = sc.processRequest(req.toString(), url, ServerConnect.METHOD_POST); if (msg.getStatusCode() == 200 || msg.getStatusCode() == 201) { ObjectMapper jackson = new ObjectMapper(); Student student = jackson.readValue( msg.getResponse().getJSONObject("payload").toString(), Student.class); //update table int pos = -1; ObservableList<Student> students = tblRoster.getItems(); for (int i = 0; i < students.size(); i++) { if (students.get(i).getId() == student.getId()) { System.out.println("Student Matched..."); student.setSignedIn("Present"); students.remove(students.get(i)); pos = i; } } if (pos >= 0) { students.add(pos, student); } System.out.println("Students Size: " + students.size()); tblRoster.setItems(students); // Dialogs.showConfirmDialog(new Stage(), msg.getResponse().getString("message") + " " + student.getName()); alertBox.setText( msg.getResponse().getString("message") + " " + student.getName()); alertBox.setStyle("-fx-text-fill: green; -fx-font-weight: bold;"); } else { // Dialogs.showErrorDialog(new Stage(), msg.getResponse().getString("message"), "Error " + msg.getStatusCode(), "Error"); alertBox.setText(msg.getResponse().getString("message")); alertBox.setStyle("-fx-text-fill: red; -fx-font-weight: bold;"); } } } catch (JSONException | IOException e) { UtilHelper.debugTrace(e); } } }); } }, delay, period); }
From source file:de.ifsr.adam.ImageGenerator.java
/** * Takes a snapshot of the Pane and prints it to a pdf. * * @return True if no IOException occurred *//*w w w.j a v a 2s.com*/ private boolean printToPDF(String filePath, Pane pane) { //Scene set up Group root = new Group(); Scene printScene = new Scene(root); printScene.getStylesheets().add(this.stylesheetURI.toString()); //Snapshot generation ArrayList<WritableImage> images = new ArrayList<>(); try { ObservableList<Node> panes = pane.getChildren(); for (int i = 0; i < panes.size(); i++) { GridPane gridPane = (GridPane) panes.get(i); ((Group) printScene.getRoot()).getChildren().clear(); ((Group) printScene.getRoot()).getChildren().addAll(gridPane); images.add(printScene.snapshot(null)); panes.add(i, gridPane); } } catch (Exception e) { log.error(e); return false; } //PDF Setup File outFile = new File(filePath + "." + "pdf"); Iterator<WritableImage> iterImages = images.iterator(); PDDocument doc = new PDDocument(); try { while (iterImages.hasNext()) { //Page setup PDPage page = new PDPage(); doc.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, false); //Image setup BufferedImage bufImage = SwingFXUtils.fromFXImage(iterImages.next(), null); PDPixelMap pixelMap = new PDPixelMap(doc, bufImage); int width = (int) (page.getMediaBox().getWidth()); int height = (int) (page.getMediaBox().getHeight()); Dimension dim = new Dimension(width, height); contentStream.drawXObject(pixelMap, 0, 0, dim.width, dim.height); contentStream.close(); } doc.save(outFile); return true; } catch (IOException | COSVisitorException e) { log.error(e); return false; } }
From source file:org.beryx.viewreka.fxapp.Viewreka.java
public void showFilePane(boolean show, FxProject newProject) { ObservableList<Node> items = mainSplitPane.getItems(); if (show) {//from w w w.ja va2 s. com if (!items.contains(fileSplitPane)) { items.add(0, fileSplitPane); } configureMainSplitDivider(project); } else { items.remove(fileSplitPane); } mnuToggleFilePane.setText((show ? "Hide" : "Show") + " File Area"); if (newProject != null) { newProject.getProjectSettingsManager().getSettings().setProperty(PROP_FILE_AREA_VISIBLE, show); } }