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

📄 uicomponentanalyzer.java

📁 基于Junit的 功能和单元测试的的测试工具。只支持Swing.
💻 JAVA
字号:
package org.uispec4j.utils;

public class UIComponentAnalyzer {
  public static Class[] getSwingClasses(Class uiComponentClass) {
    Class[] classes;
    try {
      classes = (Class[])uiComponentClass.getDeclaredField("SWING_CLASSES").get(null);
      if (classes == null) {
        throw new RuntimeException("Field 'static Class[] SWING_CLASSES' in class " + uiComponentClass +
                                   " should be initialized");
      }
    }
    catch (NoSuchFieldException e) {
      throw new RuntimeException("Class " + uiComponentClass +
                                 " should have a field 'static Class[] SWING_CLASSES'");
    }
    catch (IllegalAccessException e) {
      throw new RuntimeException("Invalid UIComponent class " + uiComponentClass, e);
    }
    return classes;
  }

  public static String getTypeName(Class uiComponentClass) {
    String typeName = null;
    try {
      typeName = (String)uiComponentClass.getDeclaredField("TYPE_NAME").get(null);
    }
    catch (IllegalAccessException e) {
      throw new RuntimeException("Invalid UIComponent class " + uiComponentClass, e);
    }
    catch (NoSuchFieldException e) {
      throw new RuntimeException("Invalid UIComponent class " + uiComponentClass, e);
    }
    return typeName;
  }
}

⌨️ 快捷键说明

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