Results 1 to 2 of 2
  1. #1
    sgerhardt is offline Member
    Join Date
    Jun 2011
    Rep Power

    Default Changing text color when combobox setEnabled() is false

    Hey guys, when I use the setEnabled() on comboboxes,(and its set to false) I'm wondering how I can change the text color so it is black and not gray. The people I'm developing software for, and myself, find it too hard to read and I can't find a way to access the text color. It was easy fixing text components as I just had to use setEditable() instead which did not gray the text color but there is not a setEditable() method available to comboboxes in SWT. Any help greatly appreciated!

  2. #2
    sgerhardt is offline Member
    Join Date
    Jun 2011
    Rep Power


    To further clarify, I have tried to override the method, but it won't use my method, instead it uses the inherited method which looks like this:
    Java Code:
     * Enables the receiver if the argument is <code>true</code>,
     * and disables it otherwise. A disabled control is typically
     * not selectable from the user interface and draws with an
     * inactive or "grayed" look.
     * @param enabled the new enabled state
     * @exception SWTException <ul>
     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
     * </ul>
    public void setEnabled (boolean enabled) {
    	checkWidget ();
    	* Feature in Windows.  If the receiver has focus, disabling
    	* the receiver causes no window to have focus.  The fix is
    	* to assign focus to the first ancestor window that takes
    	* focus.  If no window will take focus, set focus to the
    	* desktop.
    	Control control = null;
    	boolean fixFocus = false;
    	if (!enabled) {
    		if (display.focusEvent != SWT.FocusOut) {
    			control = display.getFocusControl ();
    			fixFocus = isFocusAncestor (control);
    	enableWidget (enabled);
    	if (fixFocus) fixFocus (control);
    I can't find the text painting code in here, and now I'm becoming a little more confused as I am somewhat more familiar with Swing which has the UIManager
    in which case it would look something like UIManager.put( "ComboBox.disabledText",; I'm not sure if there is an equivalent for SWT.
    Last edited by sgerhardt; 06-27-2011 at 09:59 PM.

Similar Threads

  1. Changing Image color
    By Frecow in forum Java 2D
    Replies: 0
    Last Post: 04-04-2011, 11:16 AM
  2. Changing background color
    By nikkka in forum New To Java
    Replies: 4
    Last Post: 03-12-2011, 06:54 AM
  3. Changing text color in SWT
    By ourimaler in forum SWT / JFace
    Replies: 1
    Last Post: 06-02-2010, 02:08 PM
  4. Color-changing model
    By higuchi in forum New To Java
    Replies: 1
    Last Post: 03-19-2009, 08:29 AM
  5. Changing the color of text
    By Lang in forum New To Java
    Replies: 1
    Last Post: 11-04-2007, 10: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