當前位置: 首頁>>代碼示例>>Java>>正文


Java CaretEvent類代碼示例

本文整理匯總了Java中javax.swing.event.CaretEvent的典型用法代碼示例。如果您正苦於以下問題:Java CaretEvent類的具體用法?Java CaretEvent怎麽用?Java CaretEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CaretEvent類屬於javax.swing.event包,在下文中一共展示了CaretEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
@Override
public void caretUpdate(CaretEvent e) {
    final List<Mark> old = getMarks();
    
    marks = createMarks();
    
    final List<Mark> nue = getMarks();
    
    //Do not fire this event under the document's write lock
    //may deadlock with other providers:
    RP.post(new Runnable() {
        @Override
        public void run() {
            firePropertyChange(PROP_MARKS, old, nue);
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CaretMarkProvider.java

示例2: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
@Override
public void caretUpdate(CaretEvent e) {
    int offset = text.getCaretPosition();
    
    Node[] arr = getExplorerManager().getRootContext().getChildren().getNodes(true);
    int index = Arrays.binarySearch(arr, offset, this);
    if (index < -1) {
        index = -index - 2;
    }
    if (index >= 0 && index < arr.length) {
        try {
            getExplorerManager().removePropertyChangeListener(this);
            getExplorerManager().setSelectedNodes(new Node[]{arr[index]});
        } catch (PropertyVetoException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            getExplorerManager().addPropertyChangeListener(this);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:SubmitPanel.java

示例3: WikiEditPanel

import javax.swing.event.CaretEvent; //導入依賴的package包/類
/**
 * Creates new form WikiEditPanel
 */
public WikiEditPanel(String wikiLanguage, boolean editing, boolean switchable) {
    this.wikiLanguage = wikiLanguage;
    this.switchable = switchable;
    this.wikiFormatText = "";
    this.htmlFormatText = "";
    initComponents();
    pnlButtons.setVisible(switchable);
    textCode.getDocument().addDocumentListener(new RevalidatingListener());
    textPreview.getDocument().addDocumentListener(new RevalidatingListener());
    textCode.addCaretListener(new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent e) {
            makeCaretVisible(textCode);
        }
    });
    textCode.getDocument().addDocumentListener(new EnablingListener());
    // A11Y - Issues 163597 and 163598
    UIUtils.fixFocusTraversalKeys(textCode);
    UIUtils.issue163946Hack(scrollCode);

    Spellchecker.register(textCode);
    textPreview.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    setEditing(editing);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:WikiEditPanel.java

示例4: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
@Override
public void caretUpdate(CaretEvent e)
{
	//  Get the line the caret is positioned on

	int caretPosition = component.getCaretPosition();
	Element root = component.getDocument().getDefaultRootElement();
	int currentLine = root.getElementIndex( caretPosition );

	//  Need to repaint so the correct line number can be highlighted

	if (lastLine != currentLine)
	{
		repaint();
		lastLine = currentLine;
	}
}
 
開發者ID:Skypr,項目名稱:BEAST,代碼行數:18,代碼來源:TextLineNumber.java

示例5: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
@Override
public void caretUpdate(CaretEvent ce) {
    removeAllHighlights();
    char surroundingChars[] = {' ', ' '};
    try {            
        surroundingChars[0] = JTextPaneToolbox.getCharToTheLeftOfCaret(pane).charAt(0);
        surroundingChars[1] = JTextPaneToolbox.getCharToTheRightOfCaret(pane).charAt(0);
    } catch (StringIndexOutOfBoundsException ex) {            
    }
    for (int i = 0; i < surroundingChars.length; i++) {
        char c = surroundingChars[i];
        if(c == ' ') continue;
        if(charList.isOpenChar(c)) {
            highlightChar(ce.getDot() + i);
            highlightCorrespondingCloseChar(ce.getDot() + i, charList.getOpenCloseChar(c));
            return;
        } else if(charList.isCloseChar(c)) {
            highlightChar(ce.getDot() + i);
            highlightCorrespondingOpenChar(ce.getDot() + i, charList.getOpenCloseChar(c));
            return;
        }
    }
}
 
開發者ID:Skypr,項目名稱:BEAST,代碼行數:24,代碼來源:OpenCloseCharHighlighter.java

示例6: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
/**
     * Creates new form MainMenu
     */
public void caretUpdate(CaretEvent ce) {
           
         SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(editorPanes.get(tabbedPane.getSelectedIndex()));
         if (sDoc != null) {
             Token t = sDoc.getTokenAt(ce.getDot());
             if (t != null) {
                 CharSequence tData = t.getText(sDoc);
                 if (t.length > 40) {
                     tData = tData.subSequence(0, 40);
                 }
                 caretPosLabel.setText(t.toString() + ": " + tData);
             } else {
                 // null token, remove the status
//				lblToken.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("NO_TOKEN_AT_CURSOR"));
             }
         }
              }
 
開發者ID:ksaluja24,項目名稱:scratch-bench,代碼行數:21,代碼來源:MainMenu.java

示例7: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
@Override
public void caretUpdate(CaretEvent e) {
	if (isVisible()) { // Should always be true
		int line = ac.getLineOfCaret();
		if (line!=lastLine) {
			lastLine = -1;
			setVisible(false);
		}
		else {
			doAutocomplete();
		}
	}
	else if (AutoCompletion.getDebug()) {
		Thread.dumpStack();
	}
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:17,代碼來源:AutoCompletePopupWindow.java

示例8: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
/**
 * Called when the text component's caret moves.
 *
 * @param e The event.
 */
@Override
public void caretUpdate(CaretEvent e) {
	if (maxPos==null) { // Sanity check
		deactivate();
		return;
	}
	int dot = e.getDot();
	if (dot<minPos || dot>maxPos.getOffset()) {
		deactivate();
		return;
	}
	paramPrefix = updateToolTipText();
	if (active) {
		prepareParamChoicesWindow();
	}
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:22,代碼來源:ParameterizedCompletionContext.java

示例9: fireCaretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
/**
 * Notifies all listeners that a caret change has occurred.
 *
 * @param e The caret event.
 */
@Override
protected void fireCaretUpdate(CaretEvent e) {

	// Decide whether we need to repaint the current line background.
	possiblyUpdateCurrentLineHighlightLocation();

	// Now, if there is a highlighted region of text, allow them to cut
	// and copy.
	if (e!=null && e.getDot()!=e.getMark()) {// && !cutAction.isEnabled()) {
		cutAction.setEnabled(true);
		copyAction.setEnabled(true);
	}

	// Otherwise, if there is no highlighted region, don't let them cut
	// or copy.  The condition here should speed things up, because this
	// way, we will only enable the actions the first time the selection
	// becomes nothing.
	else if (cutAction.isEnabled()) {
		cutAction.setEnabled(false);
		copyAction.setEnabled(false);
	}

	super.fireCaretUpdate(e);

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:31,代碼來源:RTextArea.java

示例10: TableViewLayoutTest

import javax.swing.event.CaretEvent; //導入依賴的package包/類
public TableViewLayoutTest() {

        super("Code example for a TableView bug");
        setUndecorated(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        edit.setEditorKit(new CodeBugEditorKit());
        initCodeBug();
        this.getContentPane().add(new JScrollPane(edit));
        this.pack();
        this.setLocationRelativeTo(null);

        edit.addCaretListener(new CaretListener() {
            public void caretUpdate(CaretEvent e) {
                JTextComponent textComp = (JTextComponent) e.getSource();
                try {
                    Rectangle rect = textComp.getUI().modelToView(textComp, e.getDot());
                    yCaret = rect.getY();
                    xCaret = rect.getX();
                } catch (BadLocationException ex) {
                    throw new RuntimeException("Failed to get pixel position of caret", ex);
                }
            }
        });
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:TableViewLayoutTest.java

示例11: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
public void caretUpdate(CaretEvent e) {
    synchronized (this) {
        lastCaretPosition = e.getDot();
    }
    
    LOG.fine("scheduling hints computation");
    
    computeHint.schedule(100);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ComponentPeer.java

示例12: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
public void caretUpdate (final CaretEvent e) {
    if (parsingTask != null) {
        parsingTask.cancel ();
    }
    parsingTask = PROC.post (new Runnable () {
        public void run () {
            refresh (e.getDot ());
        }
    }, 1000);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:MarkOccurrencesSupport.java

示例13: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
public void caretUpdate (CaretEvent e) {
    int position = e.getDot ();
    try {
        selectPath (position);
    } catch (ConcurrentModificationException ex) {
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:TokensBrowserTopComponent.java

示例14: createCaretListenerForComponent

import javax.swing.event.CaretEvent; //導入依賴的package包/類
private CaretListener createCaretListenerForComponent() {
    return new CaretListener() {

        @Override
        public void caretUpdate(CaretEvent e) {
            if (SearchBar.getInstance().isVisible()) {
                int num = SearchBar.getInstance().getNumOfMatches();
                SearchBar.getInstance().showNumberOfMatches(null, num);
            }
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:SearchBar.java

示例15: caretUpdate

import javax.swing.event.CaretEvent; //導入依賴的package包/類
public @Override void caretUpdate(CaretEvent e) {
    if (!ignoreNextCaretUpdate) {
        synchronized (this) {
            selectionInfos = null;
            selIndex = -1;
        }
    }
    ignoreNextCaretUpdate = false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:SelectCodeElementAction.java


注:本文中的javax.swing.event.CaretEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。