Java Code Examples for javafx.beans.value.ChangeListener

The following are top voted examples for showing how to use javafx.beans.value.ChangeListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: marathonv5   File: SearchBoxSample.java   Source Code and License 10 votes vote down vote up
public SearchBox() {
    setId("SearchBox");
    getStyleClass().add("search-box");
    setMinHeight(24);
    setPrefSize(200, 24);
    setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
    textBox = new TextField();
    textBox.setPromptText("Search");
    clearButton = new Button();
    clearButton.setVisible(false);
    getChildren().addAll(textBox, clearButton);
    clearButton.setOnAction(new EventHandler<ActionEvent>() {                
        @Override public void handle(ActionEvent actionEvent) {
            textBox.setText("");
            textBox.requestFocus();
        }
    });
    textBox.textProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            clearButton.setVisible(textBox.getText().length() != 0);
        }
    });
}
 
Example 2
Project: icewolf   File: IWURLField.java   Source Code and License 7 votes vote down vote up
public IWURLField(WebView webView, boolean secured, Tab tab) {
    this.webView = webView;
    this.tab = tab;
    this.securedHTTP = secured;
    setText(IWPropertyHelper.getProperty("default_homepage"));
    
    webView.getEngine().getLoadWorker().stateProperty().addListener(
    new ChangeListener<State>() {
        @Override
        public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
            if (newValue == State.SUCCEEDED) {
                tab.setText(webView.getEngine().getTitle());
            }
            
            if (newValue == State.FAILED) {
                if(getText().toString().equals("")) {
                    webView.getEngine().loadContent("<html><title>Empty Tab</title><body></body></html>");
                } else {
                    webView.getEngine().loadContent("<html><title>Oops!</title><body><b>Page not found!</b></body></html>");
                }
            }
        }
    });
}
 
Example 3
Project: OftenPorter   File: MenuItemBinder.java   Source Code and License 7 votes vote down vote up
public MenuItemBinder(MenuItem menuItem)
{
    super(menuItem);
    actionHandler = new EventHandler<ActionEvent>()
    {
        @Override
        public void handle(ActionEvent event)
        {
            onOccur();
        }
    };
    menuItem.addEventHandler(ActionEvent.ACTION,actionHandler);
    changeListener = new ChangeListener<String>()
    {
        @Override
        public synchronized void changed(ObservableValue<? extends String> observable, String oldValue,
                String newValue)
        {
            doOnchange(oldValue,newValue);
        }
    };
    menuItem.textProperty().addListener(changeListener);
}
 
Example 4
Project: Transport-Production-Issue   File: Controller.java   Source Code and License 6 votes vote down vote up
private void initSpinners() {
    ChangeListener<Integer> listener = (observable, oldValue, newValue) -> {
        int sup = suppliers.getValue();
        int rec = recipients.getValue();

        restoreMatrix(transport,sup,rec,true);
        restoreMatrix(result,sup,rec, false);
        restoreVector(capability,sup,true);
        restoreVector(production,sup, true);
        restoreVector(storage,sup, true);
        restoreVector(excess,sup, false);
        restoreVector(demand,rec, true);
    };
    suppliers.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1,6,1,1));
    recipients.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1,10,1,1));
    suppliers.valueProperty().addListener(listener);
    recipients.valueProperty().addListener(listener);
    listener.changed(null,null,null);
}
 
Example 5
Project: Money-Manager   File: TransactionHistoryController.java   Source Code and License 6 votes vote down vote up
private void showHisoty() {
	debug = new HistorySearch(cmboHistoryMonth.getValue(), cmboFilterList.getValue());

	webEngine.getLoadWorker().stateProperty().addListener(
       	    new ChangeListener<Worker.State>() {
       	        @Override
       	        public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
       	            if (newValue == Worker.State.SUCCEEDED) {
       	                JSObject windowObject = (JSObject) webEngine.executeScript("window");
       	                windowObject.setMember("HistorySearch", debug); // insert object
       	                windowObject.call("ready"); // execute callback
       	            }
       	        }
       	    }
       	);
       URL url = getClass().getResource("/html/index.html");
       webEngine.load(url.toString());
}
 
Example 6
Project: Squid   File: ExpressionManagerController.java   Source Code and License 6 votes vote down vote up
private void initializeExpressionsSortFilterChoiceBox() {
    expressionSorterChoiceBox.setItems(FXCollections.observableArrayList(ExpressionSortOrder.values()));
    expressionSorterChoiceBox.getSelectionModel().select(expressionSortOrder);
    expressionSorterChoiceBox.setConverter(new StringConverter<ExpressionSortOrder>() {
        @Override
        public String toString(ExpressionSortOrder object) {
            return object.getDisplayName();
        }

        @Override
        public ExpressionSortOrder fromString(String string) {
            return null;
        }
    });
    expressionSorterChoiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ExpressionSortOrder>() {
        @Override
        public void changed(ObservableValue observable, ExpressionSortOrder oldValue, ExpressionSortOrder newValue) {
            expressionSortOrder = newValue;
            populateExpressionsListView();
        }
    });
}
 
Example 7
Project: JavaFX-EX   File: SkinManager.java   Source Code and License 6 votes vote down vote up
public void bind(Dialog<?> dialog) {
  if (map.containsKey(dialog)) {
    return;
  }
  ChangeListener<? super SkinStyle> listener = (ob, o, n) -> {
    dialog.getDialogPane().getStylesheets().remove(o.getURL());
    dialog.getDialogPane().getStylesheets().add(n.getURL());
  };
  if (skin.get() != null) {
    dialog.getDialogPane().getStylesheets().add(skin.get().getURL());
  }
  skin.addListener(listener);
  map.put(dialog, listener);
  dialog.setOnHidden(e -> {
    skin.removeListener(listener);
    map.remove(dialog);
  });
}
 
Example 8
Project: Coconut-IDE   File: TreeUpdater.java   Source Code and License 6 votes vote down vote up
public ChangeListener<Boolean> expanderListener() {
    return (observable, oldValue, newValue) -> {
        BooleanProperty bb = (BooleanProperty) observable;

        TreeItem t = (TreeItem) bb.getBean();

        CustomIcons customIcons = new CustomIcons();
        t.setGraphic(new ImageView(newValue ? customIcons.getFolderExpandImage() : customIcons.getFolderCollapseImage()));

        if (newValue) {
            scheduleHighlight();
        }
    };
}
 
Example 9
Project: incubator-netbeans   File: WebViewBrowser.java   Source Code and License 6 votes vote down vote up
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
Example 10
Project: Cypher   File: Room.java   Source Code and License 6 votes vote down vote up
public void addAvatarListener(ChangeListener<? super Image> listener, int size) {
	//synchronized (avatarLock) {
		avatarListeners.add(listener);
		avatarWanted = true;
		if (size > avatarSize) {
			avatarSize = size;
		}
		try {
			updateAvatar();
		} catch (RestfulHTTPException | IOException e) {
			System.out.printf("Failed to load image %s%n", e.getMessage());
		}

		avatar.addListener(listener);
	//}
}
 
Example 11
Project: IO   File: BaseController.java   Source Code and License 6 votes vote down vote up
private static void makeLocationScale(Scene scene, Node node) {
    double nodeX = node.getLayoutX();
    double sceneWidth = scene.getWidth();
    double nodeY = node.getLayoutY();
    double sceneHeight = scene.getHeight();
    if (nodeX != 0.0) {
        ChangeListener<Number> xResizer = (arg0, oldValue, newValue) -> node.relocate(nodeX / sceneWidth * newValue.doubleValue(), node.getLayoutY());
        scene.widthProperty().addListener(xResizer);
    }
    if (nodeY != 0.0) {
        ChangeListener<Number> yResizer = (arg0, oldValue, newValue) -> node.relocate(node.getLayoutX(), nodeY / sceneHeight * newValue.doubleValue());
        scene.heightProperty().addListener(yResizer);
    }
}
 
Example 12
Project: marathonv5   File: SearchBoxSample.java   Source Code and License 6 votes vote down vote up
public SearchBox() {
    setId("SearchBox");
    getStyleClass().add("search-box");
    setMinHeight(24);
    setPrefSize(200, 24);
    setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
    textBox = new TextField();
    textBox.setPromptText("Search");
    clearButton = new Button();
    clearButton.setVisible(false);
    getChildren().addAll(textBox, clearButton);
    clearButton.setOnAction(new EventHandler<ActionEvent>() {                
        @Override public void handle(ActionEvent actionEvent) {
            textBox.setText("");
            textBox.requestFocus();
        }
    });
    textBox.textProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            clearButton.setVisible(textBox.getText().length() != 0);
        }
    });
}
 
Example 13
Project: twichat   File: Controller.java   Source Code and License 6 votes vote down vote up
@Override
  public void initialize(URL location, ResourceBundle resources) {
  	Main.bot.currentChannel = Main.bot.getChannels().get(0);
vbox.setSpacing(30);

      System.out.println("initialized");
      updateViewCount();
      
      new Timer().schedule(new TimerTask() {
	
	@Override
	public void run() {
		Platform.runLater(() -> { Controller.controller.viewCount
			.setText("Viewers: " + Main.bot.getChannels().get(0).getViewersNum()); });
		
	}
}, 0, 10000);

      vbox.heightProperty().addListener(new ChangeListener<Number>() {
	@Override
	public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
		scrollPane.setVvalue(1.0);
	}
});
      
  }
 
Example 14
Project: javafx-dataviewer   File: DataViewer.java   Source Code and License 6 votes vote down vote up
private void createView() {
	webView = new WebView();
       webView.setContextMenuEnabled(false);
	webEngine = webView.getEngine();
	webEngine.documentProperty().addListener(new ChangeListener<Document>() {
		@Override
		public void changed(ObservableValue<? extends Document> prop, Document oldDoc, Document newDoc) {
			logger.debug("WebView loaded dataviewer with id : [{}]", udID);
			if (enableFireBug)
				enableFirebug(webEngine);
		}
	});
	String urlToLoad = getUrlToLoad() + udID;
	logger.debug("Loading: [{}]", urlToLoad);
	webEngine.load(urlToLoad);

	setStyle("-fx-background-color: white;");
	setCenter(webView);
	setTop(topMenu = new TopMenu(plotData, latestConfig, this));
}
 
Example 15
Project: marathonv5   File: ProxyDialog.java   Source Code and License 6 votes vote down vote up
public void getDocsInBackground(final boolean showProxyDialogOnFail, final Runnable callBackOnSuccess) {
    final FetchDocListTask task = new FetchDocListTask(Ensemble2.getEnsemble2().getDocsUrl());
    task.stateProperty().addListener(new ChangeListener<Worker.State>() {
        public void changed(ObservableValue<? extends Worker.State> ov, Worker.State t, Worker.State newState) {
            try {
                Thread.sleep(5); //timing problem
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
            if (newState == Worker.State.SUCCEEDED) {
                // extract all the docs pages from the all classes page
                DocsHelper.extractDocsPagesFromAllClassesPage(
                        (CategoryPage)Ensemble2.getEnsemble2().getPages().getDocs(),
                        task.getValue(), 
                        Ensemble2.getEnsemble2().getDocsUrl());
                // update docs pages cross links to samples
                DocsHelper.syncDocPagesAndSamplePages(
                        (CategoryPage)Ensemble2.getEnsemble2().getPages().getSamples());
                if (callBackOnSuccess != null) callBackOnSuccess.run();
            } else if (newState == Worker.State.FAILED) {
                if (showProxyDialogOnFail) {
                    Ensemble2.getEnsemble2().showProxyDialog();
                }
            }
        }
    });
    new Thread(task).start();
}
 
Example 16
Project: WebPLP   File: WatcherWindow.java   Source Code and License 6 votes vote down vote up
@Subscribe
public void memoryWatchResult(MemWatchResponseEvent e) {
	if (!e.isSuccess())
		return;
	
	long address = e.getWatchedAddress();
	LongProperty value = e.getMemObject();
	value.addListener(new ChangeListener<Number>() {
		@Override
		public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
			watchedAddresses.refresh();
		}
		
	});
	MemoryRow row = new MemoryRow(address, value);
	memoryAddresses.add(row);
}
 
Example 17
Project: WebPLP   File: WatcherWindow.java   Source Code and License 6 votes vote down vote up
@Subscribe
public void registerWatchResult(RegWatchResponseEvent e) {
	if (!e.isSuccess())
		throw new IllegalArgumentException("There isn't a register with the name "
				+ e.getRegisterName());
	
	String id = e.getRegisterID();
	String registerName = e.getRegisterName();
	LongProperty register = e.getRegObject();
	register.addListener(new ChangeListener<Number>() {

		@Override
		public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
			watchedRegisters.refresh();
		}
		
	});
	RegisterRow row = new RegisterRow(registerName, id, register);
	registers.add(row);
}
 
Example 18
Project: IO   File: BaseController.java   Source Code and License 6 votes vote down vote up
private static void makeScalable(Scene scene, Region region) {
    double regionWidth = region.getPrefWidth();
    double sceneWidth = scene.getWidth();
    double regionHeight = region.getPrefHeight();
    double sceneHeight = scene.getHeight();
    if (regionWidth != -1.0) {
        ChangeListener<Number> widthResizer = (arg0, oldValue, newValue) -> region.setPrefWidth(regionWidth / sceneWidth * newValue.doubleValue());
        scene.widthProperty().addListener(widthResizer);
    }
    if (regionHeight != -1.0) {
        ChangeListener<Number> heightResizer = (arg0, oldValue, newValue) -> region.setPrefHeight(regionHeight / sceneHeight * newValue.doubleValue());
        scene.heightProperty().addListener(heightResizer);
    }
}
 
Example 19
Project: PSE   File: WinPreviewImageController.java   Source Code and License 6 votes vote down vote up
/**
 * Watch for the dimension value changes
 */
@Action
private void setValuePropertyComboBoxSize(){

    cBoxImgSize.valueProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            if(newValue.toString().equals("tamanho original")){
                dimensionImage.setWidth(getImage().getWidth());
                dimensionImage.setHeight(getImage().getHeight());
            }
            else {
                String size [] = newValue.toString().split("x");
                dimensionImage.setWidth(Double.parseDouble(size[0]));
                dimensionImage.setHeight(Double.parseDouble(size[1]));
            }

            System.out.println("Dim: "+ dimensionImage.getWidth() + " " + dimensionImage.getHeight());
        }
    });
}
 
Example 20
Project: IDBuilderFX   File: TemplateController.java   Source Code and License 6 votes vote down vote up
@Override
public void initialize(URL arg0, ResourceBundle arg1) {

	final Image tempImage = new Image(getClass().getResourceAsStream("/images/Valencia.jpg"));
	tempimg.setImage(tempImage);

	temprb.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
		public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
			if (temprb.getSelectedToggle() != null) {
				RadioButton chk = (RadioButton) old_toggle.getToggleGroup().getSelectedToggle();
				System.out.println("Selected Radio Button - " + chk.getText());
				final Image image = new Image(
						getClass().getResourceAsStream("/images/" + chk.getText().toString() + ".jpg"
				// Cast object to radio button
				// System.out.println("Selected Radio Button -
				// "+chk.getText());

				));
				tempimg.setImage(image);
			}
		}
	});
}
 
Example 21
Project: Netkit   File: Netkit.java   Source Code and License 6 votes vote down vote up
protected void initialize(boolean sync) {
    addJavascriptInterface("console", console);
    addJavascriptInterface("NetkitGateway", gateway);

    AtomicBoolean done = new AtomicBoolean(false);
    engine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
        @Override
        public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State oldValue, Worker.State newValue) {
            if (newValue == Worker.State.SUCCEEDED) {
                done.set(true);
            }
        }
    });

    String netkitView = IOUtils.convertStreamToString(Netkit.class.getResourceAsStream("/netkit-view.html"));
    engine.loadContent(netkitView);

    if (!done.get() && sync) {
        WebViewUtils.wait(view);
    }
}
 
Example 22
Project: GazePlay   File: ConfigurationContext.java   Source Code and License 6 votes vote down vote up
private static ChoiceBox<EyeTracker> buildEyeTrackerConfigChooser(Configuration configuration,
        ConfigurationContext configurationContext) {
    ChoiceBox<EyeTracker> choiceBox = new ChoiceBox<>();

    choiceBox.getItems().addAll(EyeTracker.values());

    EyeTracker selectedEyeTracker = findSelectedEyeTracker(configuration);
    choiceBox.getSelectionModel().select(selectedEyeTracker);

    choiceBox.setPrefWidth(prefWidth);
    choiceBox.setPrefHeight(prefHeight);

    choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<EyeTracker>() {
        @Override
        public void changed(ObservableValue<? extends EyeTracker> observable, EyeTracker oldValue,
                EyeTracker newValue) {
            final String newPropertyValue = newValue.name();
            ConfigurationBuilder.createFromPropertiesResource().withEyeTracker(newPropertyValue)
                    .saveConfigIgnoringExceptions();
        }
    });

    return choiceBox;
}
 
Example 23
Project: GazePlay   File: Son.java   Source Code and License 6 votes vote down vote up
public Son(Clavier clavier) {

        this.clavier = clavier;

        slider = new Slider(0, 127, 60);
        slider.setOrientation(Orientation.VERTICAL);
        slider.setTranslateY(35);
        slider.valueProperty().addListener(new ChangeListener() {
            @Override
            public void changed(ObservableValue o, Object oldVal, Object newVal) {
                clavier.requestFocus();
            }
        });

        ProgressIndicator indicateur = new ProgressIndicator(0.0);
        indicateur.progressProperty().bind(slider.valueProperty().divide(127.0));
        indicateur.setTranslateX(-15);

        this.getChildren().add(slider);
        this.getChildren().add(indicateur);
        this.setTranslateY(260);
        this.setTranslateX(60);

    }
 
Example 24
Project: Learning-RxJava   File: Ch2_13.java   Source Code and License 5 votes vote down vote up
private static <T> Observable<T> valuesOf(final
                                              ObservableValue<T> fxObservable) {
        return Observable.create(observableEmitter -> {
//emit initial state
            observableEmitter.onNext(fxObservable.getValue());
//emit value changes uses a listener
            final ChangeListener<T> listener = (observableValue, prev,
                                                current) -> observableEmitter.onNext(current);
            fxObservable.addListener(listener);
        });
    }
 
Example 25
Project: alchem   File: InventoryController.java   Source Code and License 5 votes vote down vote up
public void onChangingSearchOption() {
    searchGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> ov,
                            Toggle old_toggle, Toggle new_toggle) {
            if (searchGroup.getSelectedToggle() != null) {
                searchField.setText("");
            }
        }
    });

}
 
Example 26
Project: desktop-gmail-client   File: MainUI3Controller.java   Source Code and License 5 votes vote down vote up
public void setSentListView(){
    sentMessageListView = new JFXListView<>();
    sentMessageListView.setItems(GmailMessages.sentMessages);
    sentMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    sentMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    sentMessageListView.setExpanded(true);
    sentMessageListView.depthProperty().set(1);

    sentMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName, sentMessageListView.getSelectionModel().getSelectedIndex());
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
    /*ScrollBar listViewScrollBar = getListViewScrollBar(sentMessageListView);
    listViewScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
        double position = newValue.doubleValue();
        ScrollBar scrollBar = getListViewScrollBar(sentMessageListView);
        if (position == scrollBar.getMax()) {
            try {
                GmailMessages.sentMessages.addAll(GmailOperations.getSentMessages(10));
            } catch (IOException e) {
                e.printStackTrace();
                NotifyUser.getNotification("Internet connection has lost", "Please check your internet connection").showInformation();
            }
        }
    });*/
}
 
Example 27
Project: desktop-gmail-client   File: MainUI3Controller.java   Source Code and License 5 votes vote down vote up
public void setDraftListView(){
    draftMessageListView = new JFXListView<>();
    draftMessageListView.setItems(GmailMessages.draftMessages);
    draftMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    draftMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    draftMessageListView.setExpanded(true);
    draftMessageListView.depthProperty().set(1);

    draftMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName);
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
}
 
Example 28
Project: desktop-gmail-client   File: MainUI3Controller.java   Source Code and License 5 votes vote down vote up
public void setTrashListView(){
    trashMessageListView = new JFXListView<>();
    trashMessageListView.setItems(GmailMessages.trashMessages);
    trashMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    trashMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    trashMessageListView.setExpanded(true);
    trashMessageListView.depthProperty().set(1);

    trashMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName);
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
    /*ScrollBar listViewScrollBar = getListViewScrollBar(trashMessageListView);
    listViewScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
        double position = newValue.doubleValue();
        ScrollBar scrollBar = getListViewScrollBar(trashMessageListView);
        if (position == scrollBar.getMax()) {
            try {
                GmailMessages.trashMessages.addAll(GmailOperations.getTrashMessages(10));
            } catch (IOException e) {
                e.printStackTrace();
                NotifyUser.getNotification("Internet connection has lost", "Please check your internet connection").showInformation();
            }
        }
    });*/
}
 
Example 29
Project: FlashLib   File: LogWindow.java   Source Code and License 5 votes vote down vote up
private Scene loadScene(){
	BorderPane root = new BorderPane();
	
	textArea = new TextArea();
	textArea.setEditable(false);
	textArea.setPrefSize(300, 200);
	root.setCenter(textArea);
	BorderPane.setAlignment(root, Pos.CENTER);
	
	tabs = new TabPane();
	for (RemoteLog remoteLog : logs) {
		Tab tab = new Tab(remoteLog.getName());
		tab.setClosable(false);
		tabs.getTabs().add(tab);
	}
	if(tabs.getTabs().size() > 0){
		tabs.getSelectionModel().select(0);
		selectLog(0);
	}
	tabs.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>(){
		@Override
		public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
			selectLog(newValue.intValue());
		}
	});
	root.setTop(tabs);
	
	
	return new Scene(root, 450, 300);
}
 
Example 30
Project: H-Uppaal   File: EdgeController.java   Source Code and License 5 votes vote down vote up
private ChangeListener<Circular> getNewTargetCircularListener(final Edge newEdge) {
    // When the target location is set, finish drawing the edge
    return (obsTargetLocation, oldTargetCircular, newTargetCircular) -> {
        // If the nails list is empty, directly connect the source and target locations
        // otherwise, bind the line from the last nail to the target location
        final Link lastLink = links.get(links.size() - 1);
        final ObservableList<Nail> nails = getEdge().getNails();
        if (nails.size() == 0) {
            // Check if the source and target locations are the same, if they are, add proper amount of nails
            if (newEdge.getSourceCircular().equals(newTargetCircular)) {
                final Nail nail1 = new Nail(newTargetCircular.xProperty().add(4 * GRID_SIZE), newTargetCircular.yProperty().subtract(GRID_SIZE));
                final Nail nail2 = new Nail(newTargetCircular.xProperty().add(4 * GRID_SIZE), newTargetCircular.yProperty().add(GRID_SIZE));

                // Add the nails to the nails collection (will draw links between them)
                nails.addAll(nail1, nail2);

                // Find the new last link (updated by adding nails to the collection) and bind it from the last nail to the target location
                final Link newLastLink = links.get(links.size() - 1);
                BindingHelper.bind(newLastLink, simpleArrowHead, nail2, newTargetCircular);
            } else {
                BindingHelper.bind(lastLink, simpleArrowHead, newEdge.getSourceCircular(), newEdge.getTargetCircular());
            }
        } else {
            final Nail lastNail = nails.get(nails.size() - 1);
            BindingHelper.bind(lastLink, simpleArrowHead, lastNail, newEdge.getTargetCircular());
        }

        KeyboardTracker.unregisterKeybind(KeyboardTracker.ABANDON_EDGE);

        // When the target location is set the
        edgeRoot.setMouseTransparent(false);
    };
}
 
Example 31
Project: Squid   File: ExpressionManagerController.java   Source Code and License 5 votes vote down vote up
private void initializeExpressionsChoiceFilterChoiceBox() {
    expressionChooserChoiceBox.setItems(FXCollections.observableArrayList(ExpressionChoiceFilter.values()));
    expressionChooserChoiceBox.getSelectionModel().select(expressionChoiceFilter);
    expressionChooserChoiceBox.setConverter(new StringConverter<ExpressionChoiceFilter>() {
        @Override
        public String toString(ExpressionChoiceFilter object) {
            return object.getDisplayName();
        }

        @Override
        public ExpressionChoiceFilter fromString(String string) {
            return null;
        }
    });
    expressionChooserChoiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ExpressionChoiceFilter>() {
        @Override
        public void changed(ObservableValue observable, ExpressionChoiceFilter oldValue, ExpressionChoiceFilter newValue) {
            expressionChoiceFilter = newValue;
            populateExpressionsListView();
        }
    });
}
 
Example 32
Project: fx-animation-editor   File: SelectionListener.java   Source Code and License 5 votes vote down vote up
@Override
protected void onNodeAdded(NodeModel nodeModel) {
    ChangeListener<Boolean> listener = (v, o, n) -> onSelectionChanged(nodeModel);
    nodeModel.selectedProperty().addListener(listener);
    onSelectionChanged(nodeModel);
    listeners.put(nodeModel, listener);
}
 
Example 33
Project: hygene   File: SequenceVisualizerTest.java   Source Code and License 5 votes vote down vote up
/**
 * Set canvas.
 */

@Test
@SuppressWarnings("unchecked")
void testSetCanvasListener() {
    verify(canvasWidthProperty).addListener(any(ChangeListener.class));
}
 
Example 34
Project: IO   File: AdvancedOptionsController.java   Source Code and License 5 votes vote down vote up
@Override
protected void performSetup() {
    saveLocationField.focusedProperty().addListener((ChangeListener<Boolean>) (observable, oldValue, newValue) -> {
        if (newValue) {
            if (!wasSaveSet) {
                getDirectoryFromChooser();
            }
            else {
                wasSaveSet = false;
            }
        }
    });
}
 
Example 35
Project: springfx   File: FirstPresentation.java   Source Code and License 5 votes vote down vote up
@FXML
void initialize() {
    if (Language.RO.equals(langCtr.getLanguage())) {
        engRadio.setSelected(false);
        romRadio.setSelected(true);
    }
    langGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
            changeLanguage();
        }
    });
}
 
Example 36
Project: GestureFX   File: GesturePane.java   Source Code and License 5 votes vote down vote up
public GesturePane() {
	super();
	getStyleClass().setAll(DEFAULT_STYLE_CLASS);
	target.addListener((o, p, n) -> {
		if (n == null) return;
		content.set(null);
		runLaterOrNowIfOnFXThread(() -> {
			// TODO what if n is null?
			getChildren().removeIf(x -> !(x instanceof ScrollBar));
			n.setTransform(affine);
			targetWidth.set(n.width());
			targetHeight.set(n.height());
		});
	});

	final ChangeListener<Bounds> layoutBoundsListener = (o, p, n) -> {
		targetWidth.set(n.getWidth());
		targetHeight.set(n.getHeight());
	};
	content.addListener((o, p, n) -> {
		if (p != null)
			p.layoutBoundsProperty().removeListener(layoutBoundsListener);
		if (n == null) return;
		target.set(null);
		runLaterOrNowIfOnFXThread(() -> {
			// TODO what if n is null?
			getChildren().add(0, n);
			n.getTransforms().add(affine);
			n.layoutBoundsProperty().addListener(layoutBoundsListener);
			targetWidth.set(n.getLayoutBounds().getWidth());
			targetHeight.set(n.getLayoutBounds().getHeight());
		});
	});
}
 
Example 37
Project: MineIDE   File: ExplorerManagement.java   Source Code and License 5 votes vote down vote up
public ExplorerManagement(GuiProjectExplorer explorer)
{
    this.explorer = explorer;
    this.modes = Lists.newArrayList();

    this.explorer.getState().valueProperty()
            .addListener((ChangeListener<String>) (ov, oldValue, newValue) -> this.modes.forEach((mode) ->
            {
                if (mode.getName().equals(newValue))
                    this.setMode(mode);
            }));

}
 
Example 38
Project: marathonv5   File: TextValidatorSample.java   Source Code and License 5 votes vote down vote up
public TextInputValidatorPane() {
    contentProperty().addListener(new ChangeListener<C>() {                
        @Override public void changed(ObservableValue<? extends C> ov, C oldValue, C newValue) {
            if (oldValue != null) oldValue.textProperty().removeListener(textListener);
            if (newValue != null) newValue.textProperty().addListener(textListener);
        }
    });
}
 
Example 39
Project: Java-9-Programming-Blueprints   File: Controller.java   Source Code and License 5 votes vote down vote up
private void configureRuleFields() {
    ruleProperty = new RuleProperty();
    fields.getCheckModel().getCheckedItems().addListener(new RuleFieldChangeListener());

    final ChangeListener<Object> ruleChangeListener = 
        (observable, oldValue, newValue) -> rulesTableView.refresh();
    sourceFolder.textProperty().addListener(ruleChangeListener);
    destFolder.textProperty().addListener(ruleChangeListener);
    matchingText.textProperty().addListener(ruleChangeListener);
    age.textProperty().addListener(ruleChangeListener);
    type.getSelectionModel().selectedIndexProperty().addListener(ruleChangeListener);
}
 
Example 40
Project: marathonv5   File: ProxyDialog.java   Source Code and License 5 votes vote down vote up
public ProxyPanel() {
    setPadding(new Insets(8));
    setHgap(5.0F);
    setVgap(5.0F);

    int rowIndex = 0;

    Label label2 = new Label("Host Name");
    label2.setId("proxy-dialog-label");
    GridPane.setConstraints(label2, 0, rowIndex);

    Label label3 = new Label("Port");
    label3.setId("proxy-dialog-label");
    GridPane.setConstraints(label3, 1, rowIndex);
    getChildren().addAll(label2, label3);

    rowIndex++;
    hostNameBox = new TextField();
    hostNameBox.setPromptText("proxy.mycompany.com");
    hostNameBox.setPrefColumnCount(20);
    GridPane.setConstraints(hostNameBox, 0, rowIndex);

    portBox = new TextField();
    portBox.setPromptText("8080");
    portBox.setPrefColumnCount(10);
    GridPane.setConstraints(portBox, 1, rowIndex);

    ChangeListener<String> textListener = new ChangeListener<String>() {
        public void changed(ObservableValue<? extends String> ov, String t, String t1) {
            okBtn.setDisable(
                    hostNameBox.getText() == null || hostNameBox.getText().isEmpty()
                    || portBox.getText() == null || portBox.getText().isEmpty());
        }
    };
    hostNameBox.textProperty().addListener(textListener);
    portBox.textProperty().addListener(textListener);

    getChildren().addAll(hostNameBox, portBox);
}