hvad sker der her????
package DiveLog;import java.awt.*;
import javax.swing.*;
/**
*
* @author
* @version
*/
public class CenterPanel extends JPanel implements ActionListener{
private JTextArea comments;
private JScrollPane scrollpane;
private JButton saveAs;
private JLabel whiteshark;
private Box box;
/** Creates new CenterPanel */
public CenterPanel() {
setBackground(Color.white);
comments = new JTextArea("Enter comments, such as " +
"location, water conditions, sea life you observed," +
" and problems you may have encountered.", 15, 10);
comments.setLineWrap(true);
comments.setWrapStyleWord(true);
comments.setEditable(true);
comments.setFont(new Font(
"Times-Roman", Font.PLAIN, 14));
scrollpane = new JScrollPane(comments);
scrollpane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
saveAs = new JButton("Save Comments");
saveAs.addActionListener( this );
whiteshark = new JLabel("",
new ImageIcon("images/gwhite.gif"),
JLabel.CENTER);
box = Box.createVerticalBox();
box.add(scrollpane);
box.add(Box.createVerticalStrut(10));
box.add(saveAs);
box.add(Box.createVerticalStrut(15));
box.add(whiteshark);
add(box);
}
public void actionPerformed( ActionEvent evt )
{ // open method
JFileChooser jfc = new JFileChooser();
jfc.setSize(400, 300);
Container parent = saveAs.getParent();
int choice = jfc.showSaveDialog(parent);
if (choice == JFileChooser.APPROVE_OPTION)
{
String filename =
jfc.getSelectedFile().getAbsolutePath();
try
{ // opens try
BufferedWriter bw =
new BufferedWriter(new FileWriter(filename));
bw.write(comments.getText());
bw.flush();
bw.close();
} // closes try
catch (IOException ioe)
{ // open catch
}// close catch
}//close if statement
} //close actionPerformed method
}
fejlrapport:
CenterPanel.java [15:1] cannot resolve symbol
symbol : class ActionListener
location: class DiveLog.CenterPanel
public class CenterPanel extends JPanel implements ActionListener{
^
CenterPanel.java [56:1] cannot resolve symbol
symbol : class ActionEvent
location: class DiveLog.CenterPanel
public void actionPerformed( ActionEvent evt )
^
CenterPanel.java [39:1] addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (DiveLog.CenterPanel)
saveAs.addActionListener( this );
^
CenterPanel.java [71:1] cannot resolve symbol
symbol : class BufferedWriter
location: class DiveLog.CenterPanel
BufferedWriter bw =
^
CenterPanel.java [72:1] cannot resolve symbol
symbol : class BufferedWriter
location: class DiveLog.CenterPanel
new BufferedWriter(new FileWriter(filename));
^
CenterPanel.java [72:1] cannot resolve symbol
symbol : class FileWriter
location: class DiveLog.CenterPanel
new BufferedWriter(new FileWriter(filename));
^
CenterPanel.java [77:1] cannot resolve symbol
symbol : class IOException
location: class DiveLog.CenterPanel
catch (IOException ioe)
^
7 errors
Errors compiling CenterPanel.
det en del af en applikation
