Gå til innhold

ImageDisplay cannot be resolved to a type


Anbefalte innlegg

/*
* @(#)HelloWorld.java	1.10 99/06/19 00:18:53
*
* Copyright © 1999 Sun Microsystems, Inc. All Rights Reserved.
*
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
*/

/*
*  A Hello World Program
*/

import java.io.File;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import java.net.URL;
import java.net.MalformedURLException;


public class HelloWorld extends JPanel {

   private PlanarImage source = null;

   public HelloWorld(String filename) {

  try
  {
       	source = JAI.create("url", new URL (filename) );
       }
  catch (MalformedURLException e)
  {
	return;
  }

       ImageDisplay canvas = new ImageDisplay(source);

       Font font = new Font("SansSerif", Font.BOLD, 24);
       JLabel title = new JLabel(" Hello World");
       title.setFont(font);
       title.setLocation(0, 32);

       setOpaque(true);
       setLayout(new BorderLayout());
       setBackground(Color.white);

       add(title,  BorderLayout.NORTH);
       add(canvas, BorderLayout.CENTER);
       canvas.setLocation(0, 42);
   }
}

 

Som titel sier får jeg "ImageDisplay cannot be resolved to a type" jeg bruker eclipse som editor. Jeg ville jo tro at koden burde være i orden siden den er rett fra sun sin hjemme side. Men noen som har noen idee om hva som kan være galt?

 

java -version

java version "1.6.0_16"

Java SE Runtime Environment (build 1.6.0_16-b01)

Java HotSpot Server VM (build 14.2-b01, mixed mode)

Endret av Kargan
Lenke til kommentar
Videoannonse
Annonse

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...