List of usage examples for javafx.beans.value ChangeListener ChangeListener
ChangeListener
From source file:boundary.GraphPane.java
private Node addThresholdSlider(float min, float max) { HBox hBox = new HBox(); hBox.setPadding(new Insets(15, 12, 15, 12)); hBox.setStyle("-fx-background-color: #66FFFF;"); Label lblThreshold = new Label("Threshold: "); lblThreshold.setPrefSize(100, 20);//w w w. j av a 2 s . com Label lblValue = new Label("Value: "); lblValue.setPrefSize(50, 20); TextField tfValue = new TextField(String.valueOf(min)); Slider thresholdSlider = new Slider(); thresholdSlider.setMin(Math.floor(min)); thresholdSlider.setMax(Math.ceil(max)); thresholdSlider.setMajorTickUnit(Math.ceil((max - min) / 5)); thresholdSlider.setMinorTickCount(1); thresholdSlider.setBlockIncrement(1); thresholdSlider.setSnapToTicks(true); thresholdSlider.setShowTickMarks(true); thresholdSlider.valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { edgePredicate.setThreshold(newValue.floatValue()); vertexPredicate.setThreshold(newValue.floatValue()); vv.repaint(); tfValue.setText(String.format(Locale.US, "%.2f", newValue.floatValue())); } }); tfValue.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { float value; try { value = Float.parseFloat(tfValue.getText()); } catch (Exception ex) { value = 0; } edgePredicate.setThreshold(value); vertexPredicate.setThreshold(value); vv.repaint(); thresholdSlider.setValue(value); } }); Label lblSearch = new Label("Search: "); lblSearch.setPrefSize(70, 20); TextField tf = new TextField(); tf.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { String toFind = tf.getText().toLowerCase(); for (NodeInfo nodeInfo : nodesHighlighted) nodeInfo.setHighlighted(false); if (nodesHighlighted.size() > 0) { nodesHighlighted.clear(); vv.repaint(); } if (toFind.length() > 2) { for (NodeInfo nodeInfo : nodes.values()) { if (nodeInfo.getUserData().toLowerCase().contains((toFind))) { nodeInfo.setHighlighted(true); nodesHighlighted.add(nodeInfo); } } if (nodesHighlighted.size() == 1) { Layout<String, String> layout = vv.getGraphLayout(); Point2D q = layout.transform(nodesHighlighted.get(0).id); Point2D lvc = vv.getRenderContext().getMultiLayerTransformer() .inverseTransform(vv.getCenter()); final double dx = (lvc.getX() - q.getX()) / 10; final double dy = (lvc.getY() - q.getY()) / 10; Runnable animator = new Runnable() { public void run() { for (int i = 0; i < 10; i++) { vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT) .translate(dx, dy); try { Thread.sleep(100); } catch (InterruptedException ex) { } } } }; Thread thread = new Thread(animator); thread.start(); } vv.repaint(); } } }); hBox.getChildren().addAll(lblThreshold, thresholdSlider, lblValue, tfValue, lblSearch, tf); return hBox; }
From source file:org.noroomattheinn.visibletesla.OverviewController.java
@Override protected void initializeState() { final Vehicle v = vtVehicle.getVehicle(); getAppropriateImages(v);/*from w ww .j a va2 s .c o m*/ toggleChoice = this.storedToggleChoice(); prefs.overrides.color.addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> ov, String t, String t1) { getAppropriateImages(v); } }); prefs.overrides.doColor.addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { getAppropriateImages(v); } }); vtVehicle.vehicleState.addTracker(new Runnable() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { updateVehicleState(); } }); } }); vtVehicle.chargeState.addTracker(new Runnable() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { updateChargePort(); updateRange(); } }); } }); vtVehicle.streamState.addTracker(new Runnable() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { updateOdometer(); updateShiftState(); } }); } }); updateOdometer(); // Show at least an old reading to start vtData.produceStream(false); // Update it at some point updateWheelView(); // Make sure we display the right wheels from the get-go updateRoofView(); // Make sure we display the right roof from the get-go reflectVINOrFirmware(); vinButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { cycleToggleChoice(); reflectVINOrFirmware(); } }); }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java
@Override public Region getContent() { if (hBox == null) { VBox statedInferredToggleGroupVBox = new VBox(); statedInferredToggleGroupVBox.setSpacing(4.0); //Instantiate Everything pathComboBox = new ComboBox<>(); //Path statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred List<RadioButton> statedInferredOptionButtons = new ArrayList<>(); datePicker = new DatePicker(); //Date timeSelectCombo = new ComboBox<Long>(); //Time //Radio buttons for (StatedInferredOptions option : StatedInferredOptions.values()) { RadioButton optionButton = new RadioButton(); if (option == StatedInferredOptions.STATED) { optionButton.setText("Stated"); } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) { optionButton.setText("Inferred Then Stated"); } else if (option == StatedInferredOptions.INFERRED) { optionButton.setText("Inferred"); } else { throw new RuntimeException("oops"); }//from ww w . j a v a 2 s . co m optionButton.setUserData(option); optionButton.setTooltip( new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption())); statedInferredToggleGroup.getToggles().add(optionButton); statedInferredToggleGroupVBox.getChildren().add(optionButton); statedInferredOptionButtons.add(optionButton); } statedInferredToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData()); } }); //Path Combo Box pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() { @Override public ListCell<UUID> call(ListView<UUID> param) { final ListCell<UUID> cell = new ListCell<UUID>() { @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }; return cell; } }); pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }); pathComboBox.setOnAction((event) -> { if (!pathComboFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); if (selectedPath != null) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); StampBdb stampDb = Bdb.getStampDb(); NidSet nidSet = new NidSet(); nidSet.add(path); //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE); pathDatesList.clear(); // disableTimeCombo(true); timeSelectCombo.setValue(Long.MAX_VALUE); for (Integer thisStamp : stamps.getAsSet()) { try { Position stampPosition = stampDb.getPosition(thisStamp); this.stampDate = new Date(stampPosition.getTime()); stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); this.pathDatesList.add(stampDateInstant); //Build DatePicker } catch (Exception e) { e.printStackTrace(); } } datePicker.setValue(LocalDate.now()); } } else { pathComboFirstRun = false; } }); pathComboBox.setTooltip( new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\"")); //Calendar Date Picker final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate thisDate, boolean empty) { super.updateItem(thisDate, empty); if (pathDatesList != null) { if (pathDatesList.contains(thisDate)) { setDisable(false); } else { setDisable(true); } } } }; } }; datePicker.setDayCellFactory(dayCellFactory); datePicker.setOnAction((event) -> { if (!datePickerFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault())); Long dateSelected = Date.from(instant).getTime(); if (selectedPath != null && dateSelected != 0) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); setTimeOptions(path, dateSelected); try { timeSelectCombo.setValue(times.first()); //Default Dropdown Value } catch (Exception e) { // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled // Right now, Sometimes Time Combo is disabled, so we catch this and eat it // Otherwise make a conditional from the Read Only Boolean Property to check first } } else { disableTimeCombo(false); logger.debug("The path isn't set or the date isn't set. Both are needed right now"); } } else { datePickerFirstRun = false; } }); //Commit-Time ComboBox timeSelectCombo.setMinWidth(200); timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() { @Override public ListCell<Long> call(ListView<Long> param) { final ListCell<Long> cell = new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }; return cell; } }); timeSelectCombo.setButtonCell(new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }); try { currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty()); } catch (Exception e) { e.printStackTrace(); } // DEFAULT VALUES UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); storedTimePref = loggedIn.getViewCoordinateTime(); storedPathPref = loggedIn.getViewCoordinatePath(); if (storedPathPref != null) { pathComboBox.getItems().clear(); //Set the path Dates by default pathComboBox.getItems().addAll(getPathOptions()); final UUID storedPath = getStoredPath(); if (storedPath != null) { pathComboBox.getSelectionModel().select(storedPath); } if (storedTimePref != null) { final Long storedTime = loggedIn.getViewCoordinateTime(); Calendar cal = Calendar.getInstance(); cal.setTime(new Date(storedTime)); cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds Long storedTruncTime = cal.getTimeInMillis(); if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid(); setTimeOptions(path, storedTimePref); timeSelectCombo.setValue(storedTruncTime); // timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work Date storedDate = new Date(storedTime); datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); } else { datePicker.setValue(LocalDate.now()); timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work timeSelectCombo.setValue(Long.MAX_VALUE); // disableTimeCombo(false); } } else { //Stored Time Pref == null logger.error("ERROR: Stored Time Preference = null"); } } else { //Stored Path Pref == null logger.error("We could not load a stored path, ISAAC cannot run"); throw new Error("No stored PATH could be found. ISAAC can't run without a path"); } GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Label pathLabel = new Label("View Coordinate Path"); gridPane.add(pathLabel, 0, 0); //Path Label - Row 0 GridPane.setHalignment(pathLabel, HPos.LEFT); gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2 gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2 GridPane.setValignment(pathComboBox, VPos.TOP); Label datePickerLabel = new Label("View Coordinate Dates"); gridPane.add(datePickerLabel, 0, 2); //Row 3 GridPane.setHalignment(datePickerLabel, HPos.LEFT); gridPane.add(datePicker, 0, 3); //Row 4 Label timeSelectLabel = new Label("View Coordinate Times"); gridPane.add(timeSelectLabel, 1, 2); //Row 3 GridPane.setHalignment(timeSelectLabel, HPos.LEFT); gridPane.add(timeSelectCombo, 1, 3); //Row 4 // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY /* UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy(); UUID chosenPathUuid = userProfile.getViewCoordinatePath(); Long chosenTime = userProfile.getViewCoordinateTime(); Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid)); gridPane.add(printSelectedPathLabel, 0, 4); GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT); Label printSelectedTimeLabel = null; if(chosenTime != getDefaultTime()) { printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime))); } else { printSelectedTimeLabel = new Label("Time: LONG MAX VALUE"); } gridPane.add(printSelectedTimeLabel, 1, 4); GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT); Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy); gridPane.add(printSelectedPolicyLabel, 2, 4); GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT); */ hBox = new HBox(); hBox.getChildren().addAll(gridPane); allValid_ = new ValidBooleanBinding() { { bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (currentStatedInferredOptionProperty.get() == null) { this.setInvalidReason("Null/unset/unselected StatedInferredOption"); for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.setTextErrorColor(button); } return false; } else { for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.clearTextErrorColor(button); } } if (currentPathProperty.get() == null) { this.setInvalidReason("Null/unset/unselected path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) { this.setInvalidReason("Invalid path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } // if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE) // { // this.setInvalidReason("View Coordinate Time is unselected"); // TextErrorColorHelper.setTextErrorColor(timeSelectCombo); // return false; // } this.clearInvalidReason(); return true; } }; } // createButton.disableProperty().bind(saveButtonValid.not())); // Reload persisted values every time final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption(); for (Toggle toggle : statedInferredToggleGroup.getToggles()) { if (toggle.getUserData() == storedStatedInferredOption) { toggle.setSelected(true); } } // pathComboBox.setButtonCell(new ListCell<UUID>() { // @Override // protected void updateItem(UUID c, boolean emptyRow) { // super.updateItem(c, emptyRow); // if (emptyRow) { // setText(""); // } else { // String desc = OTFUtility.getDescription(c); // setText(desc); // } // } // }); // timeSelectCombo.setButtonCell(new ListCell<Long>() { // @Override // protected void updateItem(Long item, boolean emptyRow) { // super.updateItem(item, emptyRow); // if (emptyRow) { // setText(""); // } else { // setText(timeFormatter.format(new Date(item))); // } // } // }); // datePickerFirstRun = false; // pathComboFirstRun = false; return hBox; }
From source file:FeeBooster.java
private GridPane rbfGrid(Transaction tx) { // Setup grid GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);/* w ww . ja v a 2 s .c o m*/ grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); int inGridHeight = 0; int outGridHeight = 0; // Add inputs to table Label inputHdrLbl = new Label("Inputs"); grid.add(inputHdrLbl, 0, inGridHeight); inGridHeight++; for (int i = 0; i < tx.getInputs().size(); i++) { // Add input to table TxInput in = tx.getInputs().get(i); Text inputTxt = new Text("Txid: " + in.getTxid() + "\nIndex: " + in.getVout()); grid.add(inputTxt, 0, inGridHeight); inGridHeight++; } // Add outputs to table Label outputHdrLbl = new Label("Outputs"); grid.add(outputHdrLbl, 1, outGridHeight); outGridHeight++; ToggleGroup outputGroup = new ToggleGroup(); for (int i = 0; i < tx.getOutputs().size(); i++) { // Add output to table TxOutput out = tx.getOutputs().get(i); Text outputTxt = new Text("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress()); outputTxt.setUserData(i); grid.add(outputTxt, 1, outGridHeight); // Add radio button to table RadioButton radio = new RadioButton(); radio.setUserData(i); radio.setToggleGroup(outputGroup); radio.setSelected(true); grid.add(radio, 2, outGridHeight); outGridHeight++; } // Set gridheight int gridheight = (inGridHeight < outGridHeight) ? outGridHeight : inGridHeight; gridheight++; // Fee Text fee = new Text("Fee Paid: " + tx.getFee() + " Satoshis"); grid.add(fee, 0, gridheight); // Recommended fee from bitcoinfees.21.co JSONObject apiResult = Utils.getFromAnAPI("http://bitcoinfees.21.co/api/v1/fees/recommended", "GET"); int fastestFee = apiResult.getInt("fastestFee"); long recommendedFee = fastestFee * tx.getSize(); Text recFeeTxt = new Text("Recommended Fee: " + recommendedFee + " Satoshis"); grid.add(recFeeTxt, 1, gridheight); gridheight += 2; // Instructions Text instructions = new Text( "Choose an output to deduct an additional fee from. Then increase the fee below."); grid.add(instructions, 0, gridheight, 3, 1); gridheight++; // Fee spinner Spinner feeSpin = new Spinner((double) tx.getFee(), (double) tx.getTotalAmt(), (double) tx.getFee()); feeSpin.setEditable(true); grid.add(feeSpin, 0, gridheight); feeSpin.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { double oldVal = (double) oldValue; double newVal = (double) newValue; Double step = newVal - oldVal; tx.setFee(tx.getFee() + step.longValue()); fee.setText("Fee Paid: " + tx.getFee() + " Satoshis"); int output = (int) outputGroup.getSelectedToggle().getUserData(); TxOutput out = tx.getOutputs().get(output); out.decreaseValueBy(step.longValue()); for (int i = 0; i < grid.getChildren().size(); i++) { Node child = grid.getChildren().get(i); if (grid.getRowIndex(child) == output + 1 && grid.getColumnIndex(child) == 1) { ((Text) child) .setText("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress()); } } } }); // Set to recommended fee button Button recFeeBtn = new Button("Set fee to recommended"); grid.add(recFeeBtn, 1, gridheight); gridheight++; recFeeBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { long prevFee = tx.getFee(); long step = recommendedFee - prevFee; feeSpin.increment((int) step); } }); // Next Button Button nextBtn = new Button("Next"); grid.add(nextBtn, 1, gridheight); nextBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (sceneCursor == scenes.size() - 1) { Scene scene = new Scene(unsignedTxGrid(tx), 900, 500); scenes.add(scene); sceneCursor++; stage.setScene(scene); } else { sceneCursor++; stage.setScene(scenes.get(sceneCursor)); } } }); HBox btnHbox = new HBox(10); // Back Button Button backBtn = new Button("Back"); backBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { sceneCursor--; stage.setScene(scenes.get(sceneCursor)); } }); btnHbox.getChildren().add(backBtn); btnHbox.getChildren().add(nextBtn); // Cancel Button Button cancelBtn = new Button("Cancel"); cancelBtn.setOnAction(cancelEvent); btnHbox.getChildren().add(cancelBtn); grid.add(btnHbox, 1, gridheight); return grid; }
From source file:com.exalttech.trex.ui.views.PacketTableView.java
/** * Build component UI/*from w ww . ja v a2 s.c o m*/ */ private void buildUI(boolean addExportToYamlBtn) { setTopAnchor(this, 0d); setLeftAnchor(this, 0d); setBottomAnchor(this, 0d); setRightAnchor(this, 0d); // build btn bar HBox buttonContainer = new HBox(); buttonContainer.setSpacing(5); addPacketBtn = new StreamTableButton(StreamTableAction.ADD); initializeStreamButtons(addPacketBtn, false); buttonContainer.getChildren().add(addPacketBtn); // add build stream btn buildPacketBtn = new StreamTableButton(StreamTableAction.BUILD); buildPacketBtn.setId("buildStreamBtn"); initializeStreamButtons(buildPacketBtn, false); buttonContainer.getChildren().add(buildPacketBtn); editPacketBtn = new StreamTableButton(StreamTableAction.EDIT); editPacketBtn.setId("editStreanBtn"); initializeStreamButtons(editPacketBtn, true); buttonContainer.getChildren().add(editPacketBtn); deleteButtonBtn = new StreamTableButton(StreamTableAction.DELETE); initializeStreamButtons(deleteButtonBtn, true); buttonContainer.getChildren().add(deleteButtonBtn); importPcapButton = new StreamTableButton(StreamTableAction.IMPORT_PCAP); initializeStreamButtons(importPcapButton, false); buttonContainer.getChildren().add(importPcapButton); exportPcapButton = new StreamTableButton(StreamTableAction.EXPORT_TO_PCAP); initializeStreamButtons(exportPcapButton, true); buttonContainer.getChildren().add(exportPcapButton); if (addExportToYamlBtn) { exportToYaml = new StreamTableButton(StreamTableAction.EXPORT_TO_YAML); initializeStreamButtons(exportToYaml, false); buttonContainer.getChildren().add(exportToYaml); } getChildren().add(buttonContainer); setTopAnchor(buttonContainer, 5d); rightClickMenu = new ContextMenu(); addMenuItem(StreamTableAction.EDIT); addMenuItem(StreamTableAction.DELETE); addMenuItem(StreamTableAction.EXPORT_TO_PCAP); addMenuItem(StreamTableAction.EXPORT_TO_YAML); // add table view streamPacketTableView = new TableView<>(); streamPacketTableView.setId("streamTableView"); streamPacketTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); streamPacketTableView.setFixedCellSize(32); streamPacketTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); streamPacketTableView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { handleTableRowClick(event); } }); streamPacketTableView.getSelectionModel().selectedItemProperty() .addListener((ObservableValue<? extends TableProfileStream> observable, TableProfileStream oldValue, TableProfileStream newValue) -> { boolean notSelected = !(newValue != null); exportPcapButton.setDisable(notSelected); editPacketBtn.setDisable(notSelected); deleteButtonBtn.setDisable(notSelected); }); streamPacketTableView.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> { if (copyCombination.match(event)) { selectedProfile = tabledata.getProfiles() .get(streamPacketTableView.getSelectionModel().getSelectedIndex()); } else if (pasteCombination.match(event)) { handleDuplicateStream(); } else if (event.getCode() == KeyCode.DELETE) { handleDeletePacket(); } }); streamPacketTableView.setEditable(true); initializeTableColumn(); // disable table reordering streamPacketTableView.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> source, Number oldWidth, Number newWidth) { TableHeaderRow header = (TableHeaderRow) streamPacketTableView.lookup("TableHeaderRow"); header.reorderingProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { header.setReordering(false); } }); } }); getChildren().add(streamPacketTableView); setTopAnchor(streamPacketTableView, 35d); setBottomAnchor(streamPacketTableView, 5d); setLeftAnchor(streamPacketTableView, 0d); setRightAnchor(streamPacketTableView, 0d); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
private void addHeaders() { TableColumn colDate = new TableColumn(bundle.getString("colDate")); setMinMaxWidth(colDate, 75);/*from www . java2 s .c o m*/ colDate.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("date")); TableColumn colTime = new TableColumn(bundle.getString("colTime")); setMinMaxWidth(colTime, 75); colTime.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("time")); TableColumn colN = new TableColumn(bundle.getString("colN")); setMinMaxWidth(colN, 70); colN.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("nfiles")); TableColumn colFile = new TableColumn(bundle.getString("colFile")); setMinMaxWidth(colFile, 160); colFile.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("input")); TableColumn colErrors = new TableColumn(bundle.getString("colErrors")); setMinMaxWidth(colErrors, 65); colErrors.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("errors")); TableColumn colWarnings = new TableColumn(bundle.getString("colWarnings")); setMinMaxWidth(colWarnings, 85); colWarnings.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("warnings")); TableColumn colPassed = new TableColumn(bundle.getString("colPassed")); setMinMaxWidth(colPassed, 65); colPassed.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("passed")); colScore = new TableColumn(bundle.getString("colScore")); setMinMaxWidth(colScore, 75); colScore.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("score")); colFormats = new TableColumn(bundle.getString("colFormats")); setMinMaxWidth(colFormats, 120); colFormats .setCellValueFactory(new PropertyValueFactory<ReportRow, ObservableMap<String, String>>("formats")); colDelete = new TableColumn(bundle.getString("colDelete")); setMinMaxWidth(colDelete, 30); colDelete.setVisible(true); colDelete.setCellValueFactory(new PropertyValueFactory<>("delete")); tabReports.skinProperty().addListener((obs, oldSkin, newSkin) -> { TableHeaderRow header = (TableHeaderRow) tabReports.lookup("TableHeaderRow"); header.reorderingProperty().addListener((o, oldVal, newVal) -> header.setReordering(false)); }); tabReports.setPrefWidth(840.0); tabReports.setFixedCellSize(28.0); tabReports.getColumns().addAll(colDate, colTime, colN, colFile, colErrors, colWarnings, colPassed, colScore, colFormats, colDelete); tabReports.setCursor(Cursor.DEFAULT); tabReports.setEditable(false); tabReports.setMaxHeight(470.0); // Change column colors changeColumnTextColor(colDate, Color.LIGHTGRAY); changeColumnTextColor(colTime, Color.LIGHTGRAY); changeColumnTextColor(colFile, Color.LIGHTGRAY); changeColumnTextColor(colN, Color.CYAN); changeColumnTextColor(colErrors, Color.RED); changeColumnTextColor(colWarnings, Color.ORANGE); changeColumnTextColor(colPassed, Color.GREENYELLOW); changeColumnTextColor(colScore, Color.LIGHTGRAY); // Columns factories Bindings.size(tabReports.getItems()).addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { resizeTable(); } }); addChartScore(); addFormatIcons(); addDeleteIcon(); }
From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java
private void initDateArrays() { //populate arrays; datePickers[0] = date1;/* www .j a va2 s. c o m*/ datePickers[1] = date2; datePickers[2] = date3; datePickers[3] = date4; datePickers[4] = date5; datePickers[5] = date6; datePickers[6] = date7; dateChecks[0] = chkDay1; dateChecks[1] = chkDay2; dateChecks[2] = chkDay3; dateChecks[3] = chkDay4; dateChecks[4] = chkDay5; dateChecks[5] = chkDay6; dateChecks[6] = chkDay7; dayLabels[0] = lbl1; dayLabels[1] = lbl2; dayLabels[2] = lbl3; dayLabels[3] = lbl4; dayLabels[4] = lbl5; dayLabels[5] = lbl6; dayLabels[6] = lbl7; //set property to icrement all others if selected. datePickers[0].setOnAction(new EventHandler() { public void handle(Event t) { System.out.println("I've been touched!!!"); if (chkAutoInc.isSelected() && datePickers[0].getValue() != null) { for (int i = 1; i < dateChecks.length; i++) { datePickers[i].setValue(datePickers[i - 1].getValue().plusDays(1)); } } } }); //if the checkbox is checked after setting the date, trigger event. chkAutoInc.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { datePickers[0].fireEvent(new ActionEvent()); datePickers[0].setValue(datePickers[0].getValue()); } } }); for (int i = 0; i < datePickers.length; i++) { final int x = i; datePickers[i].valueProperty().addListener(new ChangeListener<LocalDate>() { @Override public void changed(ObservableValue<? extends LocalDate> observable, LocalDate oldValue, LocalDate newValue) { dates.set(x, newValue); dayLabels[x].setText(newValue.getDayOfWeek().name()); datePickers[x].setStyle("-fx-background-color: red"); dayLabels[x].setStyle("-fx-background-color: red"); } }); } //set select all functionality chkSelectAll.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { for (int i = 0; i < dateChecks.length; i++) { dateChecks[i].setSelected(newValue); } lblSelectAll.setText(newValue ? "Uncheck to: Unselect All" : "Check to: Select All"); } }); //default to include everything. chkSelectAll.setSelected(true); }
From source file:Main.java
private static CheckMenuItem createMenuItem(String title, final Node node) { CheckMenuItem cmi = new CheckMenuItem(title); cmi.setSelected(true);/* w w w . j a v a 2 s . co m*/ cmi.selectedProperty().addListener(new ChangeListener<Boolean>() { public void changed(ObservableValue ov, Boolean old_val, Boolean new_val) { node.setVisible(new_val); } }); return cmi; }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createAccount(ListView<String> to_update) { Stage createAccountStage = new Stage(); createAccountStage.initModality(Modality.APPLICATION_MODAL); //Set the stage info createAccountStage.setTitle("Add Server Account"); //Create a layout GridPane gp = new GridPane(); gp.setAlignment(Pos.CENTER);// w w w . jav a2s. c om gp.setVgap(10); gp.setHgap(10); gp.setPadding(new Insets(25, 25, 25, 25)); //Ads the important things Text welcome = new Text("Create Server Account"); welcome.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(welcome, 0, 0, 2, 1); Label username = new Label("Username"); Label password = new Label("Password"); Label r_password = new Label("Repeat Password"); TextField usernamefield = new TextField(); PasswordField passwordfield = new PasswordField(); PasswordField r_passwordfield = new PasswordField(); gp.add(username, 0, 1); gp.add(password, 0, 2); gp.add(r_password, 0, 3); gp.add(usernamefield, 1, 1); gp.add(passwordfield, 1, 2); gp.add(r_passwordfield, 1, 3); Text error = new Text(""); HBox error_box = new HBox(10); error_box.setAlignment(Pos.CENTER); error_box.getChildren().add(error); gp.add(error_box, 0, 4, 2, 1); Button finish = new Button("Finish"); finish.setDisable(true); HBox center_button = new HBox(10); center_button.setAlignment(Pos.CENTER); center_button.getChildren().add(finish); gp.add(center_button, 0, 5, 2, 1); ChangeListener name = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { finish.setDisable(true); if (usernamefield.getText().equals("")) { error.setFill(Color.RED); error.setText("Username can not be blank!"); } if (!passwordfield.getText().equals(r_passwordfield.getText())) { error.setFill(Color.RED); error.setText("Passwords do not match!"); } if (passwordfield.getText().equals("") && r_passwordfield.getText().equals("")) { error.setFill(Color.RED); error.setText("Passwords can not be blank!"); } if (passwordfield.getText().equals(r_passwordfield.getText()) && !usernamefield.getText().equals("") && !passwordfield.getText().equals("")) { error.setFill(Color.GREEN); error.setText("No issues."); finish.setDisable(false); } } }; usernamefield.textProperty().addListener(name); passwordfield.textProperty().addListener(name); r_passwordfield.textProperty().addListener(name); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { users.remove(usernamefield.getText()); users.add(usernamefield.getText()); userpasswords.put(usernamefield.getText(), passwordfield.getText()); to_update.setItems(FXCollections.observableArrayList(users)); createAccountStage.close(); } }); //Creates the scene Scene scene = new Scene(gp, 300, 275); scene.getStylesheets().add(this.getClass().getResource("login_css.css").toExternalForm()); createAccountStage.setScene(scene); createAccountStage.show(); }
From source file:org.yccheok.jstock.gui.news.StockNewsJFrame.java
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setAlwaysOnTop(true);/*from www.j a v a 2 s . co m*/ setAutoRequestFocus(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { } public void windowClosing(java.awt.event.WindowEvent evt) { NewsTask task = StockNewsJFrame.this.newsTask; if (task != null) { task.cancel(true); } } public void windowDeiconified(java.awt.event.WindowEvent evt) { } public void windowIconified(java.awt.event.WindowEvent evt) { } }); Platform.runLater(new Runnable() { @Override public void run() { // JFXPanel => Scene => SplitPane: // Left (news List) => StackPane => ListView / ProgressIndicator // Right (HTML content) => TabPane => Tab => StackPane => WebView / ProgressBar splitPane = new SplitPane(); scene = new Scene(splitPane); scene.getStylesheets() .add(StockNewsJFrame.class.getResource("StockNewsJFrame.css").toExternalForm()); jfxPanel.setScene(scene); // Left component: News List messages_o = FXCollections.observableArrayList(); newsListView = new ListView<>(messages_o); newsListView.setId("news-listview"); stackPane.setId("parent-stackPane"); stackPane.getChildren().addAll(newsListView, progressIn); splitPane.getItems().add(stackPane); SplitPane.setResizableWithParent(stackPane, Boolean.FALSE); // show progress indicator when loading progressIn.setMaxWidth(100); progressIn.setMaxHeight(100); progressIn.setVisible(true); newsListView.setVisible(true); newsListView.setCellFactory(new Callback<ListView<FeedItem>, ListCell<FeedItem>>() { @Override public ListCell<FeedItem> call(ListView<FeedItem> list) { return new DisplayNewsCard(); } }); // register event listener: add tab for news HTML content newsListView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() >= 1) { final FeedItem msg = newsListView.getSelectionModel().getSelectedItem(); if (msg == null) { return; } final URL link = msg.getLink(); if (link == null || link.getHost() == null) { return; } if (stockNewsContent == null) { stackPane.setPrefWidth(stackPane.getWidth()); stackPane.setMaxWidth(stackPane.getWidth()); stackPane.setMinWidth(stackPane.getWidth() / 5); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // resize JFrame first StockNewsJFrame.this.setSize(fullSize.width, fullSize.height); java.awt.Insets in = StockNewsJFrame.this.getInsets(); jfxPanel.setSize(StockNewsJFrame.this.getWidth() - in.left - in.right, jfxPanel.getHeight()); java.awt.Insets in2 = jfxPanel.getInsets(); // calculate width & height, but not resize in AWT event dispatching thread // javafx.scene.control.SplitPane should only be accessed from JavaFX Application Thread splitPaneWidth = jfxPanel.getWidth() - in2.left - in2.right; splitPaneHeight = jfxPanel.getHeight() - in2.top - in2.bottom; } }); } catch (InterruptedException | InvocationTargetException ex) { log.error(null, ex); } // resize to full screen size of jfxPanel splitPane.resize(splitPaneWidth, splitPaneHeight); stockNewsContent = new StockNewsContent(); splitPane.getItems().add(stockNewsContent.tabPane); splitPane.setDividerPositions(0.5f); stockNewsContent.tabPane.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<Tab>() { @Override public void changed(ObservableValue<? extends Tab> observable, Tab oldTab, Tab newTab) { int i = stockNewsContent.tabPane.getSelectionModel() .getSelectedIndex(); if (i < 0) { return; } jFrameTitle = stockNewsContent.tabsInfo.get(i).second; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { StockNewsJFrame.this.setTitle(jFrameTitle); } }); } }); } stockNewsContent.addNewsTab(link, StringEscapeUtils.unescapeHtml(msg.getTitle())); } } }); retrieveNewsInBackground(); } }); this.add(jfxPanel, BorderLayout.CENTER); this.setVisible(true); }