开发者

How to change the image by click keyboard arrows?

开发者 https://www.devze.com 2022-12-30 18:24 出处:网络
I have made one project in java. Now in this particular module, i am showing the user , so i am showing them a stock inventory.

I have made one project in java. Now in this particular module, i am showing the user , so i am showing them a stock inventory.

Now for doing this.

As you will see in the screen shot [ i have put screenshot so you can understand well ].

To show the images , i have made one table and i have put labels in that and then i am setting the icon at the label.

Now as soon as user click on the any image, then that image i put on big label.

But this works perfect on mouse click but client want that , if user navigate the by keyboard 开发者_开发百科arrow keys then in same should be happen.

Means : User navigate by key board then it should reflect on that table [user should know that which is currently seleted ] and then as soon as the user navigate by key board arrow events and then click enter then that image should reflect on big label.

Here is the Link for that screenshot.


Sounds like there are two steps in what you need to do.

First, the user needs to know which image is selected. Unfortunately I can't help you with that, since I don't know how you're displaying that grid. From a UI point of view, I'd suggest exploiting that white border you've got in each cell -- change it black, blue, or whatever color you like to indicate that it's the selected cell. You seem to be using a JTable, in which case you can write a TableCellRenderer (probably by extending DefaultTableCellRenderer) and call its setBackground() method.

Then you need to listen for keyboard input. This part shouldn't be too bad; write a KeyListener and add it to the JTable itself. For each key event, see if the key code matches the arrow keys; if so, move your cursor around accordingly. Don't forget to watch out for the edges of the JTable.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号