views:

192

answers:

3

hi all, i want to write a text editor in java. i want it have a snippet feature similar to textmate. now i have no idea what to use as the main editor area. should i use some widget in swing?

great thanks.

+2  A: 

I think you are going to want to use JTextArea, and probably wrap it in a JScrollPane. You may want to look at JEdit, it is a text editor written in java, you can view the source and get some ideas from how they are doing things. The tricky part is going to be handling the formatting of snippet you are trying to create. JEdit has plugins for different languages, so I would definitely check that out for some ideas on how they handle things.

broschb
+1 for looking at source code of JEdit
JuanZe
Indeed... jEdit is a great suggestion... they have one of the better text editing components for Java, imo.
jsight
+2  A: 

Since a large part of the core added value of an editor such as textmate is the text editing view, if you were making a text editor you probably should implement the view from scratch ( JComponent and override drawing and event handling ).

If instead you want a feature rich text editing component for another project, then there's a Java binding http://sourceforge.net/projects/jintilla/ for the Scintilla editor, which is quite nice ( SciTE or Notepad++ use Scintilla ).

Pete Kirkham
A: 

If I understand what you're wanting to do, you could use a JTextArea to accomplish this. I have a multithreaded text editor application I made that uses a JTextArea as the main editing area. It's nothing fancy but it was fun to make.

ChadNC