当前位置: 首页>>代码示例>>Java>>正文


Java BadLocationException.printStackTrace方法代码示例

本文整理汇总了Java中javax.swing.text.BadLocationException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java BadLocationException.printStackTrace方法的具体用法?Java BadLocationException.printStackTrace怎么用?Java BadLocationException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.BadLocationException的用法示例。


在下文中一共展示了BadLocationException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateBracketHighlight

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
protected void updateBracketHighlight(int newCaretPosition) {
	if (newCaretPosition == 0) {
		bracketPosition = bracketLine = -1;
		return;
	}

	try {
		int offset = TextUtilities.findMatchingBracket(document, newCaretPosition - 1);
		if (offset != -1) {
			bracketLine = getLineOfOffset(offset);
			bracketPosition = offset - getLineStartOffset(bracketLine);
			return;
		}
	} catch (BadLocationException bl) {
		bl.printStackTrace();
	}

	bracketLine = bracketPosition = -1;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:JEditTextArea.java

示例2: actionPerformed

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {

         JTextComponent tc = getTextComponent(e);
         String filename = null;

         // Get the name of the file to load. If there is a selection, use
         // that as the file name, otherwise, scan for a filename around
         // the caret.
         try {
            int selStart = tc.getSelectionStart();
            int selEnd = tc.getSelectionEnd();
            if (selStart != selEnd) {
               filename = tc.getText(selStart, selEnd - selStart);
            } else {
               filename = getFilenameAtCaret(tc);
            }
         } catch (BadLocationException ble) {
            ble.printStackTrace();
            UIManager.getLookAndFeel().provideErrorFeedback(tc);
            return;
         }

         menuFunctions.loadFile(new File(filename));

      }
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:26,代码来源:PTextEditor.java

示例3: ScrollManager

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
public ScrollManager(DiffPanel firstDiffPanel, DiffPanel secondDiffPanel) {
    this.firstEditor = firstDiffPanel.getEditor();
    this.secondEditor = secondDiffPanel.getEditor();
    this.firstScrollPane = firstDiffPanel.getScrollPane();
    this.secondScrollPane = secondDiffPanel.getScrollPane();
    final JViewport secondViewport = secondScrollPane.getViewport();
    final JViewport firstViewport = firstScrollPane.getViewport();
    final ChangeListener changeListener = e -> {
        if (diffResult == null || ignoreUpdate)
            return;
        try {
            ignoreUpdate = true;
            if (firstScrollPane.getViewport() == e.getSource()) {
                syncScrollPanes(firstEditor, secondEditor, firstViewport, secondViewport, true);
            } else {
                syncScrollPanes(secondEditor, firstEditor, secondViewport, firstViewport, false);
            }
        } catch (BadLocationException e1) {
            e1.printStackTrace();
        } finally {
            ignoreUpdate = false;
        }
    };
    firstViewport.addChangeListener(changeListener);
    secondViewport.addChangeListener(changeListener);
}
 
开发者ID:vedun-z,项目名称:difftool,代码行数:27,代码来源:ScrollManager.java

示例4: rowAtPoint

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
private int rowAtPoint(Point p) {

		int line = 0;

		try {
			int offs = textArea.viewToModel(p);
			if (offs>-1) {
				line = textArea.getLineOfOffset(offs);
			}
		} catch (BadLocationException ble) {
			ble.printStackTrace(); // Never happens
		}

		return line;

	}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:17,代码来源:FoldIndicator.java

示例5: scrollToText

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
/**
 * Scrolls the specified text component so the text between the starting and ending index are visible.
 */
public static void scrollToText(JTextComponent textComponent, int startingIndex, int endingIndex) {
    try {
        Rectangle startingRectangle = textComponent.modelToView(startingIndex);
        Rectangle endDingRectangle = textComponent.modelToView(endingIndex);

        Rectangle totalBounds = startingRectangle.union(endDingRectangle);

        textComponent.scrollRectToVisible(totalBounds);
        textComponent.repaint();
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:Utility.java

示例6: setDisplayNameTextToCommandLineText

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
private void setDisplayNameTextToCommandLineText() {
    try {
        String text = fullCommandLineTextField.getDocument().getText(0,
                fullCommandLineTextField.getDocument().getLength());
        displayNameTextField.setText(text);
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:SwingEditFavoriteInteraction.java

示例7: getParseTree

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
/**
 * Method that parses the current input of a BooleanExpCodeArea and returns a
 * FormalPropertyDescriptionParser.BooleanExpListContext object which can then be used for building an AST
 * out of the input.
 * @return a BooleanExpListContext node from the ANTLR generated ParseTree.
 */
public FormalPropertyDescriptionParser.BooleanExpListContext getParseTree() {
    String text = null;
    try {
        text = styledDocument.getText(0, styledDocument.getLength());
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
    lexer.setInputStream(new ANTLRInputStream(text));
    CommonTokenStream ts = new CommonTokenStream(lexer);
    parser.setTokenStream(ts);
    return parser.booleanExpList();
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:19,代码来源:BooleanExpANTLRHandler.java

示例8: removeUpdate

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
protected void removeUpdate(DefaultDocumentEvent chng) {
    super.removeUpdate(chng);
    DocumentUtilities.addEventPropertyStorage(chng);
    try {
        DocumentUtilities.putEventProperty(chng, String.class,
                getText(chng.getOffset(), chng.getLength()));
    } catch (BadLocationException e) {
        e.printStackTrace();
        throw new IllegalStateException(e.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ModificationTextDocument.java

示例9: setText

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
void setText (final String text) {
    try {
        if (text.equals (getText ())) return;
        doc.insertString (end.getOffset (), text, null);
        doc.remove (start.getOffset (), end.getOffset () - start.getOffset () - text.length ());
    } catch (BadLocationException ex) {
        ex.printStackTrace ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:InstantRenameAction.java

示例10: nextWord

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
/**
   * This returns the next word in the iteration. Note that any implementation should return
   * the current word, and then replace the current word with the next word found in the
   * input text (if one exists).
   * @return the next word in the iteration.
   */
  @Override
public String nextWord() {
    if (!first) {
      currentWordPos = nextWordPos;
      currentWordEnd = getNextWordEnd(text, currentWordPos);
      nextWordPos = getNextWordStart(text, currentWordEnd + 1);
    }
    int current = sentenceIterator.current();
    if (current == currentWordPos)
      startsSentence = true;
    else {
      startsSentence = false;
      if (currentWordEnd > current)
        sentenceIterator.next();
    }
    //The nextWordPos has already been populated
    String word = null;
    try {
    	// robert: bug fix - Segment's begin offset may be != 0
        int offs = currentWordPos - text.offset;
        word = document.getText(offs, currentWordEnd - currentWordPos);
      //word = document.getText(currentWordPos, currentWordEnd - currentWordPos);
    } catch (BadLocationException ex) {
    	ex.printStackTrace();
      moreTokens = false;
    }
    wordCount++;
    first = false;
    if (nextWordPos == -1)
      moreTokens = false;
    return word;
  }
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:39,代码来源:DocumentWordTokenizer.java

示例11: prepareParamChoicesWindow

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
/**
 * Updates the optional window listing likely completion choices,
 */
private void prepareParamChoicesWindow() {

	// If this window was set to null, the user pressed Escape to hide it
	if (paramChoicesWindow!=null) {

		int offs = getCurrentParameterStartOffset();
		if (offs==-1) {
			paramChoicesWindow.setVisible(false);
			return;
		}

		JTextComponent tc = ac.getTextComponent();
		try {
			Rectangle r = tc.modelToView(offs);
			Point p = new Point(r.x, r.y);
			SwingUtilities.convertPointToScreen(p, tc);
			r.x = p.x;
			r.y = p.y;
			paramChoicesWindow.setLocationRelativeTo(r);
		} catch (BadLocationException ble) { // Should never happen
			UIManager.getLookAndFeel().provideErrorFeedback(tc);
			ble.printStackTrace();
		}

		// Toggles visibility, if necessary.
		paramChoicesWindow.setParameter(lastSelectedParam, paramPrefix);

	}

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:34,代码来源:ParameterizedCompletionContext.java

示例12: gotoNextDiff

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
private void gotoNextDiff() {
    try {
        Interval visibleLines = UIUtils.getVisibleLines(scrollPane.getViewport(), textPane);
        DiffInterval diffInterval = diffResult.getIntervalAfter(visibleLines.getStart(), isFirst);
        if (diffInterval == null)
            return;

        int end = diffInterval.getInterval(isFirst).getEnd();
        if (visibleLines.getStart() == end) {
            diffInterval = diffResult.getIntervalAfter(end + 1, isFirst);
            if (diffInterval == null)
                return;
            end = diffInterval.getInterval(isFirst).getEnd();
        }
        int targetLine = end + 1;

        if (targetLine >= diffResult.getSize(isFirst))
            return;

        do {
            DiffInterval nextDiff = diffResult.getIntervalAfter(targetLine, isFirst);
            if (nextDiff == null)
                return;
            Interval interval = nextDiff.getInterval(isFirst);
            if (interval.isLineBefore(targetLine))
                break;
            targetLine = interval.getEnd() + 1;
            if (targetLine >= diffResult.getSize(isFirst))
                return;
        } while (true);


        if (targetLine < diffResult.getSize(isFirst))
            UIUtils.showLine(scrollPane.getViewport(), textPane, targetLine - 1);
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:vedun-z,项目名称:difftool,代码行数:39,代码来源:DiffNavigationManager.java

示例13: highlight

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
public void highlight(ActionEvent e){
	JEditorPane editor = getEditor(e);
	if(editor != null){
		StyledEditorKit kit = getStyledEditorKit(editor);
		MutableAttributeSet attr = kit.getInputAttributes();
		javax.swing.text.DefaultHighlighter.DefaultHighlightPainter highlightPainter =
                   new javax.swing.text.DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);
		try {
			last = editor.getHighlighter().addHighlight(editor.getSelectionStart(), editor.getSelectionEnd(), highlightPainter);
		} catch (BadLocationException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:16,代码来源:HTMLEditor.java

示例14: modelToToken

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
/**
 * Returns the token at the specified position in the model.
 *
 * @param offs The position in the model.
 * @return The token, or <code>null</code> if no token is at that
 *         position.
 * @see #viewToToken(Point)
 */
public Token modelToToken(int offs) {
	if (offs>=0) {
		try {
			int line = getLineOfOffset(offs);
			Token t = getTokenListForLine(line);
			return RSyntaxUtilities.getTokenAtOffset(t, offs);
		} catch (BadLocationException ble) {
			ble.printStackTrace(); // Never happens
		}
	}
	return null;
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:21,代码来源:RSyntaxTextArea.java

示例15: indentNewLine

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
/** Inserts new line at given position and indents the new line with
    * spaces.
    *
    * @param doc the document to work on
    * @param offset the offset of a character on the line
    * @return new offset to place cursor to
    */
    public int indentNewLine (Document doc, int offset) {
//        if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("\n+ XMLFormatter::indentNewLine: doc = " + doc); // NOI18N
//        if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: offset = " + offset); // NOI18N

        if (doc instanceof BaseDocument) {
            BaseDocument bdoc = (BaseDocument)doc;

            bdoc.atomicLock();
            try {
                bdoc.insertString (offset, "\n", null); // NOI18N
                offset++;

                int fullLine = Utilities.getFirstNonWhiteBwd (bdoc, offset - 1);
                int indent = Utilities.getRowIndent (bdoc, fullLine);
                
//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: fullLine = " + fullLine); // NOI18N
//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: indent   = " + indent); // NOI18N
//
//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: offset   = " + offset); // NOI18N
//                    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: sb       = '" + sb.toString() + "'"); // NOI18N

                String indentation = getIndentString(bdoc, indent);
                bdoc.insertString (offset, indentation, null);
                offset += indentation.length();

//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: offset = " + offset); // NOI18N
            } catch (BadLocationException e) {
                if (Boolean.getBoolean ("netbeans.debug.exceptions")) { // NOI18N
                    e.printStackTrace();
                }
            } finally {
                bdoc.atomicUnlock();
            }

            return offset;
        }

        return super.indentNewLine (doc, offset);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:DTDFormatter.java


注:本文中的javax.swing.text.BadLocationException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。