Home Java Poi Change Background of Slide Using Java



Change Background of Slide Using Java
Posted on: March 14, 2008 at 12:00 AM
In this example we are going to create a slide then change background of the slide.

Change Background of Slide Using Java

     


In this example we are going to create a slide then change background of the slide.

In this example we are creating an object of the shape. In this object we assign rectangle shape and set the size and position. Initial values for x and y axis are 0.The height and width are 800 and 600 respectively. Then create an object of Shape and set values, fill type, background color and  foreground color  of the slide. Then finally add into slide. We are using   setFillType(Fill.FILL_SHADE) method to set fill type, setBackgroundColor(Color.blue) method to set background color and setForegroundColor(Color.green) method to set the text color.
  
 The code of the program is given below:
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.*;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.model.*;
import java.io.*;
import java.awt.Color;
import org.apache.poi.hslf.model.TextBox;
class changeBackground
{
  public static void main(String a[])
  {
  try
  {  
  SlideShow slideShow = new SlideShow();
  Slide slide = slideShow.createSlide();
  Shape shape = new AutoShape(ShapeTypes.Rectangle);
  shape.setAnchor(new java.awt.Rectangle(00800660));
  Fill fill = shape.getFill();
  fill.setFillType(Fill.FILL_SHADE);
  fill.setBackgroundColor(Color.blue);
  fill.setForegroundColor(Color.green);  
  slide.addShape(shape);
  FileOutputStream out = new FileOutputStream
(
"changeBackground.ppt");
  slideShow.write(out);
  out.close(); 
  }catch(Exception e){}
  }}

The output of the program is given below:

Download this example.

Related Tags for Change Background of Slide Using Java:
cidetextobjectiosizemethodcolorbackgroundtypeheightvaluewidthaxischangeusingintthisidsetpositioncreatetexforexamplefinaladdvaluestorectangleiniroundexamfinallyposanglessishexteilslidesignshapeitbackaxfilllihanginitpeinshaasbackgroundcolorforegroundmntososiddosiosjadesspecallmeintoobjackcreatingxaxampsrespectrectspeeespcolatkishallivndcmplgogreeaandartfshadeslixtwidvazxissth6atiapalufininitialjepleplndonolo


More Tutorials from this section

Ask Questions?    Discuss: Change Background of Slide Using Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.