本文整理汇总了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();
}
}
}
}
示例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();
}
示例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();
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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
}
示例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()));
}
示例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));
}
}