Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8520193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:28:01+00:00 2026-06-11T06:28:01+00:00

public static void comboBoxActionPerform(JComboBox comboBox) { String ACTION_KEY = myAction; Action actionListener = new

  • 0
   public static void comboBoxActionPerform(JComboBox  comboBox)
    {
        String ACTION_KEY = "myAction";

        Action actionListener = new AbstractAction()
        {   
            @Override
            public void actionPerformed(ActionEvent actionEvent)
            {
                JComboBox source = (JComboBox) actionEvent.getSource();
                source.showPopup();
                source.setFocusable(true);
            }
        };

        KeyStroke ctrlT = KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK);
        InputMap inputMap = comboBox.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        inputMap.put(ctrlT, ACTION_KEY);
        ActionMap actionMap = comboBox.getActionMap();
        actionMap.put(ACTION_KEY, actionListener);
        locationTypeComboBox.setActionMap(actionMap);
    }

I have a com box and I call the above method to pop up combo box on keys (Ctrl+L) pressed.
It pops up the combo box. But I can’t select the items in it using UP/DOWN keys.
Combo box get not focused when I pressed Ctrl+L. That might be the issue to be fixed.
If I select the combo box manually and then up/down works fine. Need your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:28:03+00:00Added an answer on June 11, 2026 at 6:28 am

    The method you are looking for is requestFocus, not setFocusable

        Action actionListener = new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                JComboBox source = (JComboBox) actionEvent.getSource();
                source.requestFocus();
                source.showPopup();
                // source.setFocusable(true);
            }
        };
    

    BTW, it’s unusual to reset the actionMap of a component.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public static void main(String Data[]) { ConnectionPoolDataSource dps; try { cnt=new InitialContext(); cnt.rebind(java:comp/env/jdbc/pool/dragon, dps);
public static void Main() { Dictionary<string, double> values = new Dictionary<string, double>(); values.Add(a, 0.002);
public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
public class MultiplicationTable { public static void main (String[]a){ int[] x; x = new
public static void main(String[] args) { staples[] stemp = new staples[8]; int j; try
public static void main(String[] args) { int [][]shatner = new int[1][1]; int []rat =
public static void main(String[] args) throws Exception { RSAKeyPairGenerator rsaKeyPairGen = new RSAKeyPairGenerator(); AsymmetricCipherKeyPair
public static void main(String [] a) { String s = new String(Hai); String s1=s;
public class CalendarCal { public static void main(String[] args) { Date date = new
public class CollectionsFilter { public static void main(String[] args) { List<Integer> list = Arrays.asList(new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.