本文整理了Java中javax.swing.text.JTextComponent.hasFocus()
方法的一些代码示例,展示了JTextComponent.hasFocus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.hasFocus()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:hasFocus
暂无
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-team-commons
boolean hasFocus() {
return component.hasFocus();
}
代码示例来源:origin: mucommander/mucommander
public boolean hasFocus() { return textComponent.hasFocus(); }
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp
public void insertUpdate(DocumentEvent e) {
if (editorPane.hasFocus()) {
radioButton.setSelected(true);
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp
public void removeUpdate(DocumentEvent e) {
if (editorPane.hasFocus()) {
radioButton.setSelected(true);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-team-commons
@Override
public synchronized boolean canUndo() {
return super.canUndo() && (component != null ? component.hasFocus() : false);
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if (hint != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
if (color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
Insets margin = comp.getMargin();
g.drawString(hint, margin.left + 2, margin.top + comp.getFont().getSize() + 1);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-team-commons
@Override
public synchronized boolean canRedo() {
boolean can = super.canRedo();
if(!can) {
return can;
}
return super.canRedo() && (component != null ? component.hasFocus() : false);
}
代码示例来源:origin: mucommander/mucommander
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if(hint!=null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))){
if(color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
int padding = (comp.getHeight() - comp.getFont().getSize())/2;
g.drawString(hint, 3, comp.getHeight()-padding-1);
}
}
代码示例来源:origin: RPTools/maptool
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
final JTextComponent comp = getComponent();
if (info != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
if (color != null) {
g.setColor(color);
} else {
g.setColor(Color.gray);
}
final int padding = (comp.getHeight() - comp.getFont().getSize()) / 2;
g.drawString(info, 5, comp.getHeight() - padding - 1);
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if (hint != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
if (color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
Insets margin = comp.getMargin();
int padding = (comp.getHeight() - comp.getFont().getSize()) / 2;
//TODO Apply vertical margin as well
g.drawString(hint, margin.left + 2, comp.getHeight() - padding - 1);
}
}
代码示例来源:origin: gaborbata/jpass
private void showPopupMenu(MouseEvent e) {
if (e.isPopupTrigger() && e.getSource() instanceof JTextComponent) {
JTextComponent textComponent = (JTextComponent) e.getSource();
if (textComponent.isEnabled() && (textComponent.hasFocus() || textComponent.requestFocusInWindow())) {
this.cutItem.setEnabled(TextComponentActionType.CUT.getAction().isEnabled(textComponent));
this.copyItem.setEnabled(TextComponentActionType.COPY.getAction().isEnabled(textComponent));
this.pasteItem.setEnabled(TextComponentActionType.PASTE.getAction().isEnabled(textComponent));
this.deleteItem.setEnabled(TextComponentActionType.DELETE.getAction().isEnabled(textComponent));
this.clearAllItem.setEnabled(TextComponentActionType.CLEAR_ALL.getAction().isEnabled(textComponent));
this.selectAllItem.setEnabled(TextComponentActionType.SELECT_ALL.getAction().isEnabled(textComponent));
this.popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
private void modifiedUpdate() {
if (!inAtomicLock) {
JTextComponent c = component;
if (modified && c != null) {
if (undoOffset >= 0) { // last modification was undo => set the dot to undoOffset
setDot(undoOffset);
} else { // last modification was not undo
fireStateChanged();
// Scroll to caret only for component with focus
dispatchUpdate(c.hasFocus() ? this : null, EditorUI.SCROLL_MOVE);
}
modified = false;
}
}
}
代码示例来源:origin: atarw/material-ui-swing
private void installMyDefaults() {
this.activeBackground = UIManager.getColor("TextField.selectionBackground");
this.activeForeground = UIManager.getColor("TextField.selectionForeground");
this.inactiveBackground = UIManager.getColor("TextField.inactiveBackground");
this.inactiveForeground = UIManager.getColor("TextField.inactiveForeground");
getComponent().setFont(MaterialFonts.REGULAR);
getComponent().setSelectionColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeBackground : inactiveBackground);
getComponent().setSelectedTextColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
getComponent().setForeground(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
getComponent().setBorder(BorderFactory.createEmptyBorder(3, 5, 2,5));
}
@Override
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g) {
g.setColor(getComponent().getBackground());
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
if (getComponent().hasFocus() && getComponent().isEditable()) {
g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
}
}
g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}
代码示例来源:origin: org.softsmithy.lib/lib-core
@Override
public void configureCustomizer(){
super.configureCustomizer();
JTextComponent editor = ((AbstractTextCustomizer) getCustomizer()).getEditor();
editor.setText(((AbstractTextCustomizer) getCustomizer()).getText());
component = editor;
if (((AbstractTextCustomizer) getCustomizer()).isEditorScrollable()){
component = new JScrollPane(editor);
}
getCustomizer().getGlassPane().add(component, BorderLayout.CENTER);
//System.out.println("Component added!!!!!!!!!!!!!");
getCustomizer().getGlassPane().revalidate();
if(!editor.hasFocus()){
editor.requestFocus();
}
// editor.addFocusListener(focusListener);
}
// public void focusLostNow(FocusEvent e){
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g) {
g.setColor(getComponent().getBackground());
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
if (getComponent().hasFocus() && getComponent().isEditable()) {
g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
}
}
g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g) {
g.setColor(getComponent().getBackground());
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
if (getComponent().hasFocus() && getComponent().isEditable()) {
g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
}
}
g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g) {
g.setColor(getComponent().getBackground());
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
Boolean doShow = (Boolean) getComponent().getClientProperty("doShowFocusFrame");
if (doShow == null || doShow.booleanValue()) {
if (getComponent().hasFocus() && getComponent().isEditable()) {
g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
}
}
}
g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintBackground(Graphics g) {
g.setColor(getComponent().getBackground());
if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
if (getComponent().hasFocus() && getComponent().isEditable()) {
g.setColor(AbstractLookAndFeel.getTheme().getFocusBackgroundColor());
}
}
g.fillRect(0, 0, getComponent().getWidth(), getComponent().getHeight());
}
代码示例来源:origin: com.jidesoft/jide-oss
/**
* This method will call {@link #showHints(boolean)} if and only if the text component is enabled and has focus.
*
* @param autoPopup
*/
protected void showHintsPopup(boolean autoPopup) {
if (!getTextComponent().isEnabled() || !getTextComponent().isEditable() || !getTextComponent().hasFocus()) {
return;
}
showHints(autoPopup);
}
内容来源于网络,如有侵权,请联系作者删除!