当前位置: 首页>>代码示例>>Java>>正文


Java JTextComponent.getClientProperty方法代码示例

本文整理汇总了Java中javax.swing.text.JTextComponent.getClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JTextComponent.getClientProperty方法的具体用法?Java JTextComponent.getClientProperty怎么用?Java JTextComponent.getClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.JTextComponent的用法示例。


在下文中一共展示了JTextComponent.getClientProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
        int selectionStartOffset = target.getSelectionStart();
        int selectionEndOffset = target.getSelectionEnd();
        if (selectionEndOffset > selectionStartOffset || selectNext) {
            SelectionHandler handler = (SelectionHandler)target.getClientProperty(SelectionHandler.class);
            if (handler == null) {
                handler = new SelectionHandler(target);
                target.addCaretListener(handler);
                // No need to remove the listener above as the handler
                // is stored is the client-property of the component itself
                target.putClientProperty(SelectionHandler.class, handler);
            }
            
            if (selectNext) { // select next element
                handler.selectNext();
            } else { // select previous
                handler.selectPrevious();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SelectCodeElementAction.java

示例2: defaultAction

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void defaultAction (
    final JTextComponent    component
) {
    Completion.get ().hideCompletion ();
    Completion.get ().hideDocumentation ();
    Document document = component.getDocument ();
    DataObject dataObject = (DataObject) document.getProperty (Document.StreamDescriptionProperty);
    FileObject fileObject = dataObject.getPrimaryFile ();
    Project project = FileOwnerQuery.getOwner (fileObject);
    Locale locale = LocaleQuery.findLocale(fileObject);
    DictionaryImpl dictionary = projects && project != null ?
        ComponentPeer.getProjectDictionary (project, locale) :
        ComponentPeer.getUsersLocalDictionary (locale);
    dictionary.addEntry (word);
    ComponentPeer componentPeer = (ComponentPeer) component.getClientProperty (ComponentPeer.class);
    componentPeer.reschedule();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:AddToDictionaryCompletionItem.java

示例3: actionPerformed

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
        int selectionStartOffset = target.getSelectionStart();
        int selectionEndOffset = target.getSelectionEnd();
        if (selectionEndOffset > selectionStartOffset || selectNext) {
            SelectionHandler handler = (SelectionHandler)target.getClientProperty(SelectionHandler.class);
            if (handler == null) {
                handler = new SelectionHandler(target, getShortDescription());
                target.addCaretListener(handler);
                // No need to remove the listener above as the handler
                // is stored is the client-property of the component itself
                target.putClientProperty(SelectionHandler.class, handler);
            }

            if (selectNext) { // select next element
                handler.selectNext();
            } else { // select previous
                handler.selectPrevious();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SelectCodeElementAction.java

示例4: getFindButton

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
protected static JButton getFindButton(final JTextComponent c) {
    final DynamicallySizingJRSUIIcon findIcon = getFindIcon(c);
    final JButton b = createButton(c, findIcon);
    b.setName("find");

    final Object findPopup = c.getClientProperty(FIND_POPUP_KEY);
    if (findPopup instanceof JPopupMenu) {
        // if we have a popup, indicate that in the icon
        findIcon.painter.state.set(Variant.MENU_GLYPH);

        b.addMouseListener(new MouseAdapter() {
            public void mousePressed(final MouseEvent e) {
                ((JPopupMenu)findPopup).show(b, 8, b.getHeight() - 2);
                c.requestFocusInWindow();
                c.repaint();
            }
        });
    }

    final Object findAction = c.getClientProperty(FIND_ACTION_KEY);
    if (findAction instanceof ActionListener) {
        b.addActionListener((ActionListener)findAction);
    }

    return b;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:AquaTextFieldSearch.java

示例5: get

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public static AbbrevDetection get(JTextComponent component) {
    AbbrevDetection ad = (AbbrevDetection)component.getClientProperty(AbbrevDetection.class);
    if (ad == null) {
        ad = new AbbrevDetection(component);
        component.putClientProperty(AbbrevDetection.class, ad);
    }
    return ad;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:AbbrevDetection.java

示例6: actionPerformed

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
        Boolean overwriteMode = (Boolean) target.getClientProperty(EditorUtilities.CARET_OVERWRITE_MODE_PROPERTY);
        // Now toggle
        overwriteMode = (overwriteMode == null || !overwriteMode.booleanValue())
                        ? Boolean.TRUE : Boolean.FALSE;
        target.putClientProperty(EditorUtilities.CARET_OVERWRITE_MODE_PROPERTY, overwriteMode);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ActionFactory.java

示例7: editorRegistryChanged

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private void editorRegistryChanged() {
    final JTextComponent editor = EditorRegistry.lastFocusedComponent();
    final JTextComponent lastEditor = lastEditorRef == null ? null : lastEditorRef.get();
    if (lastEditor != editor && (editor == null || editor.getClientProperty("AsTextField") == null)) {
        if (lastEditor != null) {
            lastEditor.removeCaretListener(this);
            lastEditor.removePropertyChangeListener(this);
            k24.set(false);
        }
        lastEditorRef = new WeakReference<JTextComponent>(editor);
        if (editor != null) {
            editor.addCaretListener(this);
            editor.addPropertyChangeListener(this);
        }
        final JTextComponent focused = EditorRegistry.focusedComponent();
        if (focused != null) {
            final Document doc = editor.getDocument();
            final String mimeType = DocumentUtilities.getMimeType (doc);
            if (doc != null && mimeType != null) {
                final Source source = Source.create (doc);
                if (source != null) {
                    ((EventSupport)SourceEnvironment.forSource(source)).resetState(true, false, -1, -1, true);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:EventSupport.java

示例8: getCaretBias

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private static String getCaretBias(JTextComponent component) {
    Object value = component.getClientProperty(MasterMatcher.PROP_CARET_BIAS);
    if (value != null) {
        String s = value.toString();
        for (String [] pair : CARET_BIAS) {
            if (pair[0].equals(s)) {
                return pair[1];
            }
        }
    }
    return ""; //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ControlPanel.java

示例9: getInstance

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public static synchronized HighlightingManager getInstance(JTextComponent pane) {
    HighlightingManager highlightingManager = (HighlightingManager) pane.getClientProperty(HighlightingManager.class);
    if (highlightingManager == null) {
        highlightingManager = new HighlightingManager(pane);
        pane.putClientProperty(HighlightingManager.class, highlightingManager);
    }
    return highlightingManager;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:HighlightingManager.java

示例10: show

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
 * Create and display the popup at the given bounds.
 *
 * @param popupBounds location and size of the popup.
 * @param displayAboveCaret whether the popup is displayed above the anchor
 *  bounds or below them (it does not be right above them).
 */
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
    // Hide the original popup if exists
    if (popup != null) {
        popup.hide();
        popup = null;
    }
    
    // Explicitly set the preferred size
    Dimension origPrefSize = getPreferredSize();
    Dimension newPrefSize = popupBounds.getSize();
    JComponent contComp = getContentComponent();
    if (contComp == null){
        return;
    }
    contComp.setPreferredSize(newPrefSize);
    showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
    
    PopupFactory factory = PopupFactory.getSharedInstance();
    // Lightweight completion popups don't work well on the Mac - trying
    // to click on its scrollbars etc. will cause the window to be hidden,
    // so force a heavyweight parent by passing in owner==null. (#96717)
    
    JTextComponent owner = layout.getEditorComponent();
    if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) {
        owner = null;
    }
    
    // #76648: Autocomplete box is too close to text
    if(displayAboveCaret && Utilities.isMac()) {
        popupBounds.y -= 10;
    }
    
    popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
    popup.show();

    this.popupBounds = popupBounds;
    this.displayAboveCaret = displayAboveCaret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:CompletionLayoutPopup.java

示例11: propertyChange

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
@Override
public void propertyChange (PropertyChangeEvent evt) {
    // event for the editors tracker
    if (evt.getSource () == EditorRegistry.class) {
        if (evt.getPropertyName () == null || 
            EditorRegistry.FOCUS_GAINED_PROPERTY.equals (evt.getPropertyName ())
        ) {
            JTextComponent jtc = (JTextComponent) evt.getNewValue ();
            PropertyChangeListener l = (PropertyChangeListener) jtc.getClientProperty (DOCUMENT_TRACKER_PROP);
            if (l == null) {
                jtc.putClientProperty (DOCUMENT_TRACKER_PROP, documentListener);
                jtc.addPropertyChangeListener (documentListener);
            }
            myTask.schedule(100);
        }
        return;
    }

    // event for the document tracker
    if (evt.getSource () instanceof JTextComponent) {
        if (evt.getPropertyName () == null ||
            "document".equals (evt.getPropertyName ())
        ) { //NOI18N
            Document newDoc = (Document) evt.getNewValue ();
            if (newDoc != null) {
                myTask.schedule(100);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:EditorBookmarksModule.java

示例12: getAdjustedClickCount

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
 * Return the MouseEvent's click count, possibly reduced by the value of
 * the component's {@code SKIP_CLICK_COUNT} client property. Clears
 * the {@code SKIP_CLICK_COUNT} property if the mouse event's click count
 * is 1. In order for clearing of the property to work correctly, there
 * must be a mousePressed implementation on the caller with this
 * call as the first line.
 */
public static int getAdjustedClickCount(JTextComponent comp, MouseEvent e) {
    int cc = e.getClickCount();

    if (cc == 1) {
        comp.putClientProperty(SKIP_CLICK_COUNT, null);
    } else {
        Integer sub = (Integer) comp.getClientProperty(SKIP_CLICK_COUNT);
        if (sub != null) {
            return cc - sub;
        }
    }

    return cc;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:SwingUtilities2.java

示例13: getSearchDirection

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private static String getSearchDirection(JTextComponent component) {
    Object value = component.getClientProperty(MasterMatcher.PROP_SEARCH_DIRECTION);
    if (value != null) {
        String s = value.toString();
        for (String [] pair : SEARCH_DIRECTIONS) {
            if (pair[0].equals(s)) {
                return pair[1];
            }
        }
    }
    return ""; //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ControlPanel.java

示例14: canDisplay

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private static boolean canDisplay(JTextComponent component) {
    Object o = component.getClientProperty(PROP_SIDEBAR_MARK);
    return (o == null || ((o instanceof JComponent) && !((JComponent)o).isVisible()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:CodeFoldingSideBar.java

示例15: ensureRegistered

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public static void ensureRegistered(JTextComponent component, String mimeType) {
    if (component.getClientProperty(KEY) == null) {
        component.putClientProperty(KEY, new HyperlinkOperation(component, mimeType));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:HyperlinkOperation.java


注:本文中的javax.swing.text.JTextComponent.getClientProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。