Welcome to Dream.In.Code
Become a Java Expert!

Join 150,101 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,849 people online right now. Registration is fast and FREE... Join Now!




Need Help in JAVA -About Presentation tools

 
Reply to this topicStart new topic

Need Help in JAVA -About Presentation tools, To open and save presentation

senyorita
24 Jun, 2008 - 05:48 AM
Post #1

New D.I.C Head
*

Joined: 5 Sep, 2007
Posts: 9


My Contributions
I am trying to do presentation tools( that are similar to powerpoint )using Java.
1)I cannot open the save files in the folder i have save (such as: C:/windows/temp/)...
2/)and its in .png format..how should i change it back to .txt format?
Can someone shown me where is the problem...Plz...

CODE

if(e.getSource() instanceof JMenuItem){
                if("New Project".equals(actCmd)){
                    try {
                        FileDialog fileDialog = new FileDialog(mainMenu, "New Project", FileDialog.SAVE);    
                        fileDialog.setDirectory("c:/");
                        fileDialog.setFile("*.kss");
                        fileDialog.show();
                        // Get and set the String file project name
                        newProj = fileDialog.getFile();
                        System.out.println("File Name :" + newProj);
                        // Open or create a random access file
                        raf = new RandomAccessFile("c:/"+newProj+".kss", "rw");
                        randomAccssFile = "c:/"+newProj+".kss";
                    }
                    catch(IOException ex) {
                        System.out.print("Error: " + ex);
                        System.exit(0);
                        }
                    System.out.println("new project:" + newProj);
                    
                    newFolder = new File("c:\\windows\\temp\\"+ newProj +"\\");
                    newFolder.mkdir();
                    //Set the directoryName to pass in to slide show class
                    directoryName = "C:/windows/temp/"+ newProj;        
                }
                if("Open Project".equals(actCmd)){
                        newProj ="";
                        FileDialog fileDialog = new FileDialog(mainMenu, "Open Project", FileDialog.LOAD);    
                        fileDialog.setDirectory("c:/");
                        fileDialog.setFile("*.kss");
                        fileDialog.show();
                        // Get and set the String file project name
                        String newProjFile = fileDialog.getFile();
                        int l = newProjFile.length() - 4;
                        for (int i =0; i<l; i++){
                            newProj +=""+newProjFile.charAt(i);
                        }
                        System.out.println("File Name :" + newProj);
                        System.out.println("Open project:" + newProj);
        
                        //Set the directoryName to pass in to slide show class
                        directoryName = "C:/windows/temp/"+ newProj;
                }
                else if("Save Project".equals(actCmd)){
                    try {
                        FileDialog fileDialog = new FileDialog(mainMenu, "Save as png", FileDialog.SAVE);    
                        fileDialog.setFile("Slide.png");
                        
                        fileName = newProj;
                        directoryName = "C:/windows/temp/"+ newProj;
                        fileDialog.setDirectory(directoryName);
                        fileName = fileDialog.getDirectory()+"/"+newProj+TC+".png";
                        Rectangle r = pSlide.getBounds();
                        Image image = pSlide.createImage(r.width, r.height);
                        Graphics g = image.getGraphics();
                        pSlide.paint(g);
                        ImageIO.write((RenderedImage)image, "png", new File(fileName));
                        System.out.println(fileName);
                        TC += 1;
                    }
                    catch (IOException ioe) {
                        ioe.printStackTrace();
                    }
                }
                else if("Save As".equals(actCmd)){
                    try {
                        FileDialog fileDialog = new FileDialog(mainMenu, "Save as png", FileDialog.SAVE);    
                        fileDialog.setFile("*.png");
                        fileDialog.show();
                        fileName = newProj;
                        String directoryName = "C:/windows/temp/" +newProj;
                        fileDialog.setDirectory(directoryName);
                        fileName = fileDialog.getDirectory()+"/"+newProj+".png";
                        Rectangle r = pSlide.getBounds();
                        Image image = pSlide.createImage(r.width, r.height);
                        Graphics g = image.getGraphics();
                        pSlide.paint(g);
                        ImageIO.write((RenderedImage)image, "png", new File(fileName));
                        System.out.println(fileName);
                    }
                    catch (IOException ioe) {
                        ioe.printStackTrace();
                    }
                }

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:33AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month