简体   繁体   中英

in java language, in order to make a text editor like textmate, what widget should i use

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.

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.

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 ).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM