Witam was programiści i programistki.
Opis programu:
Program ma mi automatycznie dać średnik na końcu wersu po przejściu na nową linie klawiszem enter.
Mam Fragment Kodu który mi to robi, ale mam problem ponieważ on mi nie doda średnika jeżeli będę coś pisał między tekstami np. kiedy będę tworzył nową linie między innymi liniami.
//EditiorPane Code
WritingCode WritingCode = new WritingCode();
JEditorPane editorPane_TextEditor = new JEditorPane();
editorPane_TextEditor.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent key) {
System.out.println("Key Code : "+key.getKeyCode());
System.out.println("Key Char : "+key.getKeyChar());
System.out.println("Key Modifers : "+key.getModifiers());
if(key.getKeyCode() == 10){
editorPane_TextEditor.setText(editorPane_TextEditor.getText() + WritingCode.checkSemicolon(editorPane_TextEditor.getText()));
}
}
});
public String checkSemicolon(String a){
System.out.println(a.endsWith(";"));
if(a.endsWith(";") == false){
return (";");
}
return "";
}
Dlatego pomyślałem o znakach nowej linii. Jednak to już jest ponad moje możliwości.