Sign in to follow this  

Java errors

Recommended Posts

I get this error: C:\Users\mark\Desktop>java gametry.class Exception in thread "main" java.lang.NoClassDefFoundError: gametry/class Caused by: java.lang.ClassNotFoundException: gametry.class at$ at Method) at at java.lang.ClassLoader.loadClass( at sun.misc.Launcher$AppClassLoader.loadClass( at java.lang.ClassLoader.loadClass( at java.lang.ClassLoader.loadClassInternal( Here's my source:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Gametry {
	private static void GUItry() {
		JFrame f = new JFrame("Game Window");
		JLabel emptyLabel = new JLabel("");
		emptyLabel.setPreferredSize(new Dimension(800,600));
		public static void main(String args[]) {
			javax.swing.SwingUtilities.invokeLater(new Runnable() {
				public void run() {
					public class ImageApplet extends JApplet {
		public void init() {
			Container content_pane = getContentPane();
			Image img = getImage (getCodeBase (), "Halo.jpeg");
			DrawingPanel drawing_panel = new DrawingPanel (img);
			content_pane.add (drawing_panel);

		class DrawingPanel extends JPanel {
		Image img;
		DrawingPanel (Image img)
		{this.img = img; }
		public void paintComponent (Graphics g) {
		super.paintComponent (g);
		int imgX = getSize ().width/2 - img.getWidth (this);
		int imgY = getSize ().height/2 - img.getHeight (this);
		g.drawImage (img, imgX, imgY, this);

Please help, i'm not sure what i've done wrone. :D

Share this post

Link to post
Share on other sites
You never added an Image to your JFrame. You only added a DrawingElement to your applet class, which never runs, since you launch the "Gametry" class and not the applet.

I am confused why you have an applet and a JFrame.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this