Assign focus on text field associated with tree item in edit mode

The JavaFX home page has an example for how to edit the label associated with a tree item using a cell factory (see sample code below). However, if you select a tree item and then either mouse click or select the Enter key to start editing, the text field doesn't get focus even though the startEdit() method invokes textField.selectAll(). I tried invoking textField.requestFocus(), but that didn't work. Is there a way to ensure that the text field gets focus when the tree item is in edit mode?
I'm using JavaFX 2.1 GA version on Windows 7.
Thanks.
Stefan
@Override
public void startEdit() {
super.startEdit();
if (textField == null) {
createTextField();
setText(null);
setGraphic(textField);
textField.selectAll();
public class TreeViewSample extends Application {
private final Node rootIcon =
new ImageView(new Image(getClass().getResourceAsStream("root.png")));
private final Image depIcon =
new Image(getClass().getResourceAsStream("department.png"));
List<Employee> employees = Arrays.<Employee>asList(
new Employee("Ethan Williams", "Sales Department"),
new Employee("Emma Jones", "Sales Department"),
new Employee("Michael Brown", "Sales Department"),
new Employee("Anna Black", "Sales Department"),
new Employee("Rodger York", "Sales Department"),
new Employee("Susan Collins", "Sales Department"),
new Employee("Mike Graham", "IT Support"),
new Employee("Judy Mayer", "IT Support"),
new Employee("Gregory Smith", "IT Support"),
new Employee("Jacob Smith", "Accounts Department"),
new Employee("Isabella Johnson", "Accounts Department"));
TreeItem<String> rootNode =
new TreeItem<String>("MyCompany Human Resources", rootIcon);
public static void main(String[] args) {
Application.launch(args);
@Override
public void start(Stage stage) {
rootNode.setExpanded(true);
for (Employee employee : employees) {
TreeItem<String> empLeaf = new TreeItem<String>(employee.getName());
boolean found = false;
for (TreeItem<String> depNode : rootNode.getChildren()) {
if (depNode.getValue().contentEquals(employee.getDepartment())){
depNode.getChildren().add(empLeaf);
found = true;
break;
if (!found) {
TreeItem<String> depNode = new TreeItem<String>(
employee.getDepartment(),
new ImageView(depIcon)
rootNode.getChildren().add(depNode);
depNode.getChildren().add(empLeaf);
stage.setTitle("Tree View Sample");
VBox box = new VBox();
final Scene scene = new Scene(box, 400, 300);
scene.setFill(Color.LIGHTGRAY);
TreeView<String> treeView = new TreeView<String>(rootNode);
treeView.setEditable(true);
treeView.setCellFactory(new Callback<TreeView<String>,TreeCell<String>>(){
@Override
public TreeCell<String> call(TreeView<String> p) {
return new TextFieldTreeCellImpl();
box.getChildren().add(treeView);
stage.setScene(scene);
stage.show();
private final class TextFieldTreeCellImpl extends TreeCell<String> {
private TextField textField;
public TextFieldTreeCellImpl() {
@Override
public void startEdit() {
super.startEdit();
if (textField == null) {
createTextField();
setText(null);
setGraphic(textField);
textField.selectAll();
@Override
public void cancelEdit() {
super.cancelEdit();
setText((String) getItem());
setGraphic(getTreeItem().getGraphic());
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
if (isEditing()) {
if (textField != null) {
textField.setText(getString());
setText(null);
setGraphic(textField);
} else {
setText(getString());
setGraphic(getTreeItem().getGraphic());
private void createTextField() {
textField = new TextField(getString());
textField.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent t) {
if (t.getCode() == KeyCode.ENTER) {
commitEdit(textField.getText());
} else if (t.getCode() == KeyCode.ESCAPE) {
cancelEdit();
private String getString() {
return getItem() == null ? "" : getItem().toString();
public static class Employee {
private final SimpleStringProperty name;
private final SimpleStringProperty department;
private Employee(String name, String department) {
this.name = new SimpleStringProperty(name);
this.department = new SimpleStringProperty(department);
public String getName() {
return name.get();
public void setName(String fName) {
name.set(fName);
public String getDepartment() {
return department.get();
public void setDepartment(String fName) {
department.set(fName);
Edited by: 882590 on May 22, 2012 8:24 AM
Edited by: 882590 on May 22, 2012 8:24 AM

When you click on a selected tree item to start the edit process is the text in the text field selected? In my case the text is not selected and the focus is not on the text field so I have to click in the text field before I can make a change, which makes it seem as if the method call textfield.selectAll() is ignored or something else gets focus after method startEdit() executes.

Similar Messages

  • How to identify field associated with a parameter ID

    Hi All,
    Im trying to identify the fields associated with different parameters ID in User Profile(SU3) transaction.
    \[removed by moderator\]
    Thanks
    Edited by: Jan Stallkamp on Aug 6, 2008 2:39 PM

    Hi,
    As provided by Atish has provided the required details for you.
    1. Table TPARA is where Parameter-ID's are defined.
    2. Table DD04L is where a parameter-ID is associated to data element.
    Note that all parameter-ID's that are defined are not necessarily to be used on data elements. We can define parameter-ID which can be used programatically instead of data elements.
    Considering your examples: BUK & F02 are used at data element definition whereas the others were not defined at data element but were used in Programs.
    Try doing a where-used list on the same and you will understand how they were used.

  • The vendor account you entered is not associated with the item you are trying to open. Try again.

    installed eBook and authorized on Adobe Digital Edition and was able to read eBook earlier.
    Due to some issue I had to reinstall the eBook. Now I am unable to read eBook it is asking for Authorization and when I input my Adobe ID and pass it gives message 'The vendor account you entered is not associated with the item you are trying to open .Try again'.
    I have wasted whole day trying fixing but it does not work, i wasted my money for purchasing eBook that works on Adobe Digital Edition which only adds complexity and wasting peoples time.
    Is there anyone who can help answering how can I fix vendor account not associated message issue, while i am entering correct Adobe ID and pass.

    installed eBook and authorized on Adobe Digital Edition and was able to read eBook earlier.
    Due to some issue I had to reinstall the eBook. Now I am unable to read eBook it is asking for Authorization and when I input my Adobe ID and pass it gives message 'The vendor account you entered is not associated with the item you are trying to open .Try again'.
    I have wasted whole day trying fixing but it does not work, i wasted my money for purchasing eBook that works on Adobe Digital Edition which only adds complexity and wasting peoples time.
    Is there anyone who can help answering how can I fix vendor account not associated message issue, while i am entering correct Adobe ID and pass.

  • "The vendor account you entered is not associated with the item you are trying to open.  Please try again".  How do I fix this?

    Digital editions is set-up and accepting books.  Everything seems fine except when I try to open the books, it asks for authorisation.  I enter the Adobe ID which works when I go into the Adobe site, but gives me the error "The vendor account you entered is not associated with the item you are trying to open.  Please try again".  How do I fix this?

    This is the Adobe Reader forum; please ask in the Digital Editions forum.

  • The Vendor account entered is not associated with the item you are trying to open

    Hi
    I moved from a Windows laptop to a Mac Book pro and moved all my files across, now I have found that two of my purchased books I can no longer open, I always get "The Vendor account entered is not associated with the item you are trying to open" message, I have the correct authorisation but they do not open, is theer a way to recover these 2 books?
    Thanks in advance

    This is the Adobe Reader forum; please ask in the Digital Editions forum.

  • The vendor account you entered is not associated with the item you are trying to open?

    the vendor account you
    entered is not associated with the item you are trying to open?

    This is the Adobe Reader forum; please ask in the Digital Editions forum.

  • The vendor account entered is not associated with the item you are tryingto open. I get this message when i want to open a downloaden book.

    The vendor account entered is not associated with the item you are trying to open. I get this message when i want to open a downloaded book.

    This is the Adobe Reader forum; please ask in the Digital Editions forum.

  • Hello, I need to authorize digital adobe (ID) so I can download a book but I get the following message "the account provider you entered is not associated with the item you are trying to open. Try again." what should I do? Thank

    Hello, I need to authorize digital adobe (ID) so I can download a book but I get the following message "the account provider you entered is not associated with the item you are trying to open. Try again." what should I do?
    Thank

    This is the Adobe Reader forum; please ask in the Digital Editions forum.

  • Hello,  I am trying to add a book to ADE.  I have previously read it on an Android device using an app called Aldiko.  Now when I try to open it up on my account I am getting the message "the vendor account you are entering is not associated with the item

    Hello,
    I am trying to add a book to ADE.  I have previously read it on an Android device using an app called Aldiko.  Now when I try to open it up on my account I am getting the message "the vendor account you are entering is not associated with the item you are trying to open".   Please help 

    This is the Adobe Reader forum; please ask in the Digital Editions forum.

  • Text Area steals Focus from Text Field when selected with mouse

    I have created a very simple form with 4 spry validation elements here :: http://octopusdesign.net/contactus.html
    When I attempt to select the 'Your Email' text field using the mouse, focus is grabbed by the text area above it.
    It is only possible to get focus on the 'Your Email' text field by using tab.
    My best guess is that this is a bug in the framework.
    In addition to updating my spry libraries to 1.6 from 1.4 I've tried the following things::
    Reordering the elements in the form.
    Creating the elements in a different order.
    Replacing the validation elements with ordinary elements.
    None of these fixed the problem.
    Strangely, if I remove the validation text area there is no problem.
    If anyone can shed some light on this I would really appreciate it.
    Wisdom gratefully received.
    Chris

    Furthermore ::
    I've tried to reconstruct the form from scratch and discovered that if you have a validation text field and a validation text area in any order on the form, selecting the 2nd element with the mouse always results in the first element stealing the focus.

  • Why do HOME and END ignore focus in text fields?

    I just noticed that the HOME and END keys seem to ignore focus in a text field on webpages.
    Normally, they go to the beginning and end of a webpage, which is perfectly fine with me. And in fact it's quite useful on really really long webpages.
    However, when my cursor is in a text field (“focused”), I expect HOME to go to the beginning of the line and END to go to the end of the line. However, this is not the case.
    1. Does anybody know why this is the case?
    2. Does anybody know if this can be changed to my desired behavior?

    Well, I'll be damned!
    I feel a bit sheepish, but I'd never noticed that that was the way Home and End worked everywhere. For some reason I had assumed it was Safari-only. Once I read your post, I was purposely mindful about the keys I was using, and I realized that I'd learned to automatically use ⌘← and ⌘→ when editing text elsewhere. Weird.
    I think this probably arose from the fact that my first Apple computer was a laptop, and since Home and End are built into the arrow keys on the smaller keyboard, I suppose it was enough to mask the difference.
    *Follow-up question:*
    Is there a technical / usability / official reason for this discrepancy? I remember being taught the function of Home and End in computer classes in Elementary School (late 80s and early 90s for me). Some of the computers in these classes were Apple and some where PCs. (I acknowledge that Apple during that time is not the same as Apple after Steve Jobs returned as CEO, but if the cause of this difference is Apple vs. Microsoft related, then I thought it was possibly relevant.)

  • Text field update with Vendor Account using APP F110

    Hi,
    If we want to populate vendor code and vendor name in text field of each payment line item while executing Automatic Payment Program, is it possible?
    What configuration changes needs to be done?
    I have tried the Substitution at the Complete Document Level but the system is not updating the doc.

    Hi
    transaction GGb1
    New entries - Company code, Line item, Enter a Name
    Environment - Substitution - Create yes
    Select your substitution name - Select create step on top
    Select 'Field assignment' - Text field
    Prerequisite - Transaction code = Constant "F110"
    Substitution - Text = LIFNR
    Activation of subtitution is done in making the Acctivation = 1 and Call up point = 2.
    Note : In the Payment Document the Bank account line items is showing Auto. created

  • Getting text ID and Text object  associated with item texts in PO...

    Hi,
    To print standard text on smartform for a given item in purchase order, I need to find the text ID and object associated with it.
    There are various texts like item text, Info record PO text, Material PO Text, Delievry Text, etc...
    Now when I go to ME22N, and select item detail for any item -> Texts , how do I get text ID, and object associated with it ?

    Hi ,
        Use table stxh,stxl
        FM read_text.
        you can view the text id by following
        this link
         me23->header-text-double click on text->menu goto->
         header        
    Regards
    Amole

  • How to get the UIDRef of Text frame associated with hyperlink?

    Hi,
    I have a document which contains Text hyperlinks . I am able to get the number of hyperlinks present in document using "IHyperlinkTable" and text range to which hyperlink is associated using interface "IHyperlink".
    InterfacePtr<IHyperlink> hyperlink(tableDb, table->GetNthHyperlink(i), IID_IHYPERLINK);
    if(hyperlink)
           hyperlink->GetName(&sHyperlinkName); //sHyperlinkName is text to which hyperlink is associated
    now I need to find the UIDRef of Text frame with which hyperlink is associated.
    I can get the UIDRef of "Image frame" using interface "IHyperlinkPageItemSourceData".
    InterfacePtr<IHyperlinkPageItemSourceData> sourceHyperLink (tableDb, hyperlink->GetSourceUID(), UseDefaultIID());
    if (sourceHyperLink)
            UID sourceHyperLinkUID  = sourceHyperLink->GetSourceUID();
    but this interface may be not helpful in case of text in the frame (word/words) associated with hyperlink.
    If anyone has done this please do let me know.
    Thank you all in advance.
    Priyanka

    Hi All,
    I am still unable to get the solution of this issue. If anyone has done this please help me to find the solution.
    Thanks in advance.
    Priyanka

  • Focus in text field

    Our client wants to make a change to a Forms 6 app so that when he goes to a text field (either by mouse or TAB from previous field), the existing value should be highlighted to that the first key stroke will start overwriting the previous value. This is how excel works.
    Right now, whenever he lands in a text field, it is in edit mode and he must first delete the value with backspaces and right/left cursor movements before entering a replacing value.
    Thanks.

    Forms is not excel. There is nothing like a "edit"-mode. The default-behaviour is, when you tab into a field, the whole content is "selected", and when you start typing the "old" value will be erased. The only way i know that not to happen is, as already mentioned, to set "Keep Cursor Position" to "Yes", which is not the default.

Maybe you are looking for

  • Can't access my external hard drive on my new iMac

    Hello All, I just purchased a brand new iMac and am unable to access my Iomaga external hard drive. It's plugged in thru a usb port and the only way it pops up is if I unplug it from the outlet and plug it back in. When it shows up in the device list

  • I was charged twice for the same order!

    I was charged twice for the same item; once for my online pre-order through BestBuy.com and again when I picked up the item at the Best Buy Store. I pre-ordered an Xbox One - Day One Edition from BestBuy.com on 09/02/2013. I scheduled to pick up the

  • Error at connect :Requested registry access is not allowed

    I have a Windows service running as a domain admin connecting with Client 10.2.0.100. My connection string look as follows : user id=xxx;data source=xxx;password=xxx;Statement Cache Size=30;Min Pool size=0 This error (Requested registry access is not

  • Mini with doc connector

    when i use my mini with my universal dock the volume automaticaly sets itself to a nonvariable volume. you can change the volume slider on the screen but it does not affect the output. i am having trouble because my stereo is all the way up and its n

  • Choose the answer

    Which two are attributes of /SQL*Plus? (Choose two) A. /SQL*Plus commands cannot be abbreviated. B. /SQL*Plus commands are accesses from a browser. C. /SQL*Plus commands are used to manipulate data in tables. D. /SQL*Plus commands manipulate table de