Hugo Santos Newbie

Joined: 10 May 2012 Posts: 2
|
Posted: Thu May 10, 2012 6:05 am Post subject: XButton properties |
|
|
Hi!
I'm making a extension for openoffice, i'm needing to do an interface like install interfaces with "next" and "back" buttons. I would like some help to change or delete the button "back" on the first step window. Another one a need to delete a textFrame e change the text of the "next" button to "finish".
So, i need some help to delete my interface dialogs without close and reopen my window.
this is how i set button properties as shown below:
| Code: |
public Object insertButton(int posX, int posY, int width, String label, int pushButtonType, boolean enabled, String uniqueName) throws Exception {
// Create a button control model
Object oButtonModel = xMultiComponentFactoryDialogModel.createInstance("com.sun.star.awt.UnoControlButtonModel");
// Set the properties at the model
XPropertySet xButtonPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oButtonModel);
xButtonPropertySet.setPropertyValue("PositionX",new Integer(posX));
xButtonPropertySet.setPropertyValue("PositionY",new Integer(posY));
xButtonPropertySet.setPropertyValue("Height",new Integer(14));
xButtonPropertySet.setPropertyValue("Width",new Integer(width));
xButtonPropertySet.setPropertyValue("Label",(label != null)? label: "");
xButtonPropertySet.setPropertyValue("PushButtonType",new Short((short) pushButtonType));
xButtonPropertySet.setPropertyValue("Name",uniqueName);
xButtonPropertySet.setPropertyValue("Enabled",enabled);
// Add the model to the dialog model name container
xDialogModelNameContainer.insertByName(uniqueName, oButtonModel);
// Add to a list of buttons
oButtonModelList.add(oButtonModel);
System.out.println("UN:"+uniqueName);
return oButtonModel;
}
|
this is how i insert the button into the interface as shown below:
| Code: |
//Keep button properties object to change when needed
buttonPropertiesBack = dialog1.insertButton(50, 80, 30, "Voltar", PushButtonType.STANDARD_value, true, "backButton");
XControl xButtonControlBack = dialog1.getxDialogContainer().getControl("backButton");
//Create Button
xbBack = (XButton) UnoRuntime.queryInterface(XButton.class, xButtonControlBack);
//xbvoltar = dialog1.insertButton(50, 80, 30, "Voltar", PushButtonType.STANDARD_value, false);
xbBack.addActionListener(new XActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
if (train == 0) {
System.out.println("Primeiro treino");
buttonPropertiesBack = dialog1.insertButton(50, 80, 30, "Voltar", PushButtonType.STANDARD_value, false, "backButton");
XControl xButtonControlBack = dialog1.getxDialogContainer().getControl("backButton");
//Create Button
xbBack = (XButton) UnoRuntime.queryInterface(XButton.class, xButtonControlBack);
} else {
dialog1.insertTextField(10, 10, 230, 60, texts[--train]);
}
} catch (Exception ex) {
Logger.getLogger(TrainingDialog.class.getName()).log(Level.SEVERE, null, ex);
}
throw new UnsupportedOperationException("Not supported yet.");
}
public void disposing(EventObject arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
|
this code is working to add, but i dont know how to remove the interface component.
thanks for help! |
|