Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java GUI > Re: disable jco...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 9625 of 9959
Post > Topic >>

Re: disable jcombobox item

by "David A. Redick" <tinyweldingtorch@[EMAIL PROTECTED] > Apr 9, 2008 at 02:20 PM

Okie dokie...  I think I've figured it out.

Issues with this solution.
1) I'm getting the default background during the constructor. Could
cause fubars.
2) I'm relying on the BasicComboBoxEditor.editor object to be a
protected JTextField (in SE6 it is).
3) To get the dodgy object we have to make the comboBox an instance
object (or member object or wtf ever).

Seems to work rather well... nasty tho' and will prob. break on ever
other version of java.

[code]
private class MyComboBoxEditor extends BasicComboBoxEditor
{
	Color origBG;

	MyComboBoxEditor()
	{
		super();

		editor.setEditable(false);
		origBG = editor.getBackground();
	}

	public void setItem(Object anObject)
	{
		super.setItem(anObject);

		if(comboBox.getSelectedIndex() == dodgySelection)
		{
			editor.setBackground(Color.YELLOW);
		}
		else
		{
			editor.setBackground(origBG);
		}
	}
}
[/code]
 




 6 Posts in Topic:
disable jcombobox item
johnmmcparland <johnmm  2008-04-07 01:50:13 
Re: disable jcombobox item
RedGrittyBrick <RedGri  2008-04-07 10:20:10 
Re: disable jcombobox item
johnmmcparland <johnmm  2008-04-07 02:32:41 
Re: disable jcombobox item
"David A. Redick&quo  2008-04-09 14:01:45 
Re: disable jcombobox item
"David A. Redick&quo  2008-04-09 14:03:08 
Re: disable jcombobox item
"David A. Redick&quo  2008-04-09 14:20:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 13:19:49 CDT 2008.