当前位置: 首页>>代码示例>>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;未经允许,请勿转载。