Made a program using
Applet where a button is placed, upon clicking it a new Frame is opening. By paint function in Applet it draws image on default Applet window and not on Frame window. Now my question is how to draw image in new frame window. You can have a look at the program written below.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* < applet code=frame1.class width=500 height=400>
< param name="img" value="bharat.gif">
< /applet> */
public class frame1 extends Applet implements ActionListener,WindowListener
{
Frame f;
Button b;
Image img;
public void init()
{
b=new Button("join");
add(b);
img=getImage(getDocumentBase(),getParameter("img"));
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == b)
callframe();
}
public void callframe()
{
f=new Frame("New");
f.setBounds(100,100,400,500);
f.setResizable(false);
f.setVisible(true);
f.addWindowListener(this);
// paint1();
}
public void windowClosing(WindowEvent e){f.setVisible(false);}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void paint(Graphics g)
{
g.drawImage(img,20,100,this);
}
}
[I added some spaces inside the HTML tags so that they get printed rather than interpreted by the browser - Jim]
[This message has been edited by Jim Yingst (edited March 30, 2000).]