swing 开发过程中遇到的奇葩问题

swing 开发过程中遇到的奇葩问题

1,实现Ctrl+Tab 切换页签的功能



但是在实际开发中遇到了问题,切换的时候,预期是切换到序号33的页签,结果切换到了序号34 的页签.

后来发现Ctrl+Tab是系统的快捷键,与程序实现功能混淆,导致错乱.

最后就在程序中使用Shift+Tab 快捷键

if (event.getClass() == KeyEvent.class) {
							KeyEvent kE = ((KeyEvent) event);
							// 处理按键事件 Shift+Tab
							if ((kE.getKeyCode() == KeyEvent.VK_TAB)//TODO 注意:Ctrl+Tab 是系统的快捷键,容易和程序混淆
									&& (((InputEvent) event)
											.isShiftDown())&& kE.getID() == KeyEvent.KEY_PRESSED) {
								System.out.println("111");
								int lastIndex=getLastIndex();
								if(lastIndex<0){
									return;
								}
//								indexList.add(tabbedPane.getSelectedIndex());
								tabbedPane_2.setSelectedIndex(lastIndex);
							} 
						}

2,待续(欢迎大家补充)

3,

猜你喜欢

转载自hw1287789687.iteye.com/blog/2255017