This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

trying to create a jtextfield to receive input from the user and run the code  RSS feed

 
Wai Loon Tan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is my code to extract links from a website. The output of this program is transferred to a JTextArea.
What i wanted to do now is,

I would like to create a JTextField to receive input URL from the user. Before this, the URL is typed inside the IDE console to run the program. However, i would like to type the URL in a JTextField and initiate the program.

The JTextField will transfer input from the user to this code :





I already created JTextfield. However, the jtext field does not start upon starting the program. The Jtextfield also do not receive input from the user. Where am i missing ?

 
kumarjit banerjee
Ranch Hand
Posts: 32
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create button and your class to implement ActionListener.
Then in the method
public void actionPerformed(ActionEvent e){
if(e.getSource.equals(your_button)){
//write your logic to extract text from textfield and the rest
}
}
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kumarjit banerjee wrote: . . . if(e.getSource.equals(your_button)) . . .
Not at all a good design. You are far better with different classes for the different actions.

And I shall move this thread to our GUIs forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!