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


Java JTextComponent.getUI方法代码示例

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


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

示例1: setParent

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public @Override void setParent(View parent) {
    if (parent != null) { // start listening
        JTextComponent component = (JTextComponent)parent.getContainer();
        TextUI tui = component.getUI();
        if (tui instanceof BaseTextUI){
            editorUI = ((BaseTextUI)tui).getEditorUI();
            if (editorUI!=null){
                editorUI.addPropertyChangeListener(this);
            }
        }
    }

    super.setParent(parent);
    
    if (parent == null) {
        if (editorUI!=null){
            editorUI.removePropertyChangeListener(this);
            editorUI = null;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:DrawEngineDocView.java

示例2: getLineFromMouseEvent

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private int getLineFromMouseEvent(MouseEvent e){
    int line = -1;
    EditorUI eui = editorUI;
    if (eui != null) {
        try{
            JTextComponent component = eui.getComponent();
            BaseDocument document = eui.getDocument();
            BaseTextUI textUI = (BaseTextUI)component.getUI();
            int clickOffset = textUI.viewToModel(component, new Point(0, e.getY()));
            line = Utilities.getLineOffset(document, clickOffset);
        }catch (BadLocationException ble) {
            LOG.log(Level.WARNING, null, ble);
        }
    }
    return line;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:GlyphGutter.java

示例3: actionPerformed

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt) {
    // Find the right action for the corresponding editor kit
    JTextComponent component = getTextComponent(evt);
    if (component != null) {
        TextUI ui = component.getUI();
        if (ui != null) {
            EditorKit kit = ui.getEditorKit(component);
            if (kit != null) {
                Action action = EditorUtilities.getAction(kit, actionName);
                if (action != null) {
                    action.actionPerformed(evt);
                } else {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Action '" + actionName + "' not found in editor kit " + kit + '\n'); // NOI18N
                    }
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:PresenterEditorAction.java

示例4: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                 Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentationScrollPane.java

示例5: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentationScrollPane.java

示例6: installSearchField

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:AquaTextFieldSearch.java

示例7: uninstallSearchField

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
protected static void uninstallSearchField(final JTextComponent c) {
    c.setBorder(UIManager.getBorder("TextField.border"));
    c.removeAll();

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(null);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:AquaTextFieldSearch.java

示例8: getRootView

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
 * Get first view in the hierarchy that is an instance of the given class.
 * It allows to skip various wrapper-views around the doc-view that holds
 * the child views for the lines.
 *
 * @param component component from which the root view is fetched.
 * @param rootViewClass class of the view to return.
 * @return view being instance of the requested class or null if there
 *  is not one.
 */
public static View getRootView(JTextComponent component, Class rootViewClass) {
    View view = null;
    TextUI textUI = component.getUI();
    if (textUI != null) {
        view = textUI.getRootView(component);
        while (view != null && !rootViewClass.isInstance(view)
            && view.getViewCount() == 1 // must be wrapper view
        ) {
            view = view.getView(0); // get the only child
        }
    }
    
    return view;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Utilities.java

示例9: getShrinkageFor

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
static int getShrinkageFor(final JTextComponent jc, final int height) {
    if (jc == null) return 0;
    final TextUI ui = jc.getUI();
    if (ui == null) return 0;
    final Dimension size = ui.getPreferredSize(jc);
    if (size == null) return 0;
    final int shrinkage = size.height - height;
    return (shrinkage < 0) ? 0 : (shrinkage > 3) ? 3 : shrinkage;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:AquaTextFieldBorder.java

示例10: get

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public static DocumentView get(JTextComponent component) {
    TextUI textUI = component.getUI();
    if (textUI != null) {
        View rootView = textUI.getRootView(component);
        if (rootView != null && rootView.getViewCount() > 0) {
            View view = rootView.getView(0);
            if (view instanceof DocumentView) {
                return (DocumentView)view;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DocumentView.java

示例11: BraceMatchingSidebarComponent

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
public BraceMatchingSidebarComponent(JTextComponent editor) {
    this.editor = editor;
    this.mimeType = DocumentUtilities.getMimeType(editor);
    this.prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    
    final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(editor)).lookupResult(
            FontColorSettings.class);
    prefListenerGC = new PrefListener();
    this.colorResult = r;
    r.addLookupListener(WeakListeners.create(LookupListener.class, this , r));
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListenerGC, prefs));
    loadPreferences();
    
    editorPane = findEditorPane(editor);
    Component parent = editor.getParent();
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }
    if (parent instanceof JViewport) {
        this.viewport = (JViewport)parent;
        // see #219015; need to listen on viewport change to show/hide the tooltip
        viewport.addChangeListener(WeakListeners.change(this, viewport));
    }
    TextUI ui = editor.getUI();
    if (ui instanceof BaseTextUI) {
        baseUI = (BaseTextUI)ui;
        MasterMatcher.get(editor).addMatchListener(this);
    } else {
        baseUI = null;
    }
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    updatePreferredSize();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:BraceMatchingSidebarComponent.java

示例12: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Attempt to find the editor keystroke for the given action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey) {
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    JTextComponent comp = getComponent();
    if (editorActionName != null && comp != null) {
        TextUI textUI = comp.getUI();
        Keymap km = comp.getKeymap();
        if (textUI != null && km != null) {
            EditorKit kit = textUI.getEditorKit(comp);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    } else {
                        // try kit's keymap
                        Keymap km2 = ((BaseKit)kit).getKeymap();
                        KeyStroke[] keys2 = km2.getKeyStrokesForAction(a);
                        if (keys2 != null && keys2.length > 0) {
                            ret = keys2;
                        }                            
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:NbEditorToolBar.java

示例13: paintView

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
 * Paints one view that corresponds to a line (or
 * multiple lines if folding takes effect).
 */
private void paintView(View view, Graphics g, int yBase) {
    JTextComponent component = editorUI.getComponent();
    if (component == null) return;
    BaseTextUI textUI = (BaseTextUI)component.getUI();

    Element rootElem = textUI.getRootView(component).getElement();
    int line = rootElem.getElementIndex(view.getStartOffset());

    String annotation = "";  // NOI18N
    AnnotateLine al = null;
    if (!elementAnnotations.isEmpty()) {
        al = getAnnotateLine(line);
        if (al != null) {
            annotation = getDisplayName(al);  // NOI18N
        }
    } else {
        annotation = elementAnnotationsSubstitute;
    }

    if (al != null && al.getRevision().equals(recentRevision)) {
        g.setColor(selectedColor());
    } else {
        g.setColor(foregroundColor());
    }
    int texty = yBase + editorUI.getLineAscent();
    int textx = 2;
    g.drawString(annotation, textx, texty);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:AnnotationBar.java

示例14: getLineFromMouseEvent

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** GlyphGutter copy pasted utility method. */
private int getLineFromMouseEvent(MouseEvent e){
    int line = -1;
    if (editorUI != null) {
        try{
            JTextComponent component = editorUI.getComponent();
            BaseTextUI textUI = (BaseTextUI)component.getUI();
            int clickOffset = textUI.viewToModel(component, new Point(0, e.getY()));
            line = Utilities.getLineOffset(doc, clickOffset);
        }catch (BadLocationException ble){
        }
    }
    return line;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:AnnotationBar.java

示例15: getBaseTextUI

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private BaseTextUI getBaseTextUI(){
    JTextComponent comp = getComponent();
    return (comp!=null)?(BaseTextUI)comp.getUI():null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:CollapsedView.java


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