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


Java Utilities.getRowStart方法代碼示例

本文整理匯總了Java中javax.swing.text.Utilities.getRowStart方法的典型用法代碼示例。如果您正苦於以下問題:Java Utilities.getRowStart方法的具體用法?Java Utilities.getRowStart怎麽用?Java Utilities.getRowStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.Utilities的用法示例。


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

示例1: getRow

import javax.swing.text.Utilities; //導入方法依賴的package包/類
public int getRow(int pos,JTextArea textPane1)
{
    int rn=(pos==0) ? 1:0;
    try
    {
        int offs=pos;
        while(offs>0)
        {
            offs=Utilities.getRowStart(textPane1, offs)-1;
            rn++;
        }
    }
    catch(BadLocationException evt){ evt.printStackTrace();}

    return rn;
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:17,代碼來源:Caretlistener.java

示例2: getCursorPosition

import javax.swing.text.Utilities; //導入方法依賴的package包/類
/**
 * Get the cursor position for the popup menu
 * 
 * @param jText
 *            current JTextComponent
 * @return the current position
 * @throws BadLocationException
 *             should never occur
 */
protected int getCursorPosition( JTextComponent jText ) throws BadLocationException {
    Caret caret = jText.getCaret();
    int offs;
    Point p = jText.getMousePosition();
    if( p != null ) {
        // use position from mouse click and not from editor cursor position 
        offs = jText.viewToModel( p );
        // calculate rectangle of line
        int startPos = Utilities.getRowStart( jText, offs );
        int endPos = Utilities.getRowEnd( jText, offs );
        Rectangle bounds = jText.modelToView( startPos ).union( jText.modelToView( endPos ) );
        if( !bounds.contains( p ) ){
            return -1; // mouse is outside of text
        }
    } else {
        offs = Math.min( caret.getDot(), caret.getMark() );
    }
    Document doc = jText.getDocument();
    if( offs > 0 && (offs >= doc.getLength() || Character.isWhitespace( doc.getText( offs, 1 ).charAt( 0 ) )) ) {
        // if the next character is a white space then use the word on the left site
        offs--;
    }
    return offs;
}
 
開發者ID:kolchagov,項目名稱:jlokalize,代碼行數:34,代碼來源:CheckerListener.java

示例3: action

import javax.swing.text.Utilities; //導入方法依賴的package包/類
public void action()
{
	JTextComponent c = getTextComponent();
	if(c != null)
	{
		try
		{
			int offs = c.getCaretPosition();
			int begOffs = Utilities.getRowStart(c, offs);
			if(select)
			{
				c.moveCaretPosition(begOffs);
			}
			else
			{
				c.setCaretPosition(begOffs);
			}
		}
		catch(Exception e)
		{
			UIManager.getLookAndFeel().provideErrorFeedback(c);
		}
	}
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:25,代碼來源:CEditorBeginLineAction.java

示例4: mouseClicked

import javax.swing.text.Utilities; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent me) {
    if (me.getClickCount() < 2) return;

    int pos = output.viewToModel(me.getPoint());

    try {
        int rowStart = Utilities.getRowStart(output, pos);
        int rowEnd = Utilities.getRowEnd(output, pos);
        String line = output.getDocument().getText(rowStart, rowEnd - rowStart);
        if (opListener.getCmdHistory().contains(line)) {
            output.select(rowStart, rowEnd);
            cliGuiCtx.getCommandLine().getCmdText().setText(line);
            systemClipboard.setContents(new StringSelection(line), this);
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }

}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:21,代碼來源:SelectPreviousOpMouseAdapter.java

示例5: getColumn

import javax.swing.text.Utilities; //導入方法依賴的package包/類
public int getColumn(int pos,JTextArea textPane1)
{
    try
    {
        return pos-Utilities.getRowStart(textPane1, pos)+1;
    }
    catch (BadLocationException evt) {evt.printStackTrace();  }

    return -1;
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:11,代碼來源:Caretlistener.java

示例6: getRow

import javax.swing.text.Utilities; //導入方法依賴的package包/類
public static int getRow(int pos, JTextPane editor) {
    int rn = (pos == 0) ? 1 : 0;
    try {
        int offs = pos;
        while (offs > 0) {
            offs = Utilities.getRowStart(editor, offs) - 1;
            rn++;
        }
    } catch (BadLocationException e) {
    }
    return rn;
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:13,代碼來源:CLEditor.java

示例7: getColumn

import javax.swing.text.Utilities; //導入方法依賴的package包/類
public static int getColumn(int pos, JTextPane editor) {
    try {
        return pos - Utilities.getRowStart(editor, pos) + 1;
    } catch (BadLocationException e) {
    }
    return -1;
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:8,代碼來源:CLEditor.java

示例8: getCurrentCaretPosition

import javax.swing.text.Utilities; //導入方法依賴的package包/類
private int getCurrentCaretPosition() {
	int rowNum=0;
	try {
		int caretPos = PrincipalWindow.interpreter.getCaretPosition();
		rowNum = (caretPos == 0) ? 1 : 0;
		for (int offset = caretPos; offset > 0;) {
		    offset = Utilities.getRowStart(PrincipalWindow.interpreter, offset) - 1;
		    rowNum++;
		}
	} catch (BadLocationException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	return rowNum;
}
 
開發者ID:BlidiWajdi,項目名稱:Mujeed-Arabic-Prolog,代碼行數:16,代碼來源:KeyMonitor.java

示例9: getRow

import javax.swing.text.Utilities; //導入方法依賴的package包/類
private static int getRow(final int pos, final JTextComponent editor) {
  int rn = (pos == 0) ? 1 : 0;
  try {
    int offs = pos;
    while (offs > 0) {
      offs = Utilities.getRowStart(editor, offs) - 1;
      rn++;
    }
  } catch (BadLocationException e) {
    LOGGER.error("Bad location", e); //NOI18N
  }
  return rn;
}
 
開發者ID:raydac,項目名稱:netbeans-mmd-plugin,代碼行數:14,代碼來源:NoteEditor.java

示例10: getColumn

import javax.swing.text.Utilities; //導入方法依賴的package包/類
private static int getColumn(final int pos, final JTextComponent editor) {
  try {
    return pos - Utilities.getRowStart(editor, pos) + 1;
  } catch (BadLocationException e) {
    LOGGER.error("Bad location", e); //NOI18N
  }
  return -1;
}
 
開發者ID:raydac,項目名稱:netbeans-mmd-plugin,代碼行數:9,代碼來源:NoteEditor.java

示例11: currentLine

import javax.swing.text.Utilities; //導入方法依賴的package包/類
private int currentLine() {
    int caretPos = scriptField.getCaretPosition();
    int rowNum = (caretPos == 0) ? 1 : 0;
    for (int offset = caretPos; offset > 0; ) {
        try {
            offset = Utilities.getRowStart(scriptField, offset) - 1;
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
        rowNum++;
    }
    return rowNum;
}
 
開發者ID:defano,項目名稱:hypertalk-java,代碼行數:14,代碼來源:ScriptEditor.java

示例12: getRow

import javax.swing.text.Utilities; //導入方法依賴的package包/類
/**
 * 指定キャレット位置の行番號を取得する
 * 
 * @param editor
 *            テキストコンポーネント
 * @param pos
 *            キャレット位置
 * @return 行番號(1〜)
 */
public static int getRow(JTextComponent editor, int pos) {
	int rn = (pos == 0) ? 1 : 0;
	try {
		int offs = pos;
		while (offs > 0) {
			offs = Utilities.getRowStart(editor, offs) - 1;
			rn++;
		}
	} catch (BadLocationException e) {
		e.printStackTrace();
	}
	return rn;
}
 
開發者ID:K-scope,項目名稱:K-scope,代碼行數:23,代碼來源:SwingUtils.java

示例13: getRow

import javax.swing.text.Utilities; //導入方法依賴的package包/類
public static int getRow(int pos, JTextComponent editor) {
    int rn = (pos==0) ? 1 : 0;
    try {
        int offs=pos;
        while( offs>0) {
            offs=Utilities.getRowStart(editor, offs)-1;
            rn++;
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
    return rn;
}
 
開發者ID:fauconnier,項目名稱:LaToe,代碼行數:14,代碼來源:Tools.java

示例14: getColumn

import javax.swing.text.Utilities; //導入方法依賴的package包/類
public static int getColumn(int pos, JTextComponent editor) {
    try {
        return pos-Utilities.getRowStart(editor, pos)+1;
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
    return -1;
}
 
開發者ID:fauconnier,項目名稱:LaToe,代碼行數:9,代碼來源:Tools.java

示例15: shouldComment

import javax.swing.text.Utilities; //導入方法依賴的package包/類
private boolean shouldComment(int start, int end) throws BadLocationException {
    int offset = start;
    int length = editor.getDocument().getLength();
    
    do {
        int rowStart = Utilities.getRowStart(editor, offset);
        int rowEnd = Utilities.getRowEnd(editor, offset);
        if(!isCommented(rowStart, rowEnd))
            return true;
        offset = rowEnd + 1;
    } while(offset <= end && offset < length);
    
    return false;
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:15,代碼來源:TogleCommentAction.java


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