I'm making a manager to use mysql through it and not that ugly console, so I get to put on a JTextPane the command "Create database user", and my var R gets that string and I make a substring to take 'user' only, however when I try to create another database and write for example "Create database example" it will take all the lines from the JTextPane and my var R will take "User create database example", so how can I make that var to get the text from a specific line of my JTextPane, here is the code I have so far:
private void jTextPane1KeyPressed(java.awt.event.KeyEvent evt) {
int key = evt.getKeyCode();
if (key == KeyEvent.VK_ENTER) {
try {
sentencia = conexion.createStatement();
se = jTextPane1.getText().toLowerCase();
String r = se.replaceAll("['\n|\t|\r]", " ").substring(16);
System.out.println(r);
sentencia.executeUpdate("create database "+r);
System.out.println("BBDD Created");
r = "";
} catch (Exception ae) {
System.err.println(ae.getMessage());
System.out.println("BBDD not Created");
}//catch
}//if
}