ImageIcon option Hi,
This is regarding the usage of ImageIcon. Earlier I had used Icon to add an ikon as a button.I have also come across adding image using ImageIcon as below:
ImageIcon obj=new createImageIcon("pict.jpg");
I have modified my earlier program as below:
import java.awt.event.*;
import javax.swing.*;
/*<applet code=jbt.class width=500 height=500>
</applet>*/
public class jbt extends JApplet implements ActionListener
{
Container c=getContentPane();
JLabel l=new JLabel("type");
JTextField t=new JTextField(10);
ImageIcon im1=createImageIcon("doggy1.gif");
JButton mb=new JButton("hi",im1);
public void init()
{
c.setLayout(new FlowLayout());
c.add(l);
c.add(t);
mb.setRolloverIcon(im1);
c.add(mb);
mb.addActionListener(this);
}
public void actionPerformed(ActionEvent a)
{
l.setText(t.getText());
}
} But Im getting teh following errors:
jbt.java:7: cannot find symbol
symbol : class Container
location: class jbt
Container c=getContentPane();
^
jbt.java:10: cannot find symbol
symbol : method createImageIcon(java.lang.String)
location: class jbt
ImageIcon im1=createImageIcon("doggy1.gif");
^
jbt.java:14: cannot find symbol
symbol : class FlowLayout
location: class jbt
c.setLayout(new FlowLayout()); |