Results 1 to 9 of 9
  1. #1
    Java Junior is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default JTextField input to change color

    Hello all, I'm having some issues with something and I hope someone can help me. I'm making this little applet that has 3 JTextfields and undernearth a String s = "Hello";

    The user can type into each JTextField values, and depending on these values the string "Hello" will change color. So if they typed in 255 0 0 and pressed the button it would change the color of the world "Hello to red. Likewise if they typed in 255 60 180 it would change the whatever color this represents. The thing is I have no idea how to tell the program that once the button is clicked, turn the color of the "Hello" string into the corresponding RGB values.

    I've set a global variable which sets the default color to black. I also have the actionPerformed and ActionKeyListener. I'm sure the code I need has to go into the actionPerformed method but if anyone can help that would be amazing. Unfortunately I can not provide my code here on the site but if you think you understand what I mean then I'll be able to use any help you provide me more than likely.

    Thanks.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: JTextField input to change color

    Quote Originally Posted by Java Junior View Post
    Unfortunately I can not provide my code here on the site
    Unfortunately that means you're not very likely to get any targeted help. We're not mind readers here, so we don't know where you're stuck.

    Have you gone through the Swing tutorials linked from the API of relevant Swing classes?

    Oh, and Java doesn't have global variables, so it's anybody's guess what you're on about.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: JTextField input to change color

    There's no need for private messages. If you can't discuss your assignment adequately on the forum, you can't expect much help.

    Oh, and I don't click external links. Not in a forum post, not in a PM. Code posted here, on the other hand, I do read. As would the many who will read this thread year after year, and not have to be disappointed at a pastebin link that has long gone dead.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Java Junior is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: JTextField input to change color

    I can not post my code here as when I submit my work the university scan the internet with a program called turnitin and it will show as a match on this site. Then they will think that I copied my code from this site even though this is my code... Thanks anyway but I'll wait to see if anyone else can help.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JTextField input to change color

    My experience here is that you're probably not going to get much specific help if we can't see what you've tried and how it isn't working. Sorry.

  6. #6
    Java Junior is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: JTextField input to change color

    I can use a pastebin link because I can set it to private, but having the code openly pasted on the forum is scanable and I risk being dropped from my course if they think I copied from the forums. But here is the pastebin link.

    Private Paste ID: gWb5iPap

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: JTextField input to change color

    Don't keep your hopes up. Most members, self included, won't click external links, and corporate firewall settings block file sharing sites for many others.

    Moreover, it is against the spirit of a forum for the problem to not be posted here.

    Your call.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    Java Junior is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: JTextField input to change color

    Well a simple paste bin link is not going to make your firewall go nuts mate. I understand that it's nice for everyone to benefit from the help you provide me which you still can, anyone who wishes to view the code can very easily with just 1 click of the link. It's infact better because not only does it provide syntax highlighting but you can also view the entire program in 1 page without having to scroll through a 2 inch code window. If you really won't help me for the sake of a link then thanks anyway but I'll wait around for someone who doesn't mind clicking a link.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JTextField input to change color

    Quote Originally Posted by Java Junior View Post
    Well a simple paste bin link is not going to make your firewall go nuts mate.
    Please don't speak out of ignorance, because yes in fact my work firewall and many others does in fact prevent this.

Similar Threads

  1. How to change background color
    By Jeffrey4u in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 10-22-2011, 08:32 AM
  2. Change the color in my program
    By carl in forum New To Java
    Replies: 5
    Last Post: 04-03-2009, 12:20 PM
  3. Color Change of data
    By Java.child in forum AWT / Swing
    Replies: 20
    Last Post: 02-12-2009, 06:51 AM
  4. How to Change the color of MultiColumnListBox
    By Java.child in forum AWT / Swing
    Replies: 1
    Last Post: 01-22-2009, 12:07 AM
  5. How to change string Color
    By Java.child in forum AWT / Swing
    Replies: 3
    Last Post: 01-06-2009, 04:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •