• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Want to Load an Image

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to load an image into Image type variable for the past 2 days a get to here.

import java.awt.*;
import java.net.URL;
import java.applet.Applet;

public class Board{
//Internal Col
URL url = new URL("c:/Image/board.gif");
Image pict;
//Class Contructor
public Board(){
pict = getImage(url);
}
//an a few methods in here.
}

the error that i'm getting is:
The Method getImage(URL) is undefined for the type Board

Probably I'm missing something in the beginning, like importing something
if anyone knows which package a should import please tell me.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The getImage() method does not exist in the class Board. That's why you are getting that exception. Since you've imported the Applet class I'll assume that's what you are trying to make. getImage() is a method of the Applet class so have Board extend Applet and try again.

Moving this to the applets forum...
 
Juan Ignacio
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now is the part in Bold the one not working, when I add the "extends Applet"
to my class, I lost the import java.net.URL, why is that, there is a way to solve this?

package classes;

import java.awt.*;
import java.net.URL;
import java.applet.Applet;

public class Persona extends Applet {
//Colaboradores Internos
URL url = new URL("c:/Imagen/placa.gif");
Image foto;
String nombre;
String apellido;
String sector;
String cargo;
String horaEntrada;
String horaSalida;
char estado;
Time fyHActual = new Time();
//Contructor
public Persona (){

nombre = "Juan";
apellido = "Tibaldi";
sector = "Sistemas";
cargo = "Soporte Tecnico de Distrito Sur";
horaEntrada = fyHActual.now();
horaSalida = fyHActual.now();
estado = 'V';
foto = getImage(url);


}
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Juan Ignacio:
Now is the part in Bold the one not working, when I add the "extends Applet"
to my class, I lost the import java.net.URL, why is that, there is a way to solve this?



Yea, retype it?
 
Juan Ignacio
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's do it simple anyone knows how to load an image in java.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic