Skip to main content

I need your help please

3 replies [Last post]
alaam
Offline
Joined: 2006-12-02
Points: 0

I am working in my java project with is talking photo album
and i have the following code, which i download it from the net

/** This program has three buttons, 1st button (called Open Files) opens
file chooser dialog, and get the selected *.txt file; 2nd button (called
Show Next Images) shows the images in that choosed file ; the 3rd button
(called Show Previous Images) shows the previous image of file readed.

There are two ways to show image after you choosing *.txt file:(1) using
show image button,(2) puting your mouse on any place of the frame, left
click the mouse. Both ways show the image path, name on the bottom bar.

The text file can be the following format:

http://www.utdallas.edu/dept/cs/images/csimage.jpg
http://www.utdallas.edu/dept/cs/images/10.jpg
http://www.utdallas.edu/dept/cs/images/18.jpg
http://www.utdallas.edu/dept/cs/images/19.jpg
or
C:/demo/campusfall/Image01.jpg
C:/demo/campusfall/Image02.jpg
C:/demo/campusfall/Image03.jpg
C:/demo/campusfall/Image04.jpg etc.
*/
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.print.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
//import javax.media.jai.*;
import java.net.URL;
//import com.sun.media.jai.codec.*;

public class MenuTest extends JFrame implements ActionListener,Printable {
private JLabel statusBar;
private JMenuItem aboutItem, openItem, saveItem, printItem, exitItem;
private JMenuItem nextItem, preItem;
private ImageIcon open, save, next, back;
private JButton openButton, saveButton, nextButton, backButton;
private JButton aboutButton, printButton, exitButton;
final int WIDTH = 780, HEIGHT = 580;

File file, saveFile;
DisplayJAI dsp;
PlanarImage img;
int i = 0; int j = 1;
Vector preImage = new Vector();

public MenuTest() {
super ("Choose File and Show Images");
setSize( WIDTH, HEIGHT );

Container c = getContentPane();

// set up menu bar
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);

//create File menu and menu items
JMenu fileMenu = new JMenu ("File");
menuBar.add(fileMenu);

openItem =
new JMenuItem (" Open ...", new ImageIcon ("open.gif"));
fileMenu.add( openItem );
openItem.setMnemonic( 'O' );
openItem.addActionListener(this);

saveItem =
new JMenuItem (" Save ...", new ImageIcon ("save_over.gif"));
fileMenu.add( saveItem );
saveItem.setMnemonic( 'S' );
saveItem.setEnabled(false);
saveItem.addActionListener(this);
fileMenu.addSeparator();

printItem =
new JMenuItem (" Print ...", new ImageIcon ("printer.gif"));
fileMenu.add( printItem );
printItem.setMnemonic( 'P' );
printItem.setEnabled(false);
printItem.addActionListener(this);

aboutItem =
new JMenuItem (" About ...", new ImageIcon ("question.gif"));
fileMenu.add( aboutItem );
aboutItem.setMnemonic( 'A' );
aboutItem.addActionListener( this);
fileMenu.addSeparator();

exitItem =
new JMenuItem( " Exit ...", new ImageIcon ("exit.gif") );
fileMenu.add( exitItem );
exitItem.setMnemonic( 'X' );
exitItem.addActionListener( this);

//create Show menu and menu items
JMenu showMenu = new JMenu ("Show");
menuBar.add(showMenu);

nextItem = new JMenuItem (" Next ...", new ImageIcon ("next.gif"));
nextItem.setEnabled(false);
showMenu.add( nextItem );
nextItem.addActionListener(this);
showMenu.add(new JSeparator());

preItem = new JMenuItem (" Back ...", new ImageIcon ("back.gif"));
preItem.setEnabled(false);
showMenu.add( preItem );
preItem.addActionListener(this);

openButton = new JButton ("Open", new ImageIcon ("open.gif"));
saveButton = new JButton ("Save", new ImageIcon ("save_over.gif"));
nextButton = new JButton ("Next", new ImageIcon ("next.gif"));
backButton = new JButton ("Back", new ImageIcon ("back.gif"));
printButton = new JButton ("Print", new ImageIcon ("printer.gif"));
aboutButton = new JButton ("About", new ImageIcon ("question.gif"));
exitButton = new JButton ("Exit", new ImageIcon ("exit.gif"));

openButton.setToolTipText("Open");
saveButton.setToolTipText("Save");
nextButton.setToolTipText("Next");
backButton.setToolTipText("Back");
printButton.setToolTipText("Print");
aboutButton.setToolTipText("About");
exitButton.setToolTipText("Exit");

JToolBar jtb = new JToolBar();
jtb.add(openButton);
jtb.add(saveButton); saveButton.setEnabled(false);
jtb.add(nextButton); nextButton.setEnabled(false);
jtb.add(backButton); backButton.setEnabled(false);
jtb.add(printButton); printButton.setEnabled(false);
jtb.add(aboutButton);
jtb.addSeparator();
jtb.add(exitButton);
c.add(jtb, BorderLayout.NORTH);

JPanel showPanel = new JPanel();
// dsp = new DisplayJAI();
//showPanel.add(dsp);
JScrollPane scrollP = new JScrollPane();
scrollP.add(showPanel);
scrollP.setViewportView(showPanel);
scrollP.setPreferredSize(new Dimension());
c.add(scrollP, BorderLayout.CENTER);

statusBar = new JLabel();
JPanel labelPanel = new JPanel ();
statusBar.setHorizontalAlignment(statusBar.CENTER);
labelPanel.add(statusBar);
labelPanel.setBackground(new Color(255,255,204));
c.add( labelPanel, BorderLayout.SOUTH );

scrollP.addMouseListener( new MouseClickHandler() );
openButton.addActionListener (this);
saveButton.addActionListener (this);
nextButton.addActionListener (this);
backButton.addActionListener (this);
printButton.addActionListener(this);
aboutButton.addActionListener(this);
exitButton.addActionListener (this);
show();
} // end of constructor

public static void main( String args[] ) {
MenuTest app = new MenuTest();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e ){
System.exit( 0 ); } } );
} // end of main method

public void actionPerformed(ActionEvent e) {

//* open item and open button *
if( e.getSource() == openItem || e.getSource() == openButton) {
// Set the path as the same as that of Java file
JFileChooser chooser = new JFileChooser ();
chooser.setCurrentDirectory(new File("."));
final TxtFileFilter filter = new TxtFileFilter ();
filter.addExtension ("txt");
filter.setDescription (".txt files");
chooser.setFileFilter(filter);
// show open dialog, and get selected file *.txt
if (chooser.showOpenDialog(this) == JFileChooser.CANCEL_OPTION ) {
return; }
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
preImage = fileToVector(file); // call fileToVector method
}
nextItem.setEnabled(true);
nextButton.setEnabled(true);
} // end of open action

//* save item and save button *
if( e.getSource() == saveItem || e.getSource() == saveButton ) {
JFileChooser jfc = new JFileChooser ();
jfc.setCurrentDirectory(new File("."));
if (jfc.showSaveDialog(this) == JFileChooser.CANCEL_OPTION ) {
return; }
if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
saveFile = jfc.getSelectedFile(); writeFile (saveFile); }
} // end of save action

//* show next image item and button *
if( e.getSource() == nextItem || e.getSource() == nextButton) {
String line = (String) preImage.get(j-1) ;
img = fileToImage (line); //call fileToImage method
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
j++;
saveItem.setEnabled(true);
saveButton.setEnabled(true);
preItem.setEnabled(true);
backButton.setEnabled(true);
printItem.setEnabled(true);
printButton.setEnabled(true);
} // end of next action

// * show previous image item and back button *
if( e.getSource() == preItem || e.getSource() == backButton ) {
j--;
String line = (String) preImage.get(j-1) ;
img = fileToImage (line);
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
} // end of back action

// * about item and button *
if( e.getSource() == aboutItem || e.getSource() == aboutButton ) {
JOptionPane.showMessageDialog(MenuTest.this,
"This program refers to show images. There are three ways to show images: \n(1) using show menu at the menu bar: \nThere are two menu items: show next image and show the previous image.\n(2) using buttons at the tool bar: \nThe next button show next image and the back button show the previous image. \n(3) using left and right mouse click: \nThe left mouse click show next image and right mouse click show the previous image. ",
"About", JOptionPane.INFORMATION_MESSAGE, new ImageIcon ("question.gif") );
} // end of about action

// * print item and button *
if( e.getSource() == printItem || e.getSource() == printButton ) {
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(MenuTest.this);
if (pj.printDialog()) {
try { pj.print(); }
catch (PrinterException pe)
{ System.out.println(pe); }
}
} // end of print action

// * exit item and button *
if( e.getSource() == exitItem || e.getSource() == exitButton ) {
System.exit( 0 );
}
} // end of method actionPerformance

// from file convet into vector
private static Vector fileToVector (File file) {
Vector v = new Vector();
int i=0;
try {
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader (fr);
boolean done = false ;
while ( !done ) {
String line = br.readLine ();
if (line != null ) {
v.add (line);
i ++; }
else { done = true; }
}
} catch(IOException event) {
System.err.println("can't open file" + event);
System.exit(0);
}
return v;
}

// file to image from disk method
private static PlanarImage fileToImage_fromDisk (String fileLine)
throws Exception {

PlanarImage img = null;
FileSeekableStream stream = null;

if(fileLine != null) {
stream = new FileSeekableStream(fileLine);
img = JAI.create("stream", stream);
} else { // line is null
System.err.println("file is over " + fileLine);
System.exit(1);
}
return img ;
}

// file to image from Internet method
private static PlanarImage fileToImage_fromInternet (String fileLine)
throws Exception {

PlanarImage img = null;
MemoryCacheSeekableStream s= null;

if(fileLine != null) {
URL url = new URL( fileLine );
s = new MemoryCacheSeekableStream(url.openStream());
img = JAI.create("stream", s);

} else { // line is null
System.err.println("file is over " + fileLine);
System.exit(1);
}
return img ;
}

// file to image from both disk and Internet method
private static PlanarImage fileToImage (String fileLine) {

PlanarImage img = null;
try {
img = fileToImage_fromDisk (fileLine);
} catch ( Exception e) {
try {
img = fileToImage_fromInternet (fileLine);
} catch (Exception ee) {
System.out.println ("can not find the file" + ee );
System.exit(1);
}
}
return img;
}

// write file method
public void writeFile (File file) {
try {
FileWriter fw = new FileWriter(saveFile);
BufferedWriter bw = new BufferedWriter (fw);
} catch(IOException event) {
System.err.println("can't writer file");
System.exit(0);
}
}

// print frame method
public int print(Graphics g, PageFormat pf, int pageIndex) {
if (pageIndex != 0) return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
// Rectangle2D outline = new Rectangle2D.Double (
// pf.getImageableX(), pf.getImageableY(),
// pf.getImageableWidth(), pf.getImageableHeight());
// g2.draw.(outline);
g2.translate(pf.getImageableX(), pf.getImageableY());
getContentPane().paint(g2);
return PAGE_EXISTS;
} // end of print method

// inner class to handle mouse events
private class MouseClickHandler extends MouseAdapter {
public void mouseClicked( MouseEvent e ) {
// * right mouse button *
if ( e.isMetaDown() ) {
j--;
String line = (String) preImage.get(j-1) ;
img = fileToImage (line);
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
} // end of right mouse button action
// * Left mouse button *
else {
String line = (String) preImage.get(j-1) ;
img = fileToImage (line);
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
j++;
saveItem.setEnabled(true);
saveButton.setEnabled(true);
preItem.setEnabled(true);
backButton.setEnabled(true);
printItem.setEnabled(true);
printButton.setEnabled(true);
} // end of if-else
} // end of method mouseClicked
} // end of class MouseClickHandler
} // end of class MenuTest

but I have the following errors:
cannot find symbol class DisplayJAI
cannot find symbol class PlanarImage
cannot find symbol class TxtFileFilter
cannot find symbol class FileSeekableStream
cannot find symbol class MemoryCacheSeekableStream
cannot find symbol class JAI

what is the problem???
how I can solve it?
please replay as soon as possible.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Paul Kling

Here is a direct link to the page

http://java.sun.com/products/java-media/jai/downloads/download-1_1_2_01.
html

Also you may be interested in:

http://java.sun.com/products/java-media/jai/downloads/download-iio-1_0_0
1.html

Like I said early you want to make sure when you install the JDK version
you install it in the version that your IDE is using otherwise you will
have the same problem.

-----Original Message-----
From: jai-imageio@javadesktop.org [mailto:jai-imageio@javadesktop.org]
Sent: Sunday, December 03, 2006 7:46 AM
To: interest@jai-imageio.dev.java.net
Subject: Re: RE: [JAI-IMAGEIO] I need your help please

Thank you for your replay
But in fact that i didn't download the JAI in my computer.
my question?
Is the JAI a library?
How I can download it?
I am using netbeans,JCreater, and eclips, which one do you advice me to
work in with my project (Talking Photo Album) and how I can see if the
JAI is matching with the JDK that I have?
Regards
[Message sent by forum member 'alaam' (alaam)]

http://forums.java.net/jive/thread.jspa?messageID=181758

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Paul Kling

Java is having trouble locating you JAI libs and what not. If you installed JAI you should verify that where it is installed and you are using the same JDK version. Also you should verify that the JAI version you installed is for JDK and not the JRE. You really can only install one version; therefore you probably want the JDK version.

Hopefully this helps. Also it would be nice to know if that is a compile time error or a runtime error.

-----Original Message-----
From: jai-imageio@javadesktop.org [mailto:jai-imageio@javadesktop.org]
Sent: Sat 12/2/2006 6:47 AM
To: interest@jai-imageio.dev.java.net
Subject: [JAI-IMAGEIO] I need your help please

I am working in my java project with is talking photo album
and i have the following code, which i download it from the net

/** This program has three buttons, 1st button (called Open Files) opens
file chooser dialog, and get the selected *.txt file; 2nd button (called
Show Next Images) shows the images in that choosed file ; the 3rd button
(called Show Previous Images) shows the previous image of file readed.

There are two ways to show image after you choosing *.txt file:(1) using
show image button,(2) puting your mouse on any place of the frame, left
click the mouse. Both ways show the image path, name on the bottom bar.

The text file can be the following format:

http://www.utdallas.edu/dept/cs/images/csimage.jpg
http://www.utdallas.edu/dept/cs/images/10.jpg
http://www.utdallas.edu/dept/cs/images/18.jpg
http://www.utdallas.edu/dept/cs/images/19.jpg
or
C:/demo/campusfall/Image01.jpg
C:/demo/campusfall/Image02.jpg
C:/demo/campusfall/Image03.jpg
C:/demo/campusfall/Image04.jpg etc.
*/
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.print.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
//import javax.media.jai.*;
import java.net.URL;
//import com.sun.media.jai.codec.*;

public class MenuTest extends JFrame implements ActionListener,Printable {
private JLabel statusBar;
private JMenuItem aboutItem, openItem, saveItem, printItem, exitItem;
private JMenuItem nextItem, preItem;
private ImageIcon open, save, next, back;
private JButton openButton, saveButton, nextButton, backButton;
private JButton aboutButton, printButton, exitButton;
final int WIDTH = 780, HEIGHT = 580;

File file, saveFile;
DisplayJAI dsp;
PlanarImage img;
int i = 0; int j = 1;
Vector preImage = new Vector();

public MenuTest() {
super ("Choose File and Show Images");
setSize( WIDTH, HEIGHT );

Container c = getContentPane();

// set up menu bar
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);

//create File menu and menu items
JMenu fileMenu = new JMenu ("File");
menuBar.add(fileMenu);

openItem =
new JMenuItem (" Open ...", new ImageIcon ("open.gif"));
fileMenu.add( openItem );
openItem.setMnemonic( 'O' );
openItem.addActionListener(this);

saveItem =
new JMenuItem (" Save ...", new ImageIcon ("save_over.gif"));
fileMenu.add( saveItem );
saveItem.setMnemonic( 'S' );
saveItem.setEnabled(false);
saveItem.addActionListener(this);
fileMenu.addSeparator();

printItem =
new JMenuItem (" Print ...", new ImageIcon ("printer.gif"));
fileMenu.add( printItem );
printItem.setMnemonic( 'P' );
printItem.setEnabled(false);
printItem.addActionListener(this);

aboutItem =
new JMenuItem (" About ...", new ImageIcon ("question.gif"));
fileMenu.add( aboutItem );
aboutItem.setMnemonic( 'A' );
aboutItem.addActionListener( this);
fileMenu.addSeparator();

exitItem =
new JMenuItem( " Exit ...", new ImageIcon ("exit.gif") );
fileMenu.add( exitItem );
exitItem.setMnemonic( 'X' );
exitItem.addActionListener( this);

//create Show menu and menu items
JMenu showMenu = new JMenu ("Show");
menuBar.add(showMenu);

nextItem = new JMenuItem (" Next ...", new ImageIcon ("next.gif"));
nextItem.setEnabled(false);
showMenu.add( nextItem );
nextItem.addActionListener(this);
showMenu.add(new JSeparator());

preItem = new JMenuItem (" Back ...", new ImageIcon ("back.gif"));
preItem.setEnabled(false);
showMenu.add( preItem );
preItem.addActionListener(this);

openButton = new JButton ("Open", new ImageIcon ("open.gif"));
saveButton = new JButton ("Save", new ImageIcon ("save_over.gif"));
nextButton = new JButton ("Next", new ImageIcon ("next.gif"));
backButton = new JButton ("Back", new ImageIcon ("back.gif"));
printButton = new JButton ("Print", new ImageIcon ("printer.gif"));
aboutButton = new JButton ("About", new ImageIcon ("question.gif"));
exitButton = new JButton ("Exit", new ImageIcon ("exit.gif"));

openButton.setToolTipText("Open");
saveButton.setToolTipText("Save");
nextButton.setToolTipText("Next");
backButton.setToolTipText("Back");
printButton.setToolTipText("Print");
aboutButton.setToolTipText("About");
exitButton.setToolTipText("Exit");

JToolBar jtb = new JToolBar();
jtb.add(openButton);
jtb.add(saveButton); saveButton.setEnabled(false);
jtb.add(nextButton); nextButton.setEnabled(false);
jtb.add(backButton); backButton.setEnabled(false);
jtb.add(printButton); printButton.setEnabled(false);
jtb.add(aboutButton);
jtb.addSeparator();
jtb.add(exitButton);
c.add(jtb, BorderLayout.NORTH);

JPanel showPanel = new JPanel();
// dsp = new DisplayJAI();
//showPanel.add(dsp);
JScrollPane scrollP = new JScrollPane();
scrollP.add(showPanel);
scrollP.setViewportView(showPanel);
scrollP.setPreferredSize(new Dimension());
c.add(scrollP, BorderLayout.CENTER);

statusBar = new JLabel();
JPanel labelPanel = new JPanel ();
statusBar.setHorizontalAlignment(statusBar.CENTER);
labelPanel.add(statusBar);
labelPanel.setBackground(new Color(255,255,204));
c.add( labelPanel, BorderLayout.SOUTH );

scrollP.addMouseListener( new MouseClickHandler() );
openButton.addActionListener (this);
saveButton.addActionListener (this);
nextButton.addActionListener (this);
backButton.addActionListener (this);
printButton.addActionListener(this);
aboutButton.addActionListener(this);
exitButton.addActionListener (this);
show();
} // end of constructor

public static void main( String args[] ) {
MenuTest app = new MenuTest();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e ){
System.exit( 0 ); } } );
} // end of main method

public void actionPerformed(ActionEvent e) {

//* open item and open button *
if( e.getSource() == openItem || e.getSource() == openButton) {
// Set the path as the same as that of Java file
JFileChooser chooser = new JFileChooser ();
chooser.setCurrentDirectory(new File("."));
final TxtFileFilter filter = new TxtFileFilter ();
filter.addExtension ("txt");
filter.setDescription (".txt files");
chooser.setFileFilter(filter);
// show open dialog, and get selected file *.txt
if (chooser.showOpenDialog(this) == JFileChooser.CANCEL_OPTION ) {
return; }
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
preImage = fileToVector(file); // call fileToVector method
}
nextItem.setEnabled(true);
nextButton.setEnabled(true);
} // end of open action

//* save item and save button *
if( e.getSource() == saveItem || e.getSource() == saveButton ) {
JFileChooser jfc = new JFileChooser ();
jfc.setCurrentDirectory(new File("."));
if (jfc.showSaveDialog(this) == JFileChooser.CANCEL_OPTION ) {
return; }
if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
saveFile = jfc.getSelectedFile(); writeFile (saveFile); }
} // end of save action

//* show next image item and button *
if( e.getSource() == nextItem || e.getSource() == nextButton) {
String line = (String) preImage.get(j-1) ;
img = fileToImage (line); //call fileToImage method
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
j++;
saveItem.setEnabled(true);
saveButton.setEnabled(true);
preItem.setEnabled(true);
backButton.setEnabled(true);
printItem.setEnabled(true);
printButton.setEnabled(true);
} // end of next action

// * show previous image item and back button *
if( e.getSource() == preItem || e.getSource() == backButton ) {
j--;
String line = (String) preImage.get(j-1) ;
img = fileToImage (line);
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
} // end of back action

// * about item and button *
if( e.getSource() == aboutItem || e.getSource() == aboutButton ) {
JOptionPane.showMessageDialog(MenuTest.this,
"This program refers to show images. There are three ways to show images: \n(1) using show menu at the menu bar: \nThere are two menu items: show next image and show the previous image.\n(2) using buttons at the tool bar: \nThe next button show next image and the back button show the previous image. \n(3) using left and right mouse click: \nThe left mouse click show next image and right mouse click show the previous image. ",
"About", JOptionPane.INFORMATION_MESSAGE, new ImageIcon ("question.gif") );
} // end of about action

// * print item and button *
if( e.getSource() == printItem || e.getSource() == printButton ) {
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(MenuTest.this);
if (pj.printDialog()) {
try { pj.print(); }
catch (PrinterException pe)
{ System.out.println(pe); }
}
} // end of print action

// * exit item and button *
if( e.getSource() == exitItem || e.getSource() == exitButton ) {
System.exit( 0 );
}
} // end of method actionPerformance

// from file convet into vector
private static Vector fileToVector (File file) {
Vector v = new Vector();
int i=0;
try {
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader (fr);
boolean done = false ;
while ( !done ) {
String line = br.readLine ();
if (line != null ) {
v.add (line);
i ++; }
else { done = true; }
}
} catch(IOException event) {
System.err.println("can't open file" + event);
System.exit(0);
}
return v;
}

// file to image from disk method
private static PlanarImage fileToImage_fromDisk (String fileLine)
throws Exception {

PlanarImage img = null;
FileSeekableStream stream = null;

if(fileLine != null) {
stream = new FileSeekableStream(fileLine);
img = JAI.create("stream", stream);
} else { // line is null
System.err.println("file is over " + fileLine);
System.exit(1);
}
return img ;
}

// file to image from Internet method
private static PlanarImage fileToImage_fromInternet (String fileLine)
throws Exception {

PlanarImage img = null;
MemoryCacheSeekableStream s= null;

if(fileLine != null) {
URL url = new URL( fileLine );
s = new MemoryCacheSeekableStream(url.openStream());
img = JAI.create("stream", s);

} else { // line is null
System.err.println("file is over " + fileLine);
System.exit(1);
}
return img ;
}

// file to image from both disk and Internet method
private static PlanarImage fileToImage (String fileLine) {

PlanarImage img = null;
try {
img = fileToImage_fromDisk (fileLine);
} catch ( Exception e) {
try {
img = fileToImage_fromInternet (fileLine);
} catch (Exception ee) {
System.out.println ("can not find the file" + ee );
System.exit(1);
}
}
return img;
}

// write file method
public void writeFile (File file) {
try {
FileWriter fw = new FileWriter(saveFile);
BufferedWriter bw = new BufferedWriter (fw);
} catch(IOException event) {
System.err.println("can't writer file");
System.exit(0);
}
}

// print frame method
public int print(Graphics g, PageFormat pf, int pageIndex) {
if (pageIndex != 0) return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
// Rectangle2D outline = new Rectangle2D.Double (
// pf.getImageableX(), pf.getImageableY(),
// pf.getImageableWidth(), pf.getImageableHeight());
// g2.draw.(outline);
g2.translate(pf.getImageableX(), pf.getImageableY());
getContentPane().paint(g2);
return PAGE_EXISTS;
} // end of print method

// inner class to handle mouse events
private class MouseClickHandler extends MouseAdapter {
public void mouseClicked( MouseEvent e ) {
// * right mouse button *
if ( e.isMetaDown() ) {
j--;
String line = (String) preImage.get(j-1) ;
img = fileToImage (line);
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
} // end of right mouse button action
// * Left mouse button *
else {
String line = (String) preImage.get(j-1) ;
img = fileToImage (line);
dsp.set(img);
statusBar.setText( "This image located at: " + line
+ " This is: " + j + " clicks");
j++;
saveItem.setEnabled(true);
saveButton.setEnabled(true);
preItem.setEnabled(true);
backButton.setEnabled(true);
printItem.setEnabled(true);
printButton.setEnabled(true);
} // end of if-else
} // end of method mouseClicked
} // end of class MouseClickHandler
} // end of class MenuTest

but I have the following errors:
cannot find symbol class DisplayJAI
cannot find symbol class PlanarImage
cannot find symbol class TxtFileFilter
cannot find symbol class FileSeekableStream
cannot find symbol class MemoryCacheSeekableStream
cannot find symbol class JAI

what is the problem???
how I can solve it?
please replay as soon as possible.
[Message sent by forum member 'alaam' (alaam)]

http://forums.java.net/jive/thread.jspa?messageID=181633

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
[att1.html]

alaam
Offline
Joined: 2006-12-02
Points: 0

Thank you for your replay
But in fact that i didn't download the JAI in my computer.
my question?
Is the JAI a library?
How I can download it?
I am using netbeans,JCreater, and eclips, which one do you advice me to work in with my project (Talking Photo Album) and how I can see if the JAI is matching with the JDK that I have?
Regards