Uma
October 2nd, 1999, 01:44 PM
Hi,
Is it possible to overlap an Image with methods like g.drawLine()?
I have subclassed an ImagePanel class (provided by Symantec) and implemented it's paint method to draw a line that has to overlap on top of an image.
Any suggestions in general, for overlapping an image, not necessarily using the ImagePanel,
will be great!
Thanks,
Uma.
The code for the Applet class is as follows:
import java.awt.*;
import java.applet.*;
import symantec.itools.awt.ImagePanel;
import java.net.*;
public class TestImage extends Applet
{
myImagePanel mp = new myImagePanel();
ImagePanel ip = new ImagePanel();
public void init()
{
setLayout(null);
setSize(426,266);
//Add an ImagePanel that has paint method implemented
mp.setLayout(null);
mp.setBounds(0,0,426,266);
//Add an Image
try {
ip.setImageURL( new java.net.URL(this.getDocumentBase(),"Test.jpg") );
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
try {
ip.setStyle(myImagePanel.IMAGE_CENTERED);
}
catch(java.beans.PropertyVetoException e) { }
ip.setLayout(null);
ip.setBounds(40,40,100,100);
mp.add(ip);
add(mp);
}
}
And the code for the myImagePanel Class is:
import java.awt.*;
import symantec.itools.awt.ImagePanel;
public class myImagePanel extends ImagePanel
{
public void paint(Graphics g)
{
g.setColor(Color.blue);
g.drawLine(50, 40, 30, 20);
}
}
Is it possible to overlap an Image with methods like g.drawLine()?
I have subclassed an ImagePanel class (provided by Symantec) and implemented it's paint method to draw a line that has to overlap on top of an image.
Any suggestions in general, for overlapping an image, not necessarily using the ImagePanel,
will be great!
Thanks,
Uma.
The code for the Applet class is as follows:
import java.awt.*;
import java.applet.*;
import symantec.itools.awt.ImagePanel;
import java.net.*;
public class TestImage extends Applet
{
myImagePanel mp = new myImagePanel();
ImagePanel ip = new ImagePanel();
public void init()
{
setLayout(null);
setSize(426,266);
//Add an ImagePanel that has paint method implemented
mp.setLayout(null);
mp.setBounds(0,0,426,266);
//Add an Image
try {
ip.setImageURL( new java.net.URL(this.getDocumentBase(),"Test.jpg") );
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
try {
ip.setStyle(myImagePanel.IMAGE_CENTERED);
}
catch(java.beans.PropertyVetoException e) { }
ip.setLayout(null);
ip.setBounds(40,40,100,100);
mp.add(ip);
add(mp);
}
}
And the code for the myImagePanel Class is:
import java.awt.*;
import symantec.itools.awt.ImagePanel;
public class myImagePanel extends ImagePanel
{
public void paint(Graphics g)
{
g.setColor(Color.blue);
g.drawLine(50, 40, 30, 20);
}
}