Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 11th, 2004, 4:40 PM   #1
mangudai_gb
Newbie
 
Join Date: Aug 2004
Posts: 3
Rep Power: 0 mangudai_gb is on a distinguished road
import java.applet.*;
import java.awt.*;

public class Ballbewegung1 extends Applet implements Runnable
{
// Initialisierung der Variablen
int x_pos = 10; // x - Position des Balles
int y_pos = 100; // y - Position des Balles
int radius = 20; // Radius des Balles

public void init()
{
setBackground (Color.blue);
}

public void start ()
{
// Schaffen eines neuen Threads, in dem das Spiel läuft
Thread th = new Thread (this);
// Starten des Threads
th.start ();
}

public void stop()
{

}

public void destroy()
{

}

public void run ()
{
// Erniedrigen der ThreadPriority um zeichnen zu erleichtern
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

// Solange true ist läuft der Thread weiter
while (true)
{
// Verändern der x- Koordinate
x_pos ++;

// Neuzeichnen des Applets
repaint();

try
{
// Stoppen des Threads für in Klammern angegebene Millisekunden
Thread.sleep (20);
}
catch (InterruptedException ex)
{
// do nothing
}

// Zurücksetzen der ThreadPriority auf Maximalwert
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
}
}


public void paint (Graphics g)
{
g.setColor (Color.red);

g.fillOval (x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
}

this give this message when i run it:Exception in thread "main" java.lang.NoSuchMethodError: main
mangudai_gb is offline   Reply With Quote
Old Aug 11th, 2004, 4:47 PM   #2
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,623
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
i recieve that error when i run the code in console but you have created an applet here not an application. so you will need to run the appletviewer to see the results. i personally havent tryed it but i think that is what the problem is. you could try adding the .class to an help webpage and then opening he html page in your browser and see if it shows it and see what happens. i could be wrong but give it a try and see what happens.

ok i was correct. cause i got it to work fine for me. here is what i did.
i created an html doc with the following code in it. and then opened it up
<html>
<head><title>java applet test</title></head>
<body>

<APPLET CODE="Ballbewegung1.class" WIDTH="100" HEIGHT="100">
</APPLET>

</body>
</html>

this will make your applet work perfectly good luck
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is online now   Reply With Quote
Old Aug 11th, 2004, 8:02 PM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Yup. Appletviewer should do the trick.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Aug 11th, 2004, 10:21 PM   #4
mangudai_gb
Newbie
 
Join Date: Aug 2004
Posts: 3
Rep Power: 0 mangudai_gb is on a distinguished road
Thanx boss.....u r great)
mangudai_gb is offline   Reply With Quote
Old Aug 11th, 2004, 10:45 PM   #5
mangudai_gb
Newbie
 
Join Date: Aug 2004
Posts: 3
Rep Power: 0 mangudai_gb is on a distinguished road
I have got another problem....

import java.net.*;
import java.io.*;

public class SourceViewer {
  public static void main (String args[]){
	if (args.length>0){
   try{
 URL u=new URL(args[0]);
 URLConnection uc = u.openConnection();
 InputStream in = uc.getInputStream();
 in = new BufferedInputStream(in);
 Reader r = new InputStreamReader(in);
 int c;
 while((c = r.read()) != -1){
   System.out.print((char) c);
 }
   }
   catch (MalformedURLException e) {
 System.err.println(args[0] + "is not a parseable URL");
   }
   catch (IOException e) {
 System.err.println(e);
   }
	}
  }

when i run this code in Fedora 1 i get a "UnKnownHost" error......can u help me in fixing it?????
mangudai_gb is offline   Reply With Quote
Old Aug 11th, 2004, 10:55 PM   #6
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I'm not positive, but try changing

URL u=new URL(args[0]);

with

URL u=new URL(args[1]);

I would think that args[0] would refer to the name of your program.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:58 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC