1

I want to create a program to format a string into a code(As the Java coding convention). I tried with this.

final JEditorPane codeEditor = new JEditorPane();
JScrollPane scrPane = new JScrollPane(codeEditor);
c.add(scrPane, BorderLayout.CENTER);
codeEditor.setContentType("text/java");
codeEditor.setText("public static void main(String[] args) {\n}");

This is actually working for typing on the pane. How can I improve this code to format my string when I press a button. Such as...

class A{
   public static void main(String args[]){
   System.out.println("A");
   }
}

Thanks in Advance!

Prmths
  • 2,022
  • 4
  • 21
  • 38
JhonF
  • 199
  • 2
  • 2
  • 7

0 Answers0