List of usage examples for javafx.event EventHandler EventHandler
EventHandler
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
public GCodeEditor(String tabText, Path path) { super(tabText); this.viewGroup = new Group(); this.editorContainer = new BorderPane(); this.viewContainer = new Pane(); this.caCodeArea = new CodeArea(""); this.caCodeArea.setEditable(true); this.caCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(caCodeArea)); this.caCodeArea.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE); // this.caCodeArea.getStylesheets().add(this.getClass().getResource("java-keywords.css").toExternalForm()); // this.caCodeArea.richChanges().subscribe(change -> { // caCodeArea.setStyleSpans(0, // computeHighlighting(caCodeArea.getText())); // });/*from w w w.j a v a 2 s . c o m*/ addContextMenu(this.caCodeArea); EventStream<Change<String>> textEvents = EventStreams.changesOf(caCodeArea.textProperty()); textEvents.reduceSuccessions((a, b) -> b, Duration.ofMillis(3000)).subscribe(code -> { if (autoCompile) { compile(code.getNewValue()); } }); if (path == null) { this.caCodeArea.replaceText("#empty"); } else { try { this.caCodeArea.replaceText(FileUtils.readFileToString(path.toFile())); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error reading file.", ex); } } // editorContainer.setCenter(this.codeArea); subScene = new SubScene(viewGroup, 100, 100, true, SceneAntialiasing.BALANCED); subScene.widthProperty().bind(viewContainer.widthProperty()); subScene.heightProperty().bind(viewContainer.heightProperty()); PerspectiveCamera subSceneCamera = new PerspectiveCamera(false); subScene.setCamera(subSceneCamera); viewContainer.getChildren().add(subScene); SplitPane editorPane = new SplitPane(caCodeArea, viewContainer); editorPane.setOrientation(Orientation.HORIZONTAL); BorderPane rootPane = new BorderPane(); BorderPane pane = (BorderPane) this.getTab().getContent(); toolBar = createToolBar(); rootPane.setTop(toolBar); rootPane.setCenter(editorPane); this.getTab().setContent(rootPane); subScene.setOnScroll(new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { System.out .println(String.format("deltaX: %.3f deltaY: %.3f", event.getDeltaX(), event.getDeltaY())); double z = subSceneCamera.getTranslateZ(); double newZ = z + event.getDeltaY(); subSceneCamera.setTranslateZ(newZ); } }); }
From source file:org.sandsoft.acefx.AceEditor.java
/** * Creates event listener. <br/>/*w w w . jav a 2 s.co m*/ * This uses the 'upcall' feature from java-script to java. * * @param editor */ private void setEventCatchers(JSObject editor) { //set interface object editor.setMember("mAceEvent", new AceEvents(this)); //on editor events editor.eval("this.on('blur', function() { editor.mAceEvent.onBlur(); });"); editor.eval("this.on('change', function(e) { editor.mAceEvent.onChange(e); });"); editor.eval( "this.on('changeSelectionStyle', function(e) { editor.mAceEvent.onChangeSelectionStyle(e); });"); editor.eval("this.on('changeSession', function(e) { editor.mAceEvent.onChangeSession(e); });"); editor.eval("this.on('copy', function(e) { editor.mAceEvent.onCopy(e); });"); editor.eval("this.on('focus', function() { editor.mAceEvent.onFocus(); });"); editor.eval("this.on('paste', function(e) { editor.mAceEvent.onPaste(e); });"); //on edit session events editor.eval( "this.getSession().on('changeAnnotation', function() { editor.mAceEvent.onChangAnnotation(); });"); editor.eval( "this.getSession().on('changeBackMarker', function() { editor.mAceEvent.onChangeBackMarker(); });"); editor.eval( "this.getSession().on('changeBreakpoint', function() { editor.mAceEvent.onChangeBreakpoint(); });"); editor.eval("this.getSession().on('changeFold', function() { editor.mAceEvent.onChangeFold(); });"); editor.eval( "this.getSession().on('changeFrontMarker', function() { editor.mAceEvent.onChangeFrontMarker(); });"); editor.eval("this.getSession().on('changeMode', function() { editor.mAceEvent.onChangeMode(); });"); editor.eval( "this.getSession().on('changeOverwrite', function() { editor.mAceEvent.onChangeOverwrite(); });"); editor.eval( "this.getSession().on('changeScrollLeft', function(e) { editor.mAceEvent.onChangeScrollLeft(e); });"); editor.eval( "this.getSession().on('changeScrollTop', function(e) { editor.mAceEvent.onChangeScrollTop(e); });"); editor.eval("this.getSession().on('changeTabSize', function() { editor.mAceEvent.onChangeTabSize(); });"); editor.eval( "this.getSession().on('changeWrapLimit', function() { editor.mAceEvent.onChangeWrapLimit(); });"); editor.eval("this.getSession().on('changeWrapMode', function() { editor.mAceEvent.onChangeWrapMode(); });"); editor.eval( "this.getSession().on('tokenizerUpdate', function(e) { editor.mAceEvent.onTokenizerUpadate(e); });"); addEventHandler(AceEvents.onChangeEvent, new EventHandler<Event>() { @Override public void handle(Event event) { undoButton.setDisable(!getUndoManager().hasUndo()); redoButton.setDisable(!getUndoManager().hasRedo()); } }); }
From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java
private void initDateArrays() { //populate arrays; datePickers[0] = date1;/*from ww w . ja v a 2s. 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: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);//from ww w . j a va 2 s . c o m 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:com.panemu.tiwulfx.table.TableControl.java
public TableControl(Class<R> recordClass) { this.recordClass = recordClass; initControls();//from www. j a v a2 s . co m tblView.getSortOrder().addListener(new ListChangeListener<TableColumn<R, ?>>() { @Override public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) { reload(); } }); btnAdd.disableProperty().bind(mode.isEqualTo(Mode.EDIT)); btnEdit.disableProperty().bind(mode.isNotEqualTo(Mode.READ)); btnSave.disableProperty().bind(mode.isEqualTo(Mode.READ)); btnDelete.disableProperty().bind(new BooleanBinding() { { super.bind(mode, tblView.getSelectionModel().selectedItemProperty(), lstChangedRow); } @Override protected boolean computeValue() { if ((mode.get() == Mode.INSERT && lstChangedRow.size() < 2) || tblView.getSelectionModel().selectedItemProperty().get() == null || mode.get() == Mode.EDIT) { return true; } return false; } }); tblView.editableProperty().bind(mode.isNotEqualTo(Mode.READ)); tblView.getSelectionModel().cellSelectionEnabledProperty().bind(tblView.editableProperty()); mode.addListener(new ChangeListener<Mode>() { @Override public void changed(ObservableValue<? extends Mode> ov, Mode t, Mode t1) { if (t1 == Mode.READ) { directEdit = false; } } }); tblView.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { lblRowIndex .setText(TiwulFXUtil.getLiteral("row.param", (page * maxResult.get() + t1.intValue() + 1))); } }); tblView.getFocusModel().focusedCellProperty().addListener(new ChangeListener<TablePosition>() { @Override public void changed(ObservableValue<? extends TablePosition> observable, TablePosition oldValue, TablePosition newValue) { if (tblView.isEditable() && directEdit && agileEditing.get()) { tblView.edit(newValue.getRow(), newValue.getTableColumn()); } } }); tblView.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ESCAPE) { directEdit = false; } else if (event.getCode() == KeyCode.ENTER && mode.get() == Mode.READ) { getController().doubleClick(getSelectionModel().getSelectedItem()); } } }); /** * Define policy for TAB key press */ tblView.addEventFilter(KeyEvent.KEY_PRESSED, tableKeyListener); /** * In INSERT mode, only inserted row that is focusable */ tblView.getFocusModel().focusedCellProperty().addListener(tableFocusListener); tblView.setOnMouseReleased(tableRightClickListener); if (Platform.isFxApplicationThread()) { cm = new ContextMenu(); cm.setAutoHide(true); setToolTips(); /** * create custom row factory that can intercept double click on grid row */ tblView.setRowFactory(new Callback<TableView<R>, TableRow<R>>() { @Override public TableRow<R> call(TableView<R> param) { return new TableRowControl(TableControl.this); } }); } columns.addListener(new ListChangeListener<TableColumn<R, ?>>() { @Override public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) { while (change.next()) { if (change.wasAdded()) { for (TableColumn<R, ?> column : change.getAddedSubList()) { initColumn(column); } } lastColumnIndex = getLeafColumns().size() - 1; } } }); attachWindowVisibilityListener(); }
From source file:com.panemu.tiwulfx.control.skin.LookupFieldSkin.java
private void initialize() { textField = new TextField(); textField.setFocusTraversable(true); textField.setEditable(!lookupField.getDisableManualInput()); textField.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override/* w w w. j av a2 s. c om*/ public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean hasFocus) { textField.selectEnd(); } }); button = new Button(); button.setFocusTraversable(false); button.setGraphic(TiwulFXUtil.getGraphicFactory().createLookupGraphic()); StackPane.setAlignment(textField, Pos.CENTER_LEFT); StackPane.setAlignment(button, Pos.CENTER_RIGHT); this.getChildren().addAll(textField, button); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (!lookupField.isFocused()) { /** * Need to make this control become focused. Otherwise * changing value in LookupColumn while the LookuField cell * editor * is not focused before, won't trigger commitEdit() */ lookupField.requestFocus(); } getSkinnable().showLookupDialog(); } }); updateTextField(); lookupField.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue ov, Object t, Object t1) { updateTextField(); } }); lookupField.markInvalidProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (oldValue && !newValue && needValidation) { validate(); } } }); textField.textProperty().addListener(new InvalidationListener() { @Override public void invalidated(Observable o) { if (detectTextChanged) { if (waitTimer != null) { loaderTimerTask.setObsolete(true); waitTimer.cancel(); waitTimer.purge(); } if (textField.getText() == null || textField.getText().trim().isEmpty()) { lookupField.setValue(null); return; } lookupField.markInvalidProperty().set(true); needValidation = true; if (lookupField.getShowSuggestionWaitTime() >= 0) { waitTimer = new Timer("lookupTimer"); loaderTimerTask = new LoaderTimerTask(waitTimer); waitTimer.schedule(loaderTimerTask, lookupField.getShowSuggestionWaitTime()); } } } }); }
From source file:io.uploader.drive.DriveUploader.java
@Override public void start(final Stage stage) throws Exception { Preconditions.checkNotNull(stage);/*from w w w . j a v a 2 s. c om*/ try { stage.onCloseRequestProperty().set(new EventHandler<WindowEvent>() { public void handle(WindowEvent e) { logger.info("Close request"); if (Response.NO == MessageDialogs.showConfirmDialog(stage, "Are you sure you want to close the application?", "Confirmation")) { e.consume(); return; } appEvent.exit(); Platform.exit(); // TODO: // Investigate why when we shutdown the authentication service // before the end of the process, the app hangs after closing the main window... // http://stackoverflow.com/questions/4425350/how-to-terminate-a-thread-blocking-on-socket-io-operation-instantly //if (client == null) { System.exit(0); //} } }); final List<Integer> logoSizeList = Arrays.asList(16, 32, 64, 128, 256, 512); final String logoNameBase = "DriveUploader"; final String logoNameExt = ".png"; for (Integer size : logoSizeList) { StringBuilder logoName = new StringBuilder(); logoName.append(logoNameBase); logoName.append(size); logoName.append(logoNameExt); Image logo = new Image(getClass().getResourceAsStream("/images/" + logoName)); stage.getIcons().add(logo); } //final Browser browser = new SimpleBrowser (new Stage (), null) ; final Browser browser = new SimpleBrowserImpl(stage, null); authorize(browser, new Callback<Credential>() { @Override public void onSuccess(Credential result) { logger.info("Received credential"); client = new Drive.Builder(httpTransport, JSON_FACTORY, result) .setApplicationName(APPLICATION_NAME).build(); Configuration.INSTANCE.setCredential(result); //browser.close () ; try { MainWindow mainWindow = new MainWindow(client, stage, appEvent, Configuration.INSTANCE); mainWindow.show(); } catch (IOException e) { logger.error("Error occurred while creating the main window", e); Platform.exit(); } } @Override public void onFailure(Throwable cause) { logger.error("Error occurred while authenticating", cause); Platform.exit(); } }); } catch (Exception e) { Platform.exit(); throw e; } }
From source file:de.unibw.inf2.fishification.FishWorld.java
private void registerKeys() { getWorldCanvas().setOnKeyPressed(new EventHandler<KeyEvent>() { @Override/* w w w . j av a 2 s . c o m*/ public void handle(KeyEvent keyEvent) { if (keyEvent.getCode().equals(KeyCode.DIGIT1)) { toggleFps(); } else if (keyEvent.getCode().equals(KeyCode.DIGIT2)) { toggleBackground(); } else if (keyEvent.getCode().equals(KeyCode.DIGIT3)) { toggleWaveEffect(); } else if (keyEvent.getCode().equals(KeyCode.DIGIT0)) { asyncTakeScreenshot(); } else if (keyEvent.getCode().equals(KeyCode.ENTER)) { feedFish("all"); } else if (keyEvent.getCode().equals(KeyCode.SPACE)) { togglePause(); } } }); }
From source file:org.noroomattheinn.visibletesla.LocationController.java
private Animation animateBlip() { final Circle core = new Circle(572, 360, 5); final Circle blip = new Circle(572, 360, 5); final Circle outline = new Circle(572, 360, 5); Duration blipTime = Duration.seconds(1.5); Duration interBlipTime = Duration.seconds(0.5); core.setFill(Color.BLUE);/*from ww w. j a v a 2 s . c o m*/ blip.setFill(Color.LIGHTBLUE); outline.setFill(Color.TRANSPARENT); outline.setStroke(Color.DARKBLUE); outline.setStrokeWidth(0.25); root.getChildren().addAll(blip, core, outline); FadeTransition fadeBlip = new FadeTransition(blipTime, blip); fadeBlip.setFromValue(0.8); fadeBlip.setToValue(0.0); ScaleTransition scaleBlip = new ScaleTransition(blipTime, blip); scaleBlip.setFromX(1); scaleBlip.setToX(4); scaleBlip.setFromY(1); scaleBlip.setToY(4); FadeTransition fadeOutline = new FadeTransition(blipTime, outline); fadeOutline.setFromValue(1.0); fadeOutline.setToValue(0.0); ScaleTransition scaleOutline = new ScaleTransition(blipTime, outline); scaleOutline.setFromX(1); scaleOutline.setToX(4); scaleOutline.setFromY(1); scaleOutline.setToY(4); SequentialTransition sequence = new SequentialTransition( new ParallelTransition(fadeBlip, scaleBlip, scaleOutline, fadeOutline), new PauseTransition(interBlipTime)); sequence.setCycleCount(Timeline.INDEFINITE); sequence.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { core.setVisible(false); blip.setVisible(false); outline.setVisible(false); } }); sequence.play(); return sequence; }
From source file:open.dolphin.client.MainWindowController.java
/** * Initializes the controller class./*from w w w . ja v a2 s. c om*/ * * @param url * @param rb */ @Override public void initialize(URL url, ResourceBundle rb) { //- Init TableView ReceptView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); PatientSearchView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); PatientFutureView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); LabRecieverView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // mainTab.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { // @Override // public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) { // SingleSelectionModel<Tab> selectionModel = mainTab.getSelectionModel(); // if(mainTab.getTabs() != null){ // if(selectionModel.isSelected(0)){ // karteTabPane.getTabs().clear(); // } // } // } // }); // ????? TableColumn colId = new TableColumn("ID"); recept.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("recept")); visitTime.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("visitTime")); tableCellAlignRight(visitTime); clientId.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("clientId")); name.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("name")); sex.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("sex")); tableCellAlignCenter(sex); insurance.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("insurance")); birthDay.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("birthDay")); physicianInCharge.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("physicianInCharge")); clinicalDepartments .setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("clinicalDepartments")); reservation.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("reservation")); memo.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("memo")); status.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("status")); tableCellImageAlignCenter(status); // ???? ReceptView.getItems().setAll(fetchDataFromServer()); // ???(?) ReceptView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); ReceptInfo selectedUser = ((TableView<ReceptInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); // ?????????? for (ReceptInfo info : receptList) { if (info.getName().equals(selectedUser.getName())) { return; } } System.out.println(selectedUser.getClientId()); receptList.add(selectedUser); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane.getTabs().remove(karteTabPane.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane.getTabs().remove(karteTabPane.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getName()); tab.setOnClosed(new EventHandler<Event>() { @Override public void handle(Event t) { Tab tab = (Tab) t.getSource(); for (int i = 0; i < receptList.size(); i++) { if (tab.getText().equals(receptList.get(i).getName())) { receptList.remove(i); } } System.out.println("Closed!"); } }); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane.getSelectionModel().select(tab); karteTabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane.getTabs().add(tab); karteTabPane.setPrefSize(kartePane.getPrefWidth(), kartePane.getPrefHeight()); kartePane.getChildren().retainAll(); kartePane.getChildren().add(karteTabPane); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ???? clientId1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("clientId1")); name1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("name1")); kana1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("kana1")); sex1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("sex1")); birthDay1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("birthDay1")); receiveDay1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("receiveDay1")); status1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("status1")); // dummy? PatientSearchView.getItems().setAll(fetchDataFromPatientInfo()); // ??(?) PatientSearchView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); PatientSearchInfo selectedUser = ((TableView<PatientSearchInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); // ?????????? for (PatientSearchInfo info : patientSearchList) { if (info.getName1().equals(selectedUser.getName1())) { return; } } System.out.println(selectedUser.getKana1()); patientSearchList.add(selectedUser); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane1.getTabs().remove(karteTabPane1.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane1.getTabs().remove(karteTabPane1.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getName1()); tab.setOnClosed(new EventHandler<Event>() { @Override public void handle(Event t) { Tab tab = (Tab) t.getSource(); for (int i = 0; i < patientSearchList.size(); i++) { if (tab.getText().equals(patientSearchList.get(i).getName1())) { patientSearchList.remove(i); } } System.out.println("Closed!"); } }); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane1.getSelectionModel().select(tab); karteTabPane1.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane1.getTabs().add(tab); karteTabPane1.setPrefSize(kartePane1.getPrefWidth(), kartePane1.getPrefHeight()); kartePane1.getChildren().retainAll(); kartePane1.getChildren().add(karteTabPane1); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ???? clientId2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("clientId2")); name2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("name2")); kana2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("kana2")); insurance2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("insurance2")); sex2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("sex2")); birthDay2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("birthDay2")); physicianInCharge2 .setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("physicianInCharge2")); clinicalDepartments2 .setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("clinicalDepartments2")); karte2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("karte2")); // dummy? PatientFutureView.getItems().setAll(fetchDataFromPatientFutureInfo()); // ??(?) PatientFutureView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); PatientFutureInfo selectedUser = ((TableView<PatientFutureInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); System.out.println(selectedUser.getName2()); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane2.getTabs().remove(karteTabPane2.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane2.getTabs().remove(karteTabPane2.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getName2()); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane2.getSelectionModel().select(tab); karteTabPane2.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane2.getTabs().add(tab); karteTabPane2.setPrefSize(kartePane2.getPrefWidth(), kartePane2.getPrefHeight()); kartePane2.getChildren().retainAll(); kartePane2.getChildren().add(karteTabPane2); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ????? lab3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("lab3")); clientId3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("clientId3")); kana3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("kana3")); karteKana3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("karteKana3")); sex3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("sex3")); karteSex3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("karteSex3")); sampleGetDay3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("sampleGetDay3")); register3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("register3")); status3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("status3")); // dummy? LabRecieverView.getItems().setAll(fetchDataFromLabRecieverInfo()); // ???(?) LabRecieverView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); LabReceiverInfo selectedUser = ((TableView<LabReceiverInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); System.out.println(selectedUser.getKana3()); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane3.getTabs().remove(karteTabPane3.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane3.getTabs().remove(karteTabPane3.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getKana3()); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane3.getSelectionModel().select(tab); karteTabPane3.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane3.getTabs().add(tab); karteTabPane3.setPrefSize(kartePane3.getPrefWidth(), kartePane3.getPrefHeight()); kartePane3.getChildren().retainAll(); kartePane3.getChildren().add(karteTabPane3); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ??5?????? Timer exeTimer = new Timer(); Calendar cal = Calendar.getInstance(); final int sec = cal.get(Calendar.SECOND); int delay = (60 - sec) * 1000; int interval = 5 * 1000; TimerTask task = new TimerTask() { @Override public void run() { if (!stopFlag) { System.out.println("this is called every 5 seconds on UI thread"); receptUpdate(); } else { this.cancel(); } } }; exeTimer.schedule(task, delay, interval); }