public void test(TestHarness harness)
{
// use a known look and feel
try
{
UIManager.setLookAndFeel(new MetalLookAndFeel());
}
catch (Exception e)
{
harness.fail("Problem setting MetalLookAndFeel");
}
JComboBox c1 = new JComboBox(new Object[] {"A", "B", "C"});
c1.addPropertyChangeListener(this);
ComboBoxEditor editor = new MetalComboBoxEditor();
c1.setEditor(editor);
harness.check(c1.getEditor(), editor);
harness.check(event.getPropertyName(), "editor");
harness.check(event.getNewValue(), editor);
// set a new look and feel and see if the editor (which doesn't implement
// UIResource) gets replaced
try
{
UIManager.setLookAndFeel(new TestLookAndFeel());
}
catch (Exception e)
{
harness.fail("Problem setting TestLookAndFeel");
}
c1.updateUI();
JComboBox c2 = new JComboBox();
harness.check(c1.getEditor(), editor);
harness.check(c2.getEditor() instanceof BasicComboBoxEditor.UIResource);
// restore MetalLookAndFeel so as not to interfere with other tests
try
{
UIManager.setLookAndFeel(new MetalLookAndFeel());
}
catch (Exception e)
{
harness.fail("Problem restoring MetalLookAndFeel");
}