Example Usage:
Important here are the following classes: import org.jamesii.gui.syntaxeditor.SyntaxEditor; import org.jamesii.gui.syntaxeditor.highlighting.DefaultHighlighter; import org.jamesii.gui.syntaxeditor.highlighting.DefaultHighlighter.Style; import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class SyntaxEditorTest { public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame window = new JFrame("SyntaxEditorTest"); window.setSize(640, 480); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout()); DefaultHighlighter highlighter = new DefaultHighlighter( Style.JAVA); SyntaxEditor editor = new SyntaxEditor( highlighter.getLexer(), highlighter.getSyntaxStylizer()); window.getContentPane().add(editor, BorderLayout.CENTER); editor.setShowLineNumbers(true); editor.setShowIcons(true); editor.setShowAnnotations(true); editor .setText("import org.jamesii.gui.syntaxeditor.SyntaxEditor;\r\n" + "import org.jamesii.gui.syntaxeditor.highlighting.DefaultHighlighter;\r\n" + "import org.jamesii.gui.syntaxeditor.highlighting.DefaultHighlighter.Style;\r\n" + "\r\n" + "import java.awt.BorderLayout;\r\n" + "\r\n" + "import javax.swing.JFrame;\r\n" + "import javax.swing.SwingUtilities;\r\n" + "\r\n" + "public class SyntaxEditorTest {\r\n" + "\r\n" + " public static void main(String args[]) {\r\n" + " SwingUtilities.invokeLater(new Runnable() {\r\n" + "\r\n" + " @Override\r\n" + " public void run() {\r\n" + " JFrame window = new JFrame(\"SyntaxEditorTest\");\r\n" + " window.setSize(640, 480);\r\n" + " window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n" + "\r\n" + " window.getContentPane().setLayout(new BorderLayout());\r\n" + "\r\n" + " DefaultHighlighter highlighter = new DefaultHighlighter(\r\n" + " Style.JAVA);\r\n" + "\r\n" + " SyntaxEditor editor = new SyntaxEditor(\r\n" + " highlighter.getLexer(), highlighter.getSyntaxStylizer());\r\n" + "\r\n" + " window.getContentPane().add(editor, BorderLayout.CENTER);\r\n" + "\r\n" + " editor.setShowLineNumbers(true);\r\n" + " editor.setShowIcons(true);\r\n" + " editor.setShowAnnotations(true);\r\n" + " editor\r\n" + " .setText(\"\");\r\n" + "\r\n" + " window.setVisible(true);\r\n" + " }\r\n" + " });\r\n" + " }\r\n" + "\r\n" + "}\r\n"); window.setVisible(true); } }); } }
public enum JavaProblemTokenType {WARNING, ERROR}
public enum JavaSyntaxTokenType {COMMENT, STRING, NUMBER, ...}
|
|