Salam, when I run this code I have this error
MainFrame.java [132:1] cannot resolve symbol
symbol : method rubberBand (java.awt.Point)
location: class LineCanvas
lineCanvas.rubberBand(event.getPoint());
^
1 error
Errors compiling class mainframe.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
class MainFrame extends JFrame
{
// private Point point2= null;
// private Point point1= null;
JPanel contentPane;
JPanel linePanel = new JPanel();
LineCanvas lineCanvas = new LineCanvas();
JLabel instructionLabel = new JLabel();
BorderLayout borderLayout1 = new BorderLayout();
/**
* Construct the frame
*/
public MainFrame()
{
// Allows main frame to respond to window closing
// and resizing events
enableEvents(AWTEvent.WINDOW_EVENT_MASK |
AWTEvent.COMPONENT_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**
* Component initialization
*/
private void jbInit() throws Exception
{
contentPane = (JPanel) this.getContentPane();
this.getContentPane().setBackground(new Color(255, 200, 122));
this.setFont(new java.awt.Font("SansSerif", 1, 12));
this.setSize(new Dimension(600, 400));
this.setTitle("Bresenham's line algorithm");
contentPane.setLayout(borderLayout1);
linePanel.setBackground(Color.yellow);
instructionLabel.setFont(new java.awt.Font("SansSerif", 1, 12));
instructionLabel.setForeground(Color.blue);
instructionLabel.setHorizontalAlignment(SwingConstants.CENTER);
instructionLabel.setHorizontalTextPosition(SwingConstants.CENTER);
instructionLabel.
setText("Click and drag the mouse to draw a line using Bresenham\'s algorithm");
instructionLabel.setVerticalAlignment(SwingConstants.TOP);
contentPane.setBackground(Color.yellow);
// The LineCanvas class handles the drawing of the line
linePanel.add(lineCanvas);
contentPane.add(instructionLabel, BorderLayout.SOUTH);
lineCanvas.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(MouseEvent e) {
lineCanvas_mouseReleased(e);
}
public void mousePressed(MouseEvent e) {
lineCanvas_mousePressed(e);
}
});
lineCanvas.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
lineCanvas_mouseDragged(e);
}
});
contentPane.add(linePanel, BorderLayout.NORTH);
}
/**
* Overridden so we can exit when window is closed
*/
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
/**
* Resizes the panel and lineCanvas to fit a resized frame
*/
protected void processComponentEvent(ComponentEvent e)
{
super.processComponentEvent(e);
if (e.getID() == ComponentEvent.COMPONENT_RESIZED ||
e.getID() == ComponentEvent.COMPONENT_SHOWN) {
linePanel.setBounds(0, 0, getContentPane().getWidth(),
getContentPane().getHeight() - instructionLabel.getHeight());
lineCanvas.setBounds(0, 0, getContentPane().getWidth(),
getContentPane().getHeight() - instructionLabel.getHeight());
}
}
/**
* The mouse event handlers call LineCanvas methods to
* draw the line using Bresenham's algorithm
*/
void lineCanvas_mouseReleased(MouseEvent event)
{
lineCanvas.setPoint(LineCanvas.END_POINT, event.getPoint());
lineCanvas.repaint();
}
void lineCanvas_mousePressed(MouseEvent event)
{
//point1 = event.getPoint();
lineCanvas.setPoint(LineCanvas.START_POINT, event.getPoint());
}
void lineCanvas_mouseDragged(MouseEvent event)
{
// point2 = event.getPoint();
//repaint();
lineCanvas.rubberBand(event.getPoint());
}
public static void main(String[] args){
MainFrame x=new MainFrame();
x.setSize(400,400);
x.show();
}
}