Solved

How to set the cursor in JComboBox

Posted on 2001-07-17
5
466 Views
Last Modified: 2010-05-18
I have a JComboBox which is an editable one.
after populating the data into the combobox,i want to set the cursor to the first element in the combo. How to do this.
0
Comment
Question by:Narendranath
  • 3
5 Comments
 
LVL 2

Accepted Solution

by:
dbaora earned 50 total points
ID: 6289234
try this:
JComboBox.setSelectedIndex(0);
regards,
dbaora.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6289257
probably :

yourCombo.setSelectedIndex(0);
and :
((JComponent)yourCombo.getEditor().getEditorComponent()).requestFocus();
or
((JTextField)yourCombo.getEditor().getEditorComponent()).requestFocus();
or
((JTextField)yourCombo.getEditor().getEditorComponent()).setCaretPosition(0);
or
((JTextComponent)yourCombo.getEditor().getEditorComponent()).setCaretPosition(0);

or any trick like this
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6791786
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.
____________________________________________

----------------------->>>>>>>>>>>>>>    Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.  Please let me know if no response the next 3 days.

NEW topic areas added Feb 8, 2002.  http://www.experts-exchange.com/jsp/zonesAll.jsp

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6795360
These are all your remaining open questions as of today, Narendranath

Please update and finalize them today.  If you need help to split points, or other special handling needs, just comment here with details and I'll respond when I can.

EXPERTS --- if Asker chooses not to respond, please provide me with feedback as to the fair outcome to close these.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20154148
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20152011
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20151333
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20149703
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20145043
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20144972
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20144884
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20144268

Thank you,
Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6798240
Finalized
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jboss 7.1 start up error 1 58
glassfish admin console 1 16
wild fly 8 startup error 2 37
IBM TS2900 (3572) Tape Autoloader Java? 12 52
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question