Example usage for org.apache.poi.xslf.usermodel XSLFSlide getBackground

List of usage examples for org.apache.poi.xslf.usermodel XSLFSlide getBackground

Introduction

In this page you can find the example usage for org.apache.poi.xslf.usermodel XSLFSlide getBackground.

Prototype

@Override
public XSLFBackground getBackground() 

Source Link

Usage

From source file:org.joeffice.presentation.actions.BackgroundColorAction.java

License:Apache License

@Override
public void actionPerformed(ActionEvent e) {
    SlidesTopComponent currentTopComponent = OfficeTopComponent.getSelectedComponent(SlidesTopComponent.class);
    if (currentTopComponent != null) {
        String title = NbBundle.getMessage(getClass(), "CTL_BackgroundColorAction");
        Color chosenColor = JColorChooser.showDialog(WindowManager.getDefault().getMainWindow(), title,
                Color.WHITE);/*from  ww  w  .j  a  v  a2 s . c o  m*/
        if (chosenColor != null) {
            int currentSlide = currentTopComponent.getSelectedSlide();
            XSLFSlide slide = currentTopComponent.getPresentation().getSlides()[currentSlide];
            // This throws java.lang.IllegalStateException: CTShapeProperties was not found.
            slide.getBackground().setFillColor(chosenColor);

            // Also change the background of the panel
            JPanel mainComponent = (JPanel) currentTopComponent.getMainComponent();
            SlideComponent slidePanel = (SlideComponent) mainComponent.getComponent(currentSlide);
            slidePanel.setBackground(chosenColor);
        }
    }
}