Hi, im trying to call this method in my class "MyWidget" which is suppose to draw a line when someone indicates the coordinates via 4 parameters. Here is the method:
public void Connect(int xline, int yline, int nextX, int nextY)
{
Graphics g = getGraphics();
g.drawLine(xline, yline, nextX, nextY);
}
When I call this method from another class, for example from my class JTree, and substitute in values a click run on the GUI button it just gives me an error message. Here is the code when I call it:
JButton drawLine = new JButton("Draw a line");
drawLine.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
MyWidget widget;
widget = new MyWidget();
widget.Connect(0, 0, 300, 300);
myFrame.add(widget);
myFrame.validate();
}
});
Whats the problem, anyone?