How to focus on a node in a CustomMenuItem, so it can accept input from the keyboard

I have a ListView in a CustomMenuItem to a menu button.
The concept is that when you click on the menu button it shows the list view where the user can select an item, etc.

It works great except for one problem.
I want the user to be able to use the up/down keys to navigate in the ListView, but I can't find a way to give focus to the ListView when the user clicks the menu button and ListView is displayed.

Any ideas on how I can do this?
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.ListView;
import javafx.scene.control.MenuButton;
import javafx.stage.Stage;

public class JavaFXApplication1 extends Application {

    public static void main(String[] args) {
        Application.launch(args);
    }
    
    @Override
    public void start(Stage stage) {       
        ListView list = new ListView();
        list.getItems().addAll("First", "Second", "Third", "Fourth");
        
        CustomMenuItem menu = new CustomMenuItem(list);
        menu.setHideOnClick(false);

        MenuButton menuButton = new MenuButton("Show List");
        menuButton.getItems().add(menu);
        
        stage.setScene(new Scene(menuButton));
        stage.show();
    }
}

Development of transfer you can try the call the api requestFocus (http://download.oracle.com/javafx/2.0/api/javafx/scene/Node.html#requestFocus ()) on your instance of the ListView.

Sometimes, when I do this, I need to wrap the call requestFocus in a Platform.runLater construction http://download.oracle.com/javafx/2.0/api/javafx/application/Platform.html#runLater (java.lang.Runnable) to get the point to where I want to. I think that is because the other controls in the past of original provision sometimes seize the focus by default and replace at my request. Putting my request in Platform.runLater, my request seems to go through the queue and be the last thing that the runtime resumes to determine control of the development.

Tags: Java

Similar Questions

  • After you create a new playlist in iTunes, every song has the cover of the album and no box on the left side. How can I remove from the work and recover the box? TIA

    After you create a new playlist in iTunes, every song has the cover of the album and no box on the left side. How can I remove from the work and recover the box? TIA

    You can change the appearance of a selection by clicking on "reading list" in the upper right of the iTunes window. The desired view is probably "tracks"

  • Satellite 5205-s705: How can I boot from the CD/DVD drive

    I can't run Setup from my cd/dvd rom, there is no such option in the BIOS Setup. How can I boot from the cD or DVD?
    Please, help me!

    Hello

    You are not able to boot from the CD/DVD drive?
    If you are unable to change the boot order in the BIOS, I would advise you by pressing the F12 key immediately after starting the laptop.
    A start menu should appear, then you should be able to choose the reader of CD/DVD (ODD).

    You can also try clicking on the C instead of the F12 button. The C button the STRANGE start.

    Check this back and forth!

    Good luck

  • HOW CAN I TURN OFF THE KEYBOARD SCREEN. IE automatically stop coming.

    HOW CAN I TURN OFF THE KEYBOARD SCREEN. That is to say stop automatically come

    Hello

    ·         What is the operating system installed on the computer?

    Answer with the information above for you help.

  • How to detach the screen from the keyboard, and how do I use the touch screen without stylus?

    I have a gateway M285 ta6 t2300 clocked at 1.6 ghz dual core 1 GB 40 GB combo windows 7 tablet laptop 2-1 d. I don't have a pen for the touchscreen, but because I bought it used... I would like to know if I can use the touch screen using my fingers or do I have to buy a pen and if so what kind? Also, I would like to know how to detach the screen from the keyboard.

    Hello

    I suggest that you go to the Gateway Web site and download a manual for the model that will show you how to use it.

    Gateway:

    http://us.gateway.com/GW/en/us/content/drivers-downloads

    See you soon.

  • How can I boot from the Windows 7 Installation CD so that I can reformat the hard drive before reinstalling Windows 7?

    How can I boot from the Windows 7 Installation CD so that I can reformat the hard drive before reinstalling Windows 7?  I have already reinstalled Windows 7 from the CD, but that has not solved my problems.  When I put the factory CD in my CD player, it won't always boot from the CD.  When I put my Windows 7 Ultimate CD in the CD drive, it doesn't always start from the CD.         I realize that the reformatting is not always necessary, but I caught a few viruses (despite anti-virus running) and I need to start with a clean hard drive.

    On Friday, January 9, 2015 14:30:32 + 0000, BlueKodak wrote:

    How can I boot from the Windows 7 Installation CD so that I can reformat the hard drive before reinstalling Windows 7?  I have already reinstalled Windows 7 from the CD, but that has not solved my problems.  When I put the factory CD in my CD player, it won't always boot from the CD.  When I put my Windows 7 Ultimate CD in the CD drive, it doesn't always start from the CD.

    You must go into the BIOS and change the boot on CD order
    first push.

    How to get into your BIOS? It is not dependent on Windows, but on what he
    motherboard/BIOS card that you have. In fact, you need access to the
    BIOS before Windows begins to start. A common method is to press
    the key delete when you turn on first, but this is not necessarily true
    for your computer. Watch the display carefully when you start first;
    There is often a message here to tell you what to do. If this is not the case, check
    your system documentation or check with your provider.

  • How to do a system restore with windows 8. my mouse is not working but the keyboard works

    How to do a system restore with windows 8. my mouse does not work but the keyboard works.

    I've updated some drivers and now my mouse does not work

    Press the Windows key and press 'R '. Type "appwiz.cpl" without the quotes in the box run. Use the arrow keys to scroll down for updated drivers. When the driver is highlighted Press 'enter '. Use the arrow keys to select Yes in the uninstall confirmation dialog box. Restart the computer.

    You can run the restoration of the system from a command prompt if you are unable to uninstall the drivers. Press the Windows key and 'X', use the arrow keys to select the type of command (Admin) line "rstrui.exe" without the quotes. Use the arrow keys to navigate the windows system restore.

    Jim

  • How can I unsubscribe from the annual service? for my funds do not charge?

    I only use the software never and want to cancel your subscription. How can I unsubscribe from the annual service? for my funds was not charged?

    Contact adobe during the time pst support by clicking here and, when available, click on "still need help," http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • How to open a link text selected from the keyboard

    I would like to be able to search for text on a screen and then open the link that it connects to. The problem is that I want to do this via the keyboard, i.e. without moving the mouse. It seems that there should be a way to do this. I tried every combination of < meta-key > + back and all combinations of < meta-key > + down arrow I can think, because this seems like a natural place to hide such a shortcut, but nothing helps. Someone knows how to do this?

    Try this extension, and then the Enter key should work:

  • How to compose utf-8 characters from the keyboard (osx 10.11.4)?

    Hello

    In any other non-named operating system, you can press ALT-E28099 enter a utf character.

    I've seen instructions on how to do this in an earlier version of Mac OS x, but these instructions do not work.

    They tell me in system preferences | Language and text-> then a way to select UTF, but this possibility is therefore more in the new language and region settings.

    When I go to my little flag in the menu box above right, I am not shown UTF - 8 as a possibility.

    Help!

    Thank you!!!

    OS X does not use utf - 8 for entry.  Normally, you would use the character Viewer (Edit > Emoji and symbols) for the input characters that are not already included in the layout of the keyboard via the option and option more shift.  It has an option to display all Unicode characters.

    If you really want to enter special characters through numbers, you can go to the sources of the system/preferences/keyboard and activate the Unicode Hex keyboard configuration.  You can integrate any character by holding down the option key and typing sound 4-digit (or 8 digits for those outside the BMP) hexadecimal Unicode number.  e28099 is 2019 in hexadecimal.  It's the curly apostrophe which can also be made directly from the US keyboard via the shift option]

  • A40-201: How can I boot from the CD?

    Hello

    Can someone tell me how I can configure this laptop to boot from the CD?
    I try to go into the bios, but this option is not available... I'm trying to press F12... but also unsuccefull...

    Tanks in advance...

    Hello

    -Put the CD in the drive.
    -Stop the laptop.
    -Then turn on the laptop and immediately the key C.
    Now, the laptop should boot from the CD.

  • How can we record from the internet?

    HP Pavilion HPE h8 - 1360t, Windows 7 Home Premium 64 - bit SP1

    We tired Sound Recorder (supplied with the computer), Windows Media Player, Free Sound Recorder (which we always used on our old DELL), Audacity and others without success. The best we get is distorted and the volume is low. Search internet and support the application of various without a bit of luck.

    Hello

    To help us respond more quickly, please read this:

    http://h30434.www3.HP.com/T5/first-time-here-learn-how-to/welcome-get-started-here/TD-p/699035

    You can wat to try this:

    http://www.howtogeek.com/HOWTO/39532/how-to-enable-stereo-mix-in-Windows-7-to-record-audio/

    Kind regards.

  • How can I read from the InputStream when I use StreamConnectionNotifier

    I want to make a program that will listen on port 100 and exchange with PC message.

    And the program uses wifi to connect with the PC.

    I have StreamConnectionNotifier choice and I can receive request for socket of PC, but when I open imputStream, Exception throw.

    My code:

    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;

    Import javax.microedition.io.Connector;
    Import javax.microedition.io.StreamConnection;
    Import javax.microedition.io.StreamConnectionNotifier;

    SerializableAttribute public class ServerThread extends Thread {}
    constants
    private public static final String URL = ""http://:100;interface=wifi;deviceside=false "; "
    fields
    private StreamConnectionNotifier _notify;
    private InputStream _in;
    private OutputStream _out;
    private StreamConnection stream = null;
    private HelloWorld _app;
       
    Private boolean isStop = false;
     
    public ServerThread() {}
      
    }
     
    {} public void setApp (HelloWorld app)
    _APP = app;
    }
     
    public void run() {}
    try {}
    {while(!isStop)}
    {Synchronized (this)}
    _notify = Connector.open (URL) (StreamConnectionNotifier);
    }
    Stream = _notify.acceptAndOpen ();
    _in = stream.openDataInputStream ();  //<-- i="" think="" this="" line throw="" excepiton,="" excepiotn="" 's="" message="" is:request line="" is="">
    _out = stream.openDataOutputStream ();
    extract the data from the input stream
    StringBuffer sb = new StringBuffer();
    Reference int = - 1;
    {While (-1! = (reference = {_in.read ()))}
    Reference of the SB. Append ((Char));
    }
        
    _APP.updateText (SB. ToString());
        
    StringBuffer res = new StringBuffer();
    Res. Append ("HTTP/1.0 200 OK \r\n");
    Res. Append ("Content-type: text/html \r\n");
    Res. Append ("Content-Length: 1 \r\n");
    Res. Append ("1");
    _out. Write (res. ToString(). GetBytes());
        
    _in. Close();
    _out. Close();
    _notify. Close();
    }
    } catch (IOException e) {}
    probably the stream has been closed.
    System.Err.println (try ());
    _APP.updateText (try ());
    } {Finally
    try {}
    If (stream! = null) {}
    Stream.Close ();
    }
    } catch (Exception ex) {}
    }
    try {}
    If (_notify! = null) {}
    _notify. Close();
    }
    } catch (Exception ex) {}
    }
    }
    }
     
    {} public void stop()
    isStop = true;
    try {}
    If (stream! = null) {}
    Stream.Close ();
    }
    } catch (Exception ex) {}
    }
    try {}
    If (_notify! = null) {}
    _notify. Close();
    }
    } catch (Exception ex) {}
    }
    }

    }

    When I use IE application this port the program can block reading of inputStream.

    What's wrong? Please help me.

    What could happen is the following (Please check if this is the case however). Your code side device receives an incoming connection, but is then stuck on waiting for InputStream.read return anything. This translates your code aside PC it also blocks its BufferedReader.readLine, because the device-side code is not send anything (yet). So, you have a classic network impasse. If it is exactly what is happening, then you can try to fix the problem in several ways.

    1. change the code aside device to read byte-by-byte (int InputStream.read () instead of void InputStream.read (byte [],...)). It might help because on a few BlackBerrys the TCP stack returns the data received so that the stream is closed by a peer until you start viewing byte-by-byte.

    AND/OR

    2. change the PC-side code to close the output stream before reading the input stream (that's how works HTTP/1.0, for example). It might help because on a few BlackBerrys the TCP stack does not return data received until the stream is closed by a peer.

  • How to delete songs one copy of my hard drive? And keep them from the dupen yet!

    Some songs are in my media player five times also in my file of music several times

    Hello

    Please follow the steps mentioned below and check if it helps.

    Method 1:

    I would recommend you to rebuild the database of Windows Media Player and see if the problem is resolved.

    Here's how:

    To resolve this problem, delete the Windows Media Player database. To do this, follow these steps:

    a. exit Windows Media Player.

    b. Click Start, run, type %LOCALAPPDATA%\Microsoft\Media Playerand then click OK.

    c. Select all files in the folder and then click on Delete on the file menu.

    Note: You don't have to remove the folders that are in this folder.

    d. restart Windows Media Player.

    Note: Windows Media Player automatically rebuilds the database.

    Method 2: If this does not resolve the problem, disable the Windows Media Player database cache files.

    To do this, follow these steps:

    a. exit Windows Media Player.

    b. Click Start, run, type %LOCALAPPDATA%\Microsoftand then click OK.

    c. Select the Media Player folder, and then click on Delete on the file menu.

    d. restart Windows Media Player.

    Method 3:

    When you move digital media files on your computer, the file name and file path information remain unchanged in your library. Then when you select a file to play to its new location, a new entry is created in your library if you select the option automatically added to your library when played. As a result, your library can quickly contain a large number of entries, duplicate or invalid.

    To stop music files to be automatically added to your library.

    a. in Windows Media Player, on the Tools menu, click Options.

    b. on the Player tab, clear the files of music to add to the library when played check box.

    Now, when you play music on your computer or the Internet, the file will not be added automatically to your library.

    You can also consult the links below for more information.

    Remove items from the Windows Media Player library

    http://Windows.Microsoft.com/en-us/Windows7/remove-items-from-the-Windows-Media-Player-library

    The Windows Media Player library: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/Windows-Media-Player-library-frequently-asked-questions

    I hope the information is useful!

  • How can I disable under the keyboard mousepad?

    How can I disable the mouse under the keyboard pad?

    Press twice on the upper right of the touchpad in turen on or off.

    Your manual page 24

Maybe you are looking for