Sign in to follow this  
d1th3r

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 java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) 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");
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JLabel emptyLabel = new JLabel("");
		emptyLabel.setPreferredSize(new Dimension(800,600));
		f.getContentPane().add(emptyLabel,BorderLayout.CENTER);
		f.pack();
		f.setVisible(true);
		}
		public static void main(String args[]) {
			javax.swing.SwingUtilities.invokeLater(new Runnable() {
				public void run() {
					GUItry();
					}
				});
			}
					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