本文整理匯總了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);
}
});
}
示例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);
}
}
}
示例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);
}
示例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;
}
}
示例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;
}
}
}
示例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"));
}
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}
}
});
}
示例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);
}
示例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);
}
示例13: caretUpdate
import javax.swing.event.CaretEvent; //導入依賴的package包/類
public void caretUpdate (CaretEvent e) {
int position = e.getDot ();
try {
selectPath (position);
} catch (ConcurrentModificationException ex) {
}
}
示例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);
}
}
};
}
示例15: caretUpdate
import javax.swing.event.CaretEvent; //導入依賴的package包/類
public @Override void caretUpdate(CaretEvent e) {
if (!ignoreNextCaretUpdate) {
synchronized (this) {
selectionInfos = null;
selIndex = -1;
}
}
ignoreNextCaretUpdate = false;
}