def react(event): #pass the String from textfield to chatbot function answer = textField.text newAnswer = chatbot(answer) #hide the old window frame.visible = False #create a new window newFrame = JFrame("hey", size=(400, 550)) #show an answer from robot and show message = JLabel(" ") message.text = newAnswer newFrame.add(message, SOUTH) #add other parts to the layout newbutton = JButton("push", actionPerformed=react) newFrame.add(newbutton, EAST) newtextField = JTextField('', 15) newFrame.add(textField, NORTH) newFrame.add(image, WEST) newFrame.visible = True
#create the window frame = JFrame("ChatCat", size=(400, 550)) #create textfield textField = JTextField('', 15) frame.add(textField, NORTH) #create button button = JButton("push", actionPerformed=react) frame.add(button, EAST) #show picture image = JLabel(ImageIcon(file)) frame.add(image, WEST) #show greeting greeting = JLabel(" ") greeting.text = "Nice to see you, " + name frame.add(greeting, SOUTH) #show the window frame.visible = True def chatbot(answer): #arrays greeting_keywords = ("Hi", "Hello", "hi", "what's up?", "hey", "Hey", "hello") greeting_responses = ["Hi", "Hey", " Hello"] conversation_keywords = ("How are you doing?", "How are you?", "how are you?", "How's going?") conversation_responses = ["I'm fine", "good"] introducing_keywords = ("what is your name?", "name?", "what's your name?", "who are you?")
naiveForm.setContentPane(naiveFormPanel) naiveForm.locationByPlatform = True # Put Objects Altogether on Panel naiveFormPanel.add(naiveHeader, BorderLayout.CENTER) naiveForm.add(myTabbedPane) naiveFormPanel.add(primaLabel) naiveFormPanel.add(aphaLabel) naiveFormPanel.add(bitPrimaLabel) naiveFormPanel.add(label1) naiveFormPanel.add(betaLabel) naiveFormPanel.add(bitPrima) naiveFormPanel.add(genPrima) naiveFormPanel.add(alpha) alpha.text = "20135" beta.text = "17096" genPrima.text = "90059" naiveFormPanel.add(beta) naiveFormPanel.add(genKeyButton) naiveFormPanel.add(kunciPrivatLabel) naiveFormPanel.add(kunciPrivatTextBox) naiveFormPanel.add(label3) naiveFormPanel.add(label4) naiveFormPanel.add(pesanAsli) naiveFormPanel.add(scrollPanePTx) naiveFormPanel.add(pesanTerenkripsi) naiveFormPanel.add(scrollPaneCTx) naiveForm.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE)