Java Code Examples for javax.swing.event.CaretEvent.getMark()

The following are Jave code examples for showing how to use getMark() of the javax.swing.event.CaretEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: powertext   File: RTextArea.java   View Source Code Vote up 6 votes
/**
 * 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);

}
 
Example 2
Project: incubator-netbeans   File: AbbrevDetection.java   View Source Code Vote up 5 votes
public void caretUpdate(CaretEvent evt) {
    if (evt.getDot() != evt.getMark()) {
        surroundsWithTimer.setInitialDelay(SURROUND_WITH_DELAY);
        surroundsWithTimer.restart();
    } else {
        surroundsWithTimer.stop();
        hideSurroundWithHint();
    }
}
 
Example 3
Project: powertext   File: Caretlistener.java   View Source Code Vote up 5 votes
@Override        
    public void caretUpdate(CaretEvent evt) {
       JTextArea textPane1 =(JTextArea)evt.getSource();
        int row = getRow(evt.getDot(), textPane1); //row += 1;
        int col = getColumn(evt.getDot(), textPane1);
        
cal.setText("Line: " + row + " Column: " + col);
cln = row;
                
        //Get the location in the text
int dot = evt.getDot();
int mark = evt.getMark();
int totalsel = mark - dot ;
int totalsele = dot - mark ;
if (dot == mark) {  
    //Rectangle caretCoords = textPane.modelToView(dot);
    
    Totalsel.setText("Caret Position: " + dot ); doti = dot;
    //jLabel17.setText("Caret Position : " + dot);
    //jLabel18.setText("Current Line : " + row);
    jLabel500.setText(""+row);   jLabel501.setText(""+col);
    //jLabel19.setText("Current Column : " + col);
    mark +=1 ;
 } else if (dot < mark) {
    statusLabel.setText("Selection : " + totalsel + "\t | \t" + row);
    jLabel26.setText("Selection : " + totalsel + "\t | \t" + row);
    
 } else {
    jLabel26.setText("Selection : " + totalsele + "\t | " + row);
    statusLabel.setText("Selection : " + totalsele + "\t | \t" + row);
 }
    }
 
Example 4
Project: powertext   File: Caretlistener.java   View Source Code Vote up 5 votes
@Override        
    public void caretUpdate(CaretEvent evt) {
       JTextArea textPane1 =(JTextArea)evt.getSource();
        int row = getRow(evt.getDot(), textPane1); //row += 1;
        int col = getColumn(evt.getDot(), textPane1);
        
cal.setText("Line: " + row + " Column: " + col);
cln = row;
                
        //Get the location in the text
int dot = evt.getDot();
int mark = evt.getMark();
int totalsel = mark - dot ;
int totalsele = dot - mark ;
if (dot == mark) {  
    //Rectangle caretCoords = textPane.modelToView(dot);
    
    Totalsel.setText("Caret Position: " + dot ); doti = dot;
    //jLabel17.setText("Caret Position : " + dot);
    //jLabel18.setText("Current Line : " + row);
    jLabel500.setText(""+row);   jLabel501.setText(""+col);
    //jLabel19.setText("Current Column : " + col);
    mark +=1 ;
 } else if (dot < mark) {
    statusLabel.setText("Selection : " + totalsel + "\t | \t" + row);
    jLabel26.setText("Selection : " + totalsel + "\t | \t" + row);
    
 } else {
    jLabel26.setText("Selection : " + totalsele + "\t | " + row);
    statusLabel.setText("Selection : " + totalsele + "\t | \t" + row);
 }
    }
 
Example 5
Project: DIA-Umpire-Maven   File: AlignWindow.java   View Source Code Vote up 5 votes
/**
 * @param event
 */
private void handleCaretUpdateEvent(CaretEvent event) {
    if (event.getSource() == currentTextComponent) {
        boolean enabled = event.getDot() != event.getMark();
        // Read controls
        setCopyControlsEnabled(enabled);

        // Write controls
        enabled &= currentTextComponent.isEditable();
        setCutControlsEnabled(enabled);
        setDeleteControlsEnabled(enabled);
    }
}