There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
blue screen boot computer connection cpu crash css dell display driver drivers email error ethernet excel firefox firefox 3 game hard drive hardware internet internet explorer itunes laptop malware monitor network networking nvidia outlook outlook 2003 outlook express partition printer problem problems router security slow software sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
ImageIcon option


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Caliraj's Avatar
Senior Member with 145 posts.
 
Join Date: Mar 2006
Experience: Intermediate
07-Mar-2007, 05:28 AM #1
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());
Chicon's Avatar
Computer Specs
Distinguished Member with 6,681 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
07-Mar-2007, 06:51 AM #2
For errors 1 and 3, just add the following imports :

import java.awt.Container;
import java.awt.FlowLayout;


For error 2, just replace the line :

ImageIcon im1=createImageIcon("doggy1.gif");

by :

ImageIcon im1= new ImageIcon("doggy1.gif");
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:00 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.