Button extends FormControl { public void setLabel(String label) { ((FormButtonElement) mElement).setFormLabelAttribute(label); } Button(FormButtonElement element); static Button getInstanceOf(FormButtonElement element); @Override void setControlImplementation(String controlImpl); @Override void setId(String id); @Override String getId(); @Override String getName(); @Override void setName(String name); void setLabel(String label); String getLabel(); void setValue(String value); static Iterator<FormControl> getSimpleIterator(Form container);  }
@Test public void testSetLabel() { try { TextDocument textDoc = TextDocument.loadDocument(ResourceUtilities .getTestResourceAsStream("TestCreateButton.odt")); Form form = textDoc.getFormByName("Test Form"); Iterator<FormControl> iterator = Button.getSimpleIterator(form); Button find = null; while (iterator.hasNext()) { Button btn = (Button) iterator.next(); if (btn.getName().equals("Button4")) { find = btn; break; } } Assert.assertNotNull(find); String newLabel = "Change the content of button 4."; find.setLabel(newLabel); Assert.assertEquals(newLabel, find.getLabel()); find.setLabel(null); Assert.assertEquals("", find.getLabel()); textDoc.save(ResourceUtilities .newTestOutputFile("TestSetButtonLabel.odt")); } catch (Exception e) { Logger.getLogger(ButtonTest.class.getName()).log(Level.SEVERE, null, e); Assert.fail(); } }