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

  • SEARCH
  • Home
  • 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 5960111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:46:50+00:00 2026-05-22T18:46:50+00:00

My jlist is one where the cells are square and with fixed sizes, and

  • 0

My jlist is one where the cells are square and with fixed sizes, and the view port fills up with them, so the number of columns (and row i guess) can actually change.

My code to do this is fairly complex:

http://code.google.com/p/bookjar-utils/source/browse/BookJar-utils/src/util/swing/components/ImageList.java

What i want to do is allow for different keyboard movement with the arrow keys – Instead of only using ↑ and ↓ to move up and down rows also allow ← and → if the selected cell mets the west or east edges of the viewport.

Should i just calculate how many cells are fit in a “row” and add a keylistener for the arrows that takes over when at the edges when the default behavior appear to do nothing?

For that matter where is the original behavior defined? the ← and → keys DO allow movement in a row if they are not on the edges of the row.

  • 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-05-22T18:46:51+00:00Added an answer on May 22, 2026 at 6:46 pm

    In Swing, every widget has its own UI-class that controls its behavior. The LookAndFeel manages these links between widget and UI (architecture overview).

    So IMHO the right place to do what you ask is to extend the BasicTableUI and overwrite the method that defines the widgets ActionMap for keyboard actions, replacing some of the actions with your own implementation:

    class MyTableUI extends BasicTableUI {
        ...
    
        @Override
        protected void installKeyboardActions() {
            super.installKeyboardActions();
            final ActionMap actionMap = getTable().getActionMap();
            actionMap.put( NEXT_ROW, 
                new MyNewRowSelectionAction( NEXT_ROW, actionMap.get( NEXT_ROW ) ) );
            ...
    

    Note that the keys for the ActionMap are private in BasicTableUI.Actions, so they need to be copied.

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

Sidebar

Related Questions

I have a JList, and a JButton, user can click an item in the
I have a jlist with an arbitrary number of elements. I would like to
I have a JList with 5 options in it and when one of the
I have a JList with a JScrollPane . If I only have one thing
I want to code two JList (categories and items). When I click one category
Can't figure this one out. Using worker or invokeLater, the UI still freeze. After
I am trying to change JList rows dynamically. I need change nth row colour,
For some reason, I can't add anything to my JList. The JList is visible
I have a JList with a lot of items in it, of which one
how can i make a swing JList to have its items selected with any

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.