Java Code Examples for javafx.scene.control.TextField#addEventHandler()

The following examples show how to use javafx.scene.control.TextField#addEventHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodePane.java    From JRemapper with MIT License 6 votes vote down vote up
/**
 * Update the current selected class.
 * 
 * @param c
 *            The newly selected class.
 */
private void updateSelection(CDec c) {
	selectedDec = c;
	info.getChildren().clear();
	info.add(new Label("Class name"), 0, 0);
	TextField name = new TextField();
	if (c.hasMappings()) {
		name.setText(c.map().getCurrentName());
	} else {
		name.setText(c.getFullName());
		name.setEditable(false);
	}
	if (c.isLocked())
		name.setDisable(true);
	info.add(name, 1, 0);
	name.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
		if (KeyCode.ENTER == e.getCode()) {
			pass = -2;
			c.map().setCurrentName(name.getText());
			refreshCode();
			resetSelection();
			updateStyleAndRegions();
		}
	});
}
 
Example 2
Source File: CodePane.java    From JRemapper with MIT License 6 votes vote down vote up
/**
 * Update the current selected variable.
 *
 * @param v
 *            The newly selected variable.
 */
private void updateSelection(VDec v) {
	selectedDec = v;
	info.getChildren().clear();
	// Member
	TextField name = new TextField(v.map().getCurrentName());
	TextField desc = new TextField(v.getDesc());
	desc.setDisable(true);
	info.add(new Label("Variable name"), 0, 1);
	info.add(name, 1, 1);
	info.add(new Label("Variable desc"), 0, 2);
	info.add(desc, 1, 2);
	name.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
		if (KeyCode.ENTER == e.getCode()) {
			v.map().setCurrentName(name.getText());
			refreshCode();
			resetSelection();
			updateStyleAndRegions();
		}
	});
}
 
Example 3
Source File: DemoBrowser.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public DemoBrowser()
{
	super(DemoGenerator.BROWSER);
	setTitle("Browser / " + CSystem.getJavaVersion());
	
	addressField = new TextField();
	addressField.addEventHandler(KeyEvent.KEY_PRESSED, (ev) -> handleKeyTyped(ev));
	LocalSettings.get(this).add("URL", addressField);
	
	view = new WebView();
	view.getEngine().setOnError((ev) -> handleError(ev));
	view.getEngine().setOnStatusChanged((ev) -> handleStatusChange(ev));
	Worker<Void> w = view.getEngine().getLoadWorker();
	w.stateProperty().addListener(new ChangeListener<Worker.State>()
	{
		public void changed(ObservableValue v, Worker.State old, Worker.State cur)
		{
			log.debug(cur);
			
			if(w.getException() != null && cur == State.FAILED)
			{
				log.error(w.getException());
			}
		}
	});

	statusField = new Label();
	
	CPane p = new CPane();
	p.setGaps(10, 5);
	p.setCenter(view);
	p.setBottom(statusField);
	setContent(p);
	
	FX.later(() -> reload());
}