i try with .. if the user enter (-99999) in textarea ..should end the user input and go to new fframe to start execute
public static void createAndShowGUI(){
MainMe frame = new MainMe();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScrollPane jsp = new JScrollPane();
jta = new JTextArea();
lines = new JTextArea("01");
lines.setBackground(Color.PINK);
lines.setEditable(false);
JButton button=new JButton("Click here to clear text");
JButton button2=new JButton("Compile");
jta.getDocument().addDocumentListener(new DocumentListener(){
public String getText(){
final int END=-9999;
int caretPosition = jta.getDocument().getLength();
Element root = jta.getDocument().getDefaultRootElement();
String text = "01" + System.getProperty("line.separator");
for(int i = 2; i < root.getElementIndex(caretPosition) +2; i++){
text += "0"+i + System.getProperty("line.separator");
if(text=="-9999"){
JOptionPane.showMessageDialog(null, text);
}
}
return text;
}
/* public void perform(){
getText();
}*/
public void changedUpdate(DocumentEvent de) {
lines.setText(getText());
}
public void insertUpdate(DocumentEvent de) {
lines.setText(getText());
}
public void removeUpdate(DocumentEvent de) {
lines.setText(getText());
}
});
jsp.getViewport().add(jta);
jsp.setRowHeaderView(lines);
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
frame.add(jsp);
frame.pack();
frame.setSize(500,500);
frame.setVisible(true);}