Codice: Seleziona tutto
public void ShrinkWindowBy75(XScriptContext xScriptContext) {
XComponentContext xComponentContext = xScriptContext.getComponentContext();
try {
Object desktop = xComponentContext.getServiceManager().createInstanceWithContext(
"com.sun.star.frame.Desktop", xComponentContext);
XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop);
XFrame xFrame = xDesktop.getCurrentFrame();
XWindow xWindow = xFrame.getContainerWindow();
// Ottieni la posizione e la dimensione attuale della finestra
Rectangle rect = xWindow.getPosSize();
// Calcola la nuova dimensione (75% della dimensione originale)
int newWidth = (int) (rect.Width * 0.75);
int newHeight = (int) (rect.Height * 0.75);
// Ridimensiona la finestra al 75% delle dimensioni originali
xWindow.setPosSize(rect.X, rect.Y, newWidth, newHeight, PosSize.SIZE);
} catch (Exception e) {
e.printStackTrace();
}
}
grazie