user3164187
user3164187

Reputation: 1432

TAB key functionality implementation in JTextArea

I am using rxtx library for serial communication and for GUI i have used JTextArea to display the input and output.

The implementation is similar to a terminal tool, where i am trying to implement TAB key functionality as same in linux console or in windows command prompt (the respective suggestions will be shown).

for e.g

if i type cd command and press TAB key all the suggestions will be shown or particular suggestion will get filled automatically in command line.

Is there any library available in JAVA to implement this functionality?

Please help.

Upvotes: 0

Views: 185

Answers (1)

StanislavL
StanislavL

Reputation: 57401

How To Add ShortCut Keys to JTextField?

The link shows how to add your own KeyBinding. You can do the same for TAB replacing default action with your own one.

In your custom action you can fill the suggestions list and show them in a JPopupMenu or in JComboBox where you need.

You should also read http://www.coderanch.com/t/482913/GUI/java/Tab-Key-Binding-JTextField That's an attempt to replace behaviour. TAB and SHIFT+TAB are used for focus so you could meet all the problems described.

Upvotes: 1

Related Questions