<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[JavaRanch: Latest posts for the topic "JSpinner - disabled foreground color"]]></title>
		<link>http://www.coderanch.com/forums/t/2/Swing-AWT-SWT-JFace/JSpinner-disabled-foreground-color</link>
		<description><![CDATA[Latest messages posted in the topic "JSpinner - disabled foreground color"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>JSpinner - disabled foreground color</title>
				<description><![CDATA[I have a <a href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html" class="api" title="Java API" target="_new" rel="nofollow">JSpinner</a> that I want to be able to optionally disable spinner input,  but...<br /> <br />  I still want to use the editor part as a display by slaving it to something else.  That is working, but when I do a "setEnable(false)" the display turns gray.<br /> <br /> I've tried significant options to make it NOT be gray, but can't get it to behave. I've defined <br /> my own Jspinner class with<br /> <pre>
	@Override
	public void setForeground(Color inColor) {
		super.setForeground(inColor);
		 DefaultEditor editor = (DefaultEditor) getEditor();
	     editor.getTextField().setForeground(inColor);
	}
</pre><br /> <br /> but that only changes the foreground in "NON DISABLED" mode.  I need the foreground to change in DISABLED mode as well.<br /> <br /> Any ideas?<br /> <br /> As I said, I have my own <a href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html" class="api" title="Java API" target="_new" rel="nofollow">JSpinner</a> class now so modifying that isn't an issue.<br /> <br /> Regards,<br /> Kurt]]></description>
				<guid isPermaLink="true">http://www.coderanch.com/forums/posts/preList/442452/1968522</guid>
				<link>http://www.coderanch.com/forums/posts/preList/442452/1968522</link>
				<pubDate><![CDATA[Thu, Apr 23 2009 09:33:15 MDT]]></pubDate>
				<author><![CDATA[Kurt Peters]]></author>
			</item>
			<item>
				<title>JSpinner - disabled foreground color</title>
				<description><![CDATA[<pre>    
JTextField tf = ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();
tf.setEnabled(false);
tf.setDisabledTextColor(UIManager.getColor(&quot;TextField.foreground&quot;));
</pre>]]></description>
				<guid isPermaLink="true">http://www.coderanch.com/forums/posts/preList/442452/1968684</guid>
				<link>http://www.coderanch.com/forums/posts/preList/442452/1968684</link>
				<pubDate><![CDATA[Thu, Apr 23 2009 13:21:00 MDT]]></pubDate>
				<author><![CDATA[Michael Dunn]]></author>
			</item>
			<item>
				<title>JSpinner - disabled foreground color</title>
				<description><![CDATA[Thanks, that worked.  How would a mere mortal figure that one out from the documentation?<br /> <br /> My change foreground code is now:<br /> <pre>
	@Override
	public void setForeground(Color inColor) {
		super.setForeground(inColor);
		 DefaultEditor editor = (DefaultEditor) getEditor();
		 JTextField tf = editor.getTextField();
	     editor.getTextField().setForeground(inColor);
	     if (!isEnabled()) {
	    	 tf.setDisabledTextColor(UIManager.getColor(&quot;TextField.foreground&quot;));
	     }
	}
</pre><br /> I'm thinking it would get the color from the enabled one?<br /> Kurt]]></description>
				<guid isPermaLink="true">http://www.coderanch.com/forums/posts/preList/442452/1968753</guid>
				<link>http://www.coderanch.com/forums/posts/preList/442452/1968753</link>
				<pubDate><![CDATA[Thu, Apr 23 2009 15:11:24 MDT]]></pubDate>
				<author><![CDATA[Kurt Peters]]></author>
			</item>
			<item>
				<title>JSpinner - disabled foreground color</title>
				<description><![CDATA[&gt; I'm thinking it would get the color from the enabled one? <br /> <br /> UIManager.getColor(&quot;TextField.foreground&quot;) gets whatever the 'default' is,<br /> so should match the enabled one, but you can specify any color e.g.<br /> tf.setDisabledTextColor(Color.YELLOW); <br /> <br /> there is no real need to put it in the overridden setForeground().<br /> on it's own in the constructor will do - once set, stays that value until changed, <br /> regardless of whether the spinner is disabled/re-enabled/disabled again<br /> <br /> [edit]<br /> forgot this bit<br /> &gt; Thanks, that worked. How would a mere mortal figure that one out from the documentation? <br /> <br /> there are a huge number of methods in the <a href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html" class="api" title="Java API" target="_new" rel="nofollow">JTextComponent</a> api, so most of your document reading<br /> in regard to text components (textfield, textArea etc) should be directed to &quot;methods inherited from <a href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html" class="api" title="Java API" target="_new" rel="nofollow">JTextComponent</a>&quot;]]></description>
				<guid isPermaLink="true">http://www.coderanch.com/forums/posts/preList/442452/1968766</guid>
				<link>http://www.coderanch.com/forums/posts/preList/442452/1968766</link>
				<pubDate><![CDATA[Thu, Apr 23 2009 15:43:27 MDT]]></pubDate>
				<author><![CDATA[Michael Dunn]]></author>
			</item>
	</channel>
</rss>
