Results 1 to 9 of 9
  1. #1
    saul_2110 is offline Member
    Join Date
    Dec 2008
    Location
    Mexico
    Posts
    10
    Rep Power
    0

    Question Text color in disabled componentes

    Could you tell me a way to change the color of the text in textfields when the textfields are disabled?

    In the default behavior, the text in disable textfields is a light blue.

    Thanks.

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

    Default

    java.awt.TextField? I don't think it can be done, but then I haven't worked with AWT.

    db

  3. #3
    saul_2110 is offline Member
    Join Date
    Dec 2008
    Location
    Mexico
    Posts
    10
    Rep Power
    0

    Default

    Sorry! I should've specified. I'm talking about

    javax.swing.JTextField

    Any ideas?

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

    Default

    Time for you to read this:
    How To Ask Questions The Smart Way

    Do you want to change the disabled text color for one JTextField, or for all instances of JTextField in your application?

    db

  5. #5
    saul_2110 is offline Member
    Join Date
    Dec 2008
    Location
    Mexico
    Posts
    10
    Rep Power
    0

    Default

    The link got me to thinking... ^_^

    Well, being completely honest, the GUI I built uses textfields, textareas and comboboxes to interact with the user. But I want the user to interact only when pressing certain buttons; the behavior I'm looking for is controlled by the "enable" property of the components.

    The problem is that while in "disabled" state, the text is too dim, hard to read. So I thought maybe there was a way to change "the color of text in disable components [even if that affects ALL components]".

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

    Default

    For all classes that inherit from JTextComponent, you can invoke the method setDisabledTextColor on each instance for which you need to change the color. For a JComboBox, it will depend on whether it's editable or not, and involve more code.

    To effect such changes on all components of specific classes, use UIManager#put(...) before creating your GUI. You can find an easy-to-use application for researching the UIManager's default values here:
    UIManager Defaults Java Tips Weblog

    db

  7. #7
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    446
    Rep Power
    6

    Default drag and drop

    hello

    how to drag and drop swing control.

    i am newer to java.
    please help me.

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

    Default

    makpandian

    Get your own thread. This one's about Text color in disabled componentes.

    db

  9. #9
    saul_2110 is offline Member
    Join Date
    Dec 2008
    Location
    Mexico
    Posts
    10
    Rep Power
    0

Similar Threads

  1. Replies: 6
    Last Post: 10-17-2008, 06:11 PM
  2. Disabled JButton font color
    By p900128 in forum Advanced Java
    Replies: 1
    Last Post: 07-24-2008, 08:16 AM
  3. How to change the foreground color of a disabled control
    By arunkumarsimhadri in forum New To Java
    Replies: 0
    Last Post: 07-09-2008, 04:30 PM
  4. Replies: 0
    Last Post: 06-25-2008, 10:33 AM
  5. Changing the color of text
    By Lang in forum New To Java
    Replies: 1
    Last Post: 11-04-2007, 09:51 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
  •