javax.swing.JComponent.hasFocus()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中javax.swing.JComponent.hasFocus()方法的一些代码示例,展示了JComponent.hasFocus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.hasFocus()方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:hasFocus

JComponent.hasFocus介绍

暂无

代码示例

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void paint(Graphics g, JComponent c ) {
  super.paint (g, c);
  if (c.hasFocus() && !tableUI) {
    Color prev = g.getColor();
    try {
      g.setColor (PropUtils.getShadowColor());
      g.drawRect(2,2,c.getWidth()-5, c.getHeight()-5);
    } finally {
      g.setColor(prev);
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public void paint(Graphics g, JComponent c ) {
  super.paint (g, c);
  if (c.hasFocus() && !tableUI) {
    Color prev = g.getColor();
    try {
      g.setColor (PropUtils.getShadowColor());
      g.drawRect(2,2,c.getWidth()-5, c.getHeight()-5);
    } finally {
      g.setColor(prev);
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
public void paint(Graphics g, JComponent c) {
  super.paint(g, c);
  if (c.hasFocus() && !tableUI) {
    Color prev = g.getColor();
    try {
      g.setColor(PropUtils.getShadowColor());
      g.drawRect(2, 2, c.getWidth() - 5, c.getHeight() - 5);
    } finally {
      g.setColor(prev);
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-cnd-gizmo

@Override
protected void componentDeactivated() {
  super.componentDeactivated();
  lastFocusedComponent = null;
  if (indicatorPanels == null || indicatorPanels.size() == 0) {
    return;
  }
  for (JComponent c : indicatorPanels) {
    if (c.hasFocus()) {
      lastFocusedComponent = c;
      break;
    }
  }
  if (lastFocusedComponent == null) {
    lastFocusedComponent = indicatorPanels.get(0);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-dlight-core-ui

@Override
protected void componentDeactivated() {
  super.componentDeactivated();
  lastFocusedComponent = null;
  if (indicatorPanels == null || indicatorPanels.size() == 0) {
    return;
  }
  for (JComponent c : indicatorPanels) {
    if (c.hasFocus()) {
      lastFocusedComponent = c;
      break;
    }
  }
  if (lastFocusedComponent == null) {
    lastFocusedComponent = indicatorPanels.get(0);
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * Gets the color to paint the selected rows.
 *
 * @param c the component
 * @return the selection color.
 * @since 3.4.6
 */
protected Color getSelectionColor(JComponent c) {
  Color selectedColor = UIManager.getColor("NavigationComponent.selectionBackground");
  if (selectedColor == null) {
    selectedColor = UIManager.getColor("Tree.selectionBackground");
  }
  if (!c.hasFocus()) {
    selectedColor = ColorUtils.toGrayscale(selectedColor).brighter();
    if (Color.WHITE.equals(selectedColor)) {
      selectedColor = new Color(202, 202, 202);
    }
  }
  return selectedColor;
}

代码示例来源:origin: khuxtable/seaglass

/**
 * DOCUMENT ME!
 *
 * @param context DOCUMENT ME!
 * @param g       DOCUMENT ME!
 * @param c       DOCUMENT ME!
 */
void paintBackground(SeaGlassContext context, Graphics g, JComponent c) {
  context.getPainter().paintTextFieldBackground(context, g, 0, 0, c.getWidth(), c.getHeight());
  // If necessary, paint the placeholder text.
  if (placeholderText != null && ((JTextComponent) c).getText().length() == 0 && !c.hasFocus()) {
    paintPlaceholderText(context, g, c);
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

public static void adjustFocus(JComponent component) {
  if ((!(component.hasFocus())) && (component.isRequestFocusEnabled()))
    component.requestFocus();
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

public static void adjustFocus(JComponent component) {
  if ((!(component.hasFocus())) && (component.isRequestFocusEnabled()))
    component.requestFocus();
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

public static void adjustFocus(JComponent component) {
  if ((!(component.hasFocus())) && (component.isRequestFocusEnabled()))
    component.requestFocus();
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

public static void adjustFocus(JComponent component) {
  if ((!(component.hasFocus())) && (component.isRequestFocusEnabled()))
    component.requestFocus();
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
  public boolean isEnabled(Object sender) {
    if (component == null || !component.isEnabled() || !component.hasFocus())
      return false;
    return isClickable(getFocusedCell());
  }
};

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
  public boolean isEnabled(Object sender) {
    if (component == null || !component.isEnabled() || !component.hasFocus())
      return false;
    return isClickable(getFocusedCell());
  }
};

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

@Override
  public boolean isEnabled(Object sender) {
    if (component == null || !component.isEnabled() || !component.hasFocus())
      return false;
    return isClickable(getFocusedCell());
  }
};

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

@Override
  public boolean isEnabled() {
    if (component == null || !component.isEnabled() || !component.hasFocus())
      return false;
    return isClickable(getFocusedCell());
  }
};

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

@Override
  public boolean isEnabled(Object sender) {
    if (component == null || !component.isEnabled() || !component.hasFocus())
      return false;
    return isClickable(getFocusedCell());
  }
};

代码示例来源:origin: com.github.insubstantial/substance

public static final boolean isFocused(Component component) {
  if (QuaquaUtilities.isOnActiveWindow(component)) {
    Component c = component;
    if (c instanceof JComponent) {
      if (c instanceof JScrollPane) {
        JViewport viewport = ((JScrollPane) component).getViewport();
        if (viewport != null) {
          c = viewport.getView();
        }
      }
      if (c instanceof JTextComponent
          && !((JTextComponent) c).isEditable()) {
        return false;
      }
      return c != null
          && (((JComponent) c).hasFocus() || ((JComponent) c).getClientProperty("Quaqua.drawFocusBorder") == Boolean.TRUE);
    }
  }
  return false;
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

for (Enumeration e = BuLib.getAllSubComponents(cp).elements(); e.hasMoreElements();) {
 Object o = e.nextElement();
 if ((o instanceof JComponent) && ((JComponent) o).hasFocus()) {
  focus = (JComponent) o;
  break;

代码示例来源:origin: org.java.net.substance/substance

public static final boolean isFocused(Component component) {
  if (QuaquaUtilities.isOnActiveWindow(component)) {
    Component c = component;
    if (c instanceof JComponent) {
      if (c instanceof JScrollPane) {
        JViewport viewport = ((JScrollPane) component).getViewport();
        if (viewport != null) {
          c = viewport.getView();
        }
      }
      if (c instanceof JTextComponent
          && !((JTextComponent) c).isEditable()) {
        return false;
      }
      return c != null
          && (((JComponent) c).hasFocus() || ((JComponent) c).getClientProperty("Quaqua.drawFocusBorder") == Boolean.TRUE);
    }
  }
  return false;
}

代码示例来源:origin: org.tentackle/tentackle-swing

if (c.hasFocus() && ((AbstractButton) c).isFocusPainted()) {
 paintFlashingFocus(g, c);

相关文章

JComponent类方法