//boutton
ent.setBounds(490,400,100,50);
ent.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String text;
text=chatbox.getText().toLowerCase();
chatarea.append("\t\t\t\t"+text+" <- YOU \n");
chatbox.setText("");
if(text.contains("hii") || text.contains("hey") || text.contains("hi"))
{
bot("hey there");
bot("how can i help you?");
}
else if(text.contains("info") || text.contains("help") || text.contains("i need information") || text.contains("help me"))
{
bot("sure i am here to help you");
bot("what you want to know about?");
bot("1 info about anything?");
bot("2 info about place?");
bot("enter your choice : ");
if(text.contains("1")|| text.contains("info about anything") || text.contains("number 1") || text.contains("first one") || text.contains("first"))
{
bot("sure which blood group info you are looking for?");
}else if(text.contains("2") || text.contains("info about place") || text.contains("number 2") || text.contains("second one") || text.contains("second"))
else
{
bot("I Don't Understand you");
}
}
}
});
}
private void bot(String string)
{
chatarea.append("BOT -> "+string+"\n");
}
public static void main(String[] args)
{
new bot();
}
}
I am making a chat bot in which when I click on the JButton
it takes the value from JTextField
and posts it on a JTextArea
. But the problem is I want my code to be continue not stop but every time click on button it start the code from starting.
How to make code continue from same place in action performed when I second time click on the button?