1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer; import javax.swing.*; import org.apache.poi.xslf.usermodel.SlideLayout; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFSlide; import org.apache.poi.xslf.usermodel.XSLFSlideLayout; import org.apache.poi.xslf.usermodel.XSLFSlideMaster; import org.apache.poi.xslf.usermodel.XSLFTextParagraph; import org.apache.poi.xslf.usermodel.XSLFTextRun; import org.apache.poi.xslf.usermodel.XSLFTextShape; public class PresentationMaker extends JFrame{ private JTextField tftitle=null; private JTextArea tacontent=null; private JButton bcreate=null; public PresentationMaker(){ setSize(400,400); tftitle=new JTextField(); tftitle.setColumns(20); tacontent=new JTextArea(20,20); tacontent.setLineWrap(true); bcreate=new JButton("Create"); bcreate.addActionListener(new ButtonHandler()); setLayout(new BorderLayout()); add("North",tftitle); add("Center",tacontent); add("South",bcreate); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); show(); } class ButtonHandler implements ActionListener{ public void actionPerformed(ActionEvent e){ String stitle=tftitle.getText(); String stemp=tacontent.getText(); StringTokenizer stoken=new StringTokenizer(stemp); ArrayList<String> al=new ArrayList<String>(); int counter=0; for(int i=0;i<stemp.length();i++){ if(stemp.charAt(i)=='.'){ counter++; } } al.add(0,stitle.trim()); counter++; for(int i=1;i<counter;i++){ al.add(i,stoken.nextToken(".").trim()+"."); System.out.println(al.get(i)); } XMLSlideShow ppt=new XMLSlideShow(); XSLFSlideMaster slideMaster=ppt.getSlideMasters().get(0); XSLFSlideLayout titleLayout=slideMaster.getLayout(SlideLayout.TITLE_ONLY); XSLFSlide slide[]=new XSLFSlide[counter+1]; for(int i=0;i<counter;i++){ slide[i]=ppt.createSlide(titleLayout); XSLFTextShape title=slide[i].getPlaceholder(0); title.setText(al.get(i)); } File file=new File("C://Users/MARIO/Documents/NetBeansProjects/presentation1.pptx"); try{ FileOutputStream out=new FileOutputStream(file); ppt.write(out); out.close(); }catch(Exception ex){ } } } public static void main(String[] args) throws IOException{ new PresentationMaker(); } } |
Tuesday, April 5, 2016
Automatic Presentation Maker
Utilizing POI API which is designed to manipulate various file formats, this his short program creates a very simple presentation file automatically. The number of slides depends on the number of sentences entered by the user plus one for title.
Subscribe to:
Post Comments (Atom)
Best Casino Games - DRMCD
ReplyDeleteIf you've ever gambled on a 진주 출장마사지 casino, you've 광양 출장샵 probably heard 의정부 출장마사지 of it. These games are designed to entertain and 포천 출장샵 bet on real-life 순천 출장안마 customers. Learn more about