Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make a JLabel hyperlink change depending on a JTextField  RSS feed

 
Rebecca Jonson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone !

This is a part of my program. When the user enters "Exam Schedule" in the JtextField and clicks the add button I want the link to change to a link that opens a local pdf file. And if the user enters "Academic Calendar" the Jlabel will be set to another link. So far this works fine but the problem is that if you erase the textfield and enter another value the link of the previous value will still be there. Can you help me?

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a text change listener to your text field that delets the link whenever the text changes.
 
Rebecca Jonson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply!
I'm so sorry but is possible to show me how to add that?
I'm new to this and still learning
thank you again!
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been a while since I did any Swing programming.
You actually need to add the listener to the underlying document.
This contains some sample code for how to do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!