Пример #1
0
  public static void main(String[] args) throws Exception {
    JTextArea textArea = new JTextArea(10, 50);
    textArea.setEditable(false);
    try {
      new DefaultEditorKit()
          .read(
              new FileReader(
                  "D:\\MyBlog\\IncrementalSearch\\src\\santhosh\\TextComponentFindAction.java"),
              textArea.getDocument(),
              0);
    } catch (Exception e) {
      e.printStackTrace();
    }

    FindAction findAction = new TextComponentFindAction();
    findAction.install(textArea);

    JScrollPane scroll = new JScrollPane(textArea);
    scroll.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(50, 10, 10, 10), scroll.getBorder()));

    JOptionPane.showMessageDialog(null, scroll);
  }