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();
}
}