Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

select text in JComboBox

Thread view: 
Roger Levy - 12 Dec 2003 15:48 GMT
When I open my editable JComboBox I want the text for the displayed item
to be selected in the sense that any typing would replace the text.  In
most applications selection can be achieved by sweeping across the text
with the left mouse button pressed or by using SHIFT and the LEFT or
RIGHT arrow key.  So in my application I created KeyEvents with key
codes for VK_SHIFT and IDs KEY_PRESSED and KEY_RELEASED and for VK_LEFT
with IDs KEY_PRESSED and KEY_RELEASED.  I sent these events to my combo
box via dispatchEvent.  I used exactly the same sequence of presses and
releases that I was able to observe to select text in the combo box when
I selected it manually and monitored the events by handling them in
KeyAdapter.  The result was that the cursor moved across the text but
did not select it.  Can anyone tell me why the selection did not happen?
 Note: I am using Java 1.2 (it's a Visual Cafe tools limitation) so
although I know that the Robot class might be useful in this case it is
not available to me.

Roger
Andrew Thompson - 12 Dec 2003 16:08 GMT
...
>   Note: I am using Java 1.2 (it's a Visual Cafe tools limitation) so
> although I know that the Robot class might be useful in this case it is
> not available to me.

All thought of looking further into the
problem ceased when I read that.

Toss Visual Cafe, install the latest JDK,  develop
from the command line. Then the problems will
probably vanish, and if they don't, you will at
least you will be able to consult with developers
that do not have to think back to ..whenever the
heck they last used java 1.2

HTH

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Andrew Thompson - 12 Dec 2003 16:15 GMT
> ...
> >   Note: I am using Java 1.2 (it's a Visual Cafe tools limitation) so
[quoted text clipped - 3 lines]
> All thought of looking further into the
> problem ceased when I read that.
<snip rant>

OK.  So maybe I am railing at a separate
thread I am having about Eclipse hassles
on c.l.j.p.

And, sorry, no - I have no _good_ ideas
that might solve your immediate dilemma..

[ N.B. I would still recommend dropping
an IDE that is no longer supported, though.  ]

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
ak - 14 Dec 2003 23:22 GMT
JComboBox jcb = ...
JTextField field = (JTextField)jcb.getEditor().getEditorComponent();
field.selectAll();
or
field.setSelectionStart(start);
field.setSelectionEnd(end);

--

____________

http://reader.imagero.com the best java image reader.

> When I open my editable JComboBox I want the text for the displayed item
> to be selected in the sense that any typing would replace the text.  In
[quoted text clipped - 13 lines]
>
> Roger


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.