⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 focusaction.java

📁 掌握 JDBC 驱动程序的加载方法和JDBC-ODBC桥URL的形式; 掌握使用JDBC连接数据库的步骤; 掌握使用JDBC发送SQL语句的基本步骤; 掌握使用JDBC处理SQL查询结果集
💻 JAVA
字号:
package cn.edu.csu.oo.gui.project.view.viewaction;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JPanel;

public class FocusAction extends KeyAdapter {
  private JPanel panel = null;

  int i = 0;

  public FocusAction(JPanel panel, int i) {
    this.panel = panel;
    System.out.println(panel.getComponentCount());
    this.i = i;
  }

  /**
   * Invoked when a key has been pressed.
   */
  public void keyPressed(KeyEvent e) {
    int ch = e.getKeyCode();
    if (ch == KeyEvent.VK_DOWN || ch == KeyEvent.VK_ENTER) {
      if (i < 17) {
        if (i == 3) {
          panel.getComponent(i + 4).requestFocus();
        } else {
          panel.getComponent(i + 2).requestFocus();
        }
      }
    }
    if (ch == KeyEvent.VK_UP) {
      if (i > 2) {
        if (i == 7) {
          panel.getComponent(i - 4).requestFocus();
        } else {
          panel.getComponent(i - 2).requestFocus();
        }
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -