Exemple #1
0
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==b)
		{
			temp=tf.getText();
			temp1[]=ta.getText().split();
			index=0;
			index=temp1[].indexOf(temp,index);
			ta.select(index, index+temp.length());
			b.setVisible(false);
			b1.setVisible(true);
		}
		if(e.getSource()==b1)
		{
			index=temp1.indexOf(temp,index+temp.length());
			if(index!=-1)
			{
				ta.requestFocusInWindow();
				ta.select(index, index+temp.length());
			}
			else
			{
				b.setVisible(true);
				b1.setVisible(false);
				index=0;
			}
		}
	}	
  public void findNext() {
    String selection = txt.getSelectedText();
    try {
      selection.equals("");
    } catch (NullPointerException e) {
      selection = textF.getText();
      try {
        selection.equals("");
      } catch (NullPointerException e2) {
        selection = JOptionPane.showInputDialog("Find:");
        textF.setText(selection);
      }
    }
    try {
      int select_start = txt.getText().toLowerCase().indexOf(selection.toLowerCase(), startIndex);
      int select_end = select_start + selection.length();
      txt.select(select_start, select_end);
      startIndex = select_end + 1;

      if (select_start == txt.getText().toLowerCase().lastIndexOf(selection.toLowerCase())) {
        startIndex = 0;
      }
    } catch (NullPointerException e) {
    }
  }
 /**
  * Will select the Mars Messages tab error message that matches the given specifications, if it is
  * found. Matching is done by constructing a string using the parameter values and searching the
  * text area for the last occurrance of that string.
  *
  * @param fileName A String containing the file path name.
  * @param line Line number for error message
  * @param column Column number for error message
  */
 public void selectErrorMessage(String fileName, int line, int column) {
   String errorReportSubstring =
       new java.io.File(fileName).getName()
           + ErrorList.LINE_PREFIX
           + line
           + ErrorList.POSITION_PREFIX
           + column;
   int textPosition = assemble.getText().lastIndexOf(errorReportSubstring);
   if (textPosition >= 0) {
     int textLine = 0;
     int lineStart = 0;
     int lineEnd = 0;
     try {
       textLine = assemble.getLineOfOffset(textPosition);
       lineStart = assemble.getLineStartOffset(textLine);
       lineEnd = assemble.getLineEndOffset(textLine);
       assemble.setSelectionColor(Color.YELLOW);
       assemble.select(lineStart, lineEnd);
       assemble.getCaret().setSelectionVisible(true);
       assemble.repaint();
     } catch (BadLocationException ble) {
       // If there is a problem, simply skip the selection
     }
   }
 }
 public void find() {
   select_start = txt.getText().toLowerCase().indexOf(textF.getText().toLowerCase());
   if (select_start == -1) {
     startIndex = 0;
     JOptionPane.showMessageDialog(null, "Could not find \"" + textF.getText() + "\"!");
     return;
   }
   if (select_start == txt.getText().toLowerCase().lastIndexOf(textF.getText().toLowerCase())) {
     startIndex = 0;
   }
   int select_end = select_start + textF.getText().length();
   txt.select(select_start, select_end);
 }