How to get index of currently focussed element in JComboBox

Hello
I have an editable JComboBox and i have the following property set on it
"JComboBox.lightweightKeyboardNavigation","Lightweight". THis enables the user to traverse using arrow keys without actually selecting each time.
In this case how do i find out which element or value is in focus because the value in focus may be different from the selected value in the combo box.
Please help!!!!!!!!
Gunjan

Try this:
import java.awt.event.KeyEvent;
import java.util.Vector;
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
public class LightWeightComboBox extends JComboBox {
private int m_intSelectedIndex;
public LightWeightComboBox() {
super();
init();
public LightWeightComboBox(ComboBoxModel aModel) {
super(aModel);
init();
public LightWeightComboBox(Object[] items) {
super(items);
init();
public LightWeightComboBox(Vector items) {
super(items);
init();
private void init() {
// Enable lightweight keyboard navigation.
putClientProperty("JComboBox.lightweightKeyboardNavigation", "Lightweight"); // JDK 1.3
putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // JDK 1.4
public void showPopup() {
m_intSelectedIndex = getSelectedIndex();
super.showPopup();
private void updateSelectedIndex(int intKeyCode) {
if (intKeyCode == KeyEvent.VK_UP) {
m_intSelectedIndex--;
if (m_intSelectedIndex < 0) {
m_intSelectedIndex = 0;
else if (intKeyCode == KeyEvent.VK_DOWN) {
m_intSelectedIndex++;
if (m_intSelectedIndex > (getItemCount()-1)) {
m_intSelectedIndex = getItemCount()-1;
public void processKeyEvent(KeyEvent e) {
if (isPopupVisible()) {
if ( (e.getID() == KeyEvent.KEY_RELEASED) && ( (e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN) ) ) {
updateSelectedIndex(e.getKeyCode());
else if ( (e.getID() == KeyEvent.KEY_RELEASED) && ( (e.getKeyCode() == KeyEvent.VK_SPACE) || (e.getKeyCode() == KeyEvent.VK_ENTER) ) ) {
hidePopup();
setSelectedIndex(m_intSelectedIndex);
else if ( (e.getID() == KeyEvent.KEY_RELEASED) && ( (e.getKeyCode() == KeyEvent.VK_DOWN) || (e.getKeyCode() == KeyEvent.VK_SPACE) || (e.getKeyCode() == KeyEvent.VK_ENTER) ) ) {
showPopup();
if ( (e.getKeyCode() != KeyEvent.VK_ENTER) && (e.getKeyCode() != KeyEvent.VK_SPACE) ) {
super.processKeyEvent(e);
}

Similar Messages

  • How to get Index of a single element in a table

    Hi Gurus,
    I need to get the index number of the element in a table even if the row is not selected.
    I've already searched the forum for this but all i'm getting are selected rows in the table.  I need to get the index even if that elemen's row is not selected in the table.
    Please advise.
    Regards,

    Hi,
    Could you please specify what exactly you want to do?
    You said you want to get the index of an element even if the corresponding row is not selected. But there might be more than one element where the correponding rows are not selected. So it would be better if you could be more specific about what you want to achieve.
    Regards,
    Srilatha

  • How to get audio into Adobe Premiere Elements 12?

    How to get audio into Adobe Premiere Elements 12?
    I have filmed an air show with a very good camera JVC pro
    And when I pick up the clips in Adobe Premiere Elements 12, it works too, but only without sound.
    I think I tried everything for 4 days now.
    Sound in my computer works perfectly
    I go to where the video files are located and try to run them in VLC or in Nero Kwik so it works fine with both audio and video.
    I have checked the sound card.
    Yes, I have tried everything so now I'm so tired of this lousy so I'm ready to throw this program at the dump.
    It's not normal if you will keep on producing audio for over 4 days at Adobe
    The old Elements 9 worked fine. Offer some of would consider developing it again. I do not know how I should do.
    My name is Thore Hult
    live in Karlshamn in Sweden

    Thore Hult
    On what computer operating system is your Premiere Elements 12 working on? Have you updated it from 12 to 12.1 Update using an opened project's Help Menu/Update. If not, please do so.
    For your immediate problem.
    What is the model/settings for the JVC camera that recorded you video. I want to get at the properties of your source video including the file extension.
    Since you are getting video, but no audio, please download and install the free codec utility named GSpot to see what is shows
    for your Audio Name and Status.
    http://www.headbands.com/gspot/
    The other properties of the file there would also be of interest.
    When you import your source file into the project, do you see any "conforming" activity going in a progress bar at the bottom right corner of the workspace?
    If so, do you wait for it to complete before you move forward in the project?
    Can you get sound in any of your Premiere Elements projects with this current JVC file or other?
    Can we assume that your troubleshooting has included checking
    a. Volume control within the project
    b. Edit Menu/Preferences/Audio Hardware ASIO
    Let us start here and then we can decide what next if necessary.
    Thanks.
    ATR

  • How to get the values of all elements and sub elements from  following xml

    how to get the values of all elements and sub elements from following xml...
    <?xml version="1.0" encoding="UTF-8" ?>
    <List_AML_Finacle xmlns="http://3i-infotech.com/Cust_AML_Finacle.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://3i-infotech.com/Cust_AML_Finacle.xsd List_AML_Finacle.xsd">
    <TransactionID>TransactionID</TransactionID>
    <Match>
    <Src_Matched_Field>Src_Matched_Field</Src_Matched_Field>
    <List_Matched_Field>
    <FSFM_Matches>
    <NUMBER>NUMBER</NUMBER>
    <TERROR>TERROR</TERROR>
    <TU>TU</TU>
    <NAMEU>NAMEU</NAMEU>
    <DESCRIPT>DESCRIPT</DESCRIPT>
    <KODCR>KODCR</KODCR>
    <KODCN>KODCN</KODCN>
    <AMR>AMR</AMR>
    <ADDRESS>ADDRESS</ADDRESS>
    <SD>SD</SD>
    <RG>RG</RG>
    <ND>ND</ND>
    <VD>VD</VD>
    <GR>GR</GR>
    <YR>YR</YR>
    <MR>MR</MR>
    <CB_DATE>CB_DATE</CB_DATE>
    <CE_DATE>CE_DATE</CE_DATE>
    <DIRECTOR>DIRECTOR</DIRECTOR>
    <FOUNDER>FOUNDER</FOUNDER>
    <TERRTYPE>TERRTYPE</TERRTYPE>
    </FSFM_Matches>
    <OfacMatchDetails>
    <UID>UID</UID>
    <TITLE>TITLE</TITLE>
    <SDNTYPE>SDNTYPE</SDNTYPE>
    <REMARKS>REMARKS</REMARKS>
    <ID_UID>ID_UID</ID_UID>
    <IDTYPE>IDTYPE</IDTYPE>
    <IDNUMBER>IDNUMBER</IDNUMBER>
    <IDCOUNTRY>IDCOUNTRY</IDCOUNTRY>
    <ISSUEDATE>ISSUEDATE</ISSUEDATE>
    <EXPIRATIONDATE>EXPIRATIONDATE</EXPIRATIONDATE>
    <ADDRESS1>ADDRESS1</ADDRESS1>
    <ADDRESS2>ADDRESS2</ADDRESS2>
    <ADDRESS3>ADDRESS3</ADDRESS3>
    <CITY>CITY</CITY>
    <STATEORPROVINCE>STATEORPROVINCE</STATEORPROVINCE>
    <POSTALCODE>POSTALCODE</POSTALCODE>
    <COUNTRY>COUNTRY</COUNTRY>
    </OfacMatchDetails>
    </List_Matched_Field>
    </Match>
    </List_AML_Finacle>

    avoid multi post
    http://forum.java.sun.com/thread.jspa?threadID=5249519

  • How to get the most current file based on date and time stamp using SSIS?

    Hello,
    Let us assume that files get copied in a specific directory. We need to pick up a file and load data. Can you guys let me know how to get the most current file based on date and time stamp using SSIS?
    Thanks
    thx regards dinesh vv

    hi simon
    i excuted this script it is giving error..
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_9a6d985a04b249c2addd766b58fee890.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            The execution engine calls this method when the task executes.
            To access the object model, use the Dts property. Connections, variables, events,
            and logging features are available as members of the Dts property as shown in the following examples.
            To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
            To post a log entry, call Dts.Log("This is my log text", 999, null);
            To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
            To use the connections collection use something like the following:
            ConnectionManager cm = Dts.Connections.Add("OLEDB");
            cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
            Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
            To open Help, press F1.
            public void Main()
                string file = Dts.Variables["User::FolderName"].Value.ToString();
                string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::FolderName"].Value.ToString());
                System.IO.FileInfo finf;
                DateTime currentDate = new DateTime();
                string lastFile = string.Empty;
                foreach (string f in files)
                    finf = new System.IO.FileInfo(f);
                    if (finf.CreationTime >= currentDate)
                        currentDate = finf.CreationTime;
                        lastFile = f;
                Dts.Variables["User::LastFile"].Value = lastFile;
                Dts.TaskResult = (int)ScriptResults.Success;
    thx regards dinesh vv

  • How to get the count of repeating elements in a xml doc.

    In many xml documents, in is common to have repeating child elements and what I would like to know is how do I determine exactly how many of these child elements exist in a particular document. There is probably a correct XPath string to determine this, but I cannot figure out what it is. Here is an example
    <a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>
    The above 'c' element is what varies in number from document to document and I need to know how to get the number of 'c' elements for the document, which would be 3 in the above case.

    create table test_xml(data xmltype)
    insert into test_xml values(
    xmltype('<a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>')
    select extract(data, '/a/b/c').getclobval() from test_xml
    select count(*) from test_xml
    where existsnode(data, '/a/b/c')=1
    good luck.

  • How to get and display current year

    hi,
    how to get and display current year
    and need it to convert numeric format if it is orginally
    in character format.

    Hi,
    chk this FM.
    CALL FUNCTION 'GET_CURRENT_YEAR'
      EXPORTING
        BUKRS         = '1000'     " Company Code
        DATE          = SY-DATUM   " Date to find fiscal year for
      IMPORTING
        CURRM         = w_currm    " Current Fiscal Month
        CURRY         = w_curry    " Current Fiscal Year
        PREVM         = w_prevm    " Previous Fiscal Month
        PREVY         = w_prevy.   " Previous Fiscal Year
    rgds
    anver
    if hlped pls mark points

  • How to get Dealership of Adobe Photoshop Elements for Mumbai, Maharastra, India

    Hello,
    i am doing wedding Album designing in india Using Adobe Photoshop Elements8 Licence Version.
    Also Developing Plugin for Adobe Premiere in Flex.
    How to get Dealership of Adobe Photoshop Elements for Mumbai, Maharastra, India
    any one have idea please help.
    thanks
    Dhiraj

    Hi,
    Thanks Barbara B. sure i will try.
    Thanks
    Dhiraj

  • How canI get my serial number for Elements 11?

    How canI get my serial number for Elements 11?  Does anyone know how to help me.  I did puchase it sometime ago but lost all computer data and had to replace computer.  Hope someone can help.
    Thanks
    Steve

    If you have no record of it at your end, the only place you might find it is at Adobe's end via logging into your Adobe account and seeing if it is listed there.  If you registered the software it should be.
    Beyond that your only hope might be to have Adobe support check your information to see if the software/serial number is available and if it can be given to you.  Try contacting them by chat or telephone.
    Here is a link to a page with options to help make contact:
    http://www.adobe.com/support/download-install/supportinfo/

  • How to get index of the item from table when user double click on an item

    Can anyone tell me how to get the corresponding index of a table in which
    elements are listed as array of strings? I am looking for the index of the
    item being double-clicked on?
    Thank you in advance
    Cheers,
    NQ.

    Hi NQ,
    Although the question is not thouroughly clear, I can give a few suggestions. You can use the property node for table to refer to any particular row or column of the table. The correpsonding elements in the property node will be "SelStart", "SelSize" etc. Just as a side thought, the index of a table starts with (0,0).
    I am attaching a test file. Please see if it helps you in figuring out what exactly you want. This example VI is just to help you try different options under property node (if you havent already tried)to get what you want.
    Regards,
    Sastry Vadlamani
    Applications Engineer
    National Instruments
    Attachments:
    test.vi ‏27 KB

  • How to get information of current message in code inspector

    I need your expertise.
    I've enhanced code inspector. I've created several classes. I would like to get the information on the previous errors of my test.
    I've found that information is stored in EXEC_SCIRESTPS in class CL_CI_INSPECTION and I don't how to get this information in the run method of my new class.
    I hope some expert has the answer.
    Christophe.

    Hi James,
    You can determine the current user by accessing variable &APP_USER., or V('APP_USER'). You can then query view apex_workspace_apex_users or wwv_flow_users to find out more info.
    Regards
    Paul

  • Don't know how to get printer online. currently offline 3520 deskjet

    HP 3520 deskjet.  Can't print.  Printer reads offline.  Don't know how to get it online (ready).  I tried reloading it, but error message came up.
    HELP!

    Hello there! Welcome to the forums @mattiesmom !
    I read your post about how your Deskjet 3520 is showing offline and is not printing.
    I will certainly help!
    Please follow all of these steps, in order, and you should be back online and printing afterwards:
    'Printer is offline' Message Displays on the Computer and the Printer Will Not Print: Windows Vista
    Feel free to write back to let me know the results!
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • How to get Index storage Quality

    Hi,
    I want to get the storage quality of the Index for multiple Indexes.
    I am albe to get the Index Quality for particular one Index by accessing following path.
    DB02OLD -> Tables and Indexes -> Detailed Analysis -> Enter Index Name -> Detailed Analysis
    Check storage quality by, Analyze Index -> Storage Quality
    By accessing above path i have to check index one by one and its take very long time.
    But I want to check the storage Quality for multiple Indexes at same time.
    So is it possible to get Index Storage quality for miltiple indexes in single steps?
    Regards,
    Nisit

    Hi Nisit Patel ,
    If u have found the solution please share with me
    as i also need to analyse the % of storage quality from mulitple indexes
    is there any sql script for the same
    thanks
    Anand

  • How to get the member of cost element group from Profit center group

    Hi Guys,
                  I need to get the member of cost element group from Profit center group like in Tcode KCH3 and the same from Account Group like in Tcode KDH3.
    Any Function Module available to get this data.
    Thank U for Ur time.
    Cheers
    Senthil

    I am closing this thread.

  • JAXB:How to get the type of an element

    Hi
    I am working with JAXB 2and i am using a custom ValidationEventHandler to validate my xml document:The issue I have is that when my document isn't valid,i would like to get the error node and its type(string,date...)
    I tryed node.getNodeType() but it return if the node is ATTRIBUTE_NODE,TEXT_NODE....
    public boolean handleEvent(ValidationEvent ve) {           
            if (ve.getSeverity()==ValidationEvent.FATAL_ERROR || 
                                   ve .getSeverity()==ValidationEvent.ERROR){
                ValidationEventLocator  locator = ve.getLocator();
                org.w3c.dom.Node node=locator.getNode();
              System.out.println("ERROR element type:"+node.getNodeType());
             return true;
           }How could i get the type(String,Date,Integer...) of the node in error?
    Edited by: riadhhwajdii on Aug 14, 2010 4:20 AM

    As you already mention that is not resolved before the annotation processing stage
    [ http://openjdk.java.net/groups/compiler/doc/compilation-overview/index.html]
    So, you probably need to produce your own analysis code or better reuse the compiler's own code if that turns out to be easy (no clue). I reckon it is better if you avoid modifying the compiler itself as it will make much more difficult to maintain and deploy your (more than a) processor.
    Sorry if you already tough about this.
    Edited by: discretoboy on Apr 7, 2009 3:20 PM

Maybe you are looking for