Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Probleme mit Applets

Empfohlene Antworten

Veröffentlicht

hi

Ich habe folgendes Problem:

Ich habe einen Code von einem Tutorial kopiert und ihn mit Netbeans kompiliert.

Der Code ist folgender:

import java.applet.*;

import java.awt.*;


// The drawing area is 600 by 400.

// (X=0, Y=0) is the top left corner.

//

public class test extends Applet

{


  public void paint ( Graphics gr )

  {

    double inc = 1.0/32.0;


    for ( double x = 0.0; x <= 2*Math.PI; x = x + inc )

    {

      double y     = Math.sin( x );

      double nextx = x + inc;

      double nexty = Math.sin( nextx );


      int startX   = (int)(  x * 599/(2*Math.PI) );

      int startY   = (int)( -y * 399.0/2.0 + 399.0/2.0 );

      int endX     = (int)(  nextx * 599/(2*Math.PI) );

      int endY     = (int)( -nexty * 399.0/2.0 + 399.0/2.0 );


      gr.drawLine( startX, startY, endX, endY );

    }

  }

}
die test.Class Datei ist nun im gleichen Verzeichnis wie meine test1.html Datei. Die html Datei schaut so aus:

<html>

<head>

</head>

<body>

<applet code="test.class" width="600" height="400">

</applet>

</body>

</html>

Wenn ich jetzt die html Datei mit FireFox öffne bekomme ich aber nur das Symbol das ein Bild fehlt angezeigt...

Netbeans sagt mir nur "Multiple annotations here [2] - click to cyrcle" in der "public void paint" Zeile.

Ich habe jetzt schon mehrere Applets probiert manchmal klappt es manchmal nicht und das schlimme ist ich weiß nicht warum.

mfg hyperion

  • 3 Wochen später...

Problem besteht übrigens immernoch.

Also bei mir läuft's. Vielleicht solltest Du mal klicken und die 2 Meldungen von NetBeans näher betrachten?

hmm Add @Override Annotation kann ich bei der Fehlermeldung (wobei es eher ein Fehlerhinweis ist) anklicken, dann fügt netbeans "@Override" ein.

Dann funktioniert aber auch nichts. Dann ist eigentlich die einzigste Möglichkeit doch, dass der Compiler von netbeans fehlerhaft ist. Wobei das Problem nur bei Applets auftritt.

Echt gemein sowas:)

mfg hyperion

Dann ist eigentlich die einzigste Möglichkeit doch, dass der Compiler von netbeans fehlerhaft ist.

Das glaube ich nicht ...

Hast du mal den appletviewer aus dem JDK ausprobiert?

Gruß

hmm also ich hab jetzt mal die .class Datei mit appletviewer.exe geöffnet da passiert gar nichts.

mfg hyperion

EDIT: Ah wenn ich in NetBeans einfach rechtsklick auf test.java klicke und dann run file dann funktionierts.

Bearbeitet von hyperion

hmm also ich hab jetzt mal die .class Datei mit appletviewer.exe geöffnet da passiert gar nichts.

Nicht das Kompilat öffnen, die HTML Datei (appletviewer).

Gruß

Hallo,

hmm ich habe jetzt nochmal ein Beispiel genommen:

import java.applet.Applet;

import java.awt.*;


public class AEHousman extends Applet

{

  public void paint ( Graphics gr )

  { 

    setBackground( Color.pink );

    gr.drawString("Loveliest of trees, the cherry now", 25, 30);

    gr.drawString("Is hung with bloom along the bough,", 25, 50);

    gr.drawString("And stands about the woodland ride", 25, 70 );

    gr.drawString("Wearing white for Eastertide." ,25, 90);

    gr.drawString("--- A. E. Housman" ,50, 130);

   }

}

Das funktioniert dann auch wenn ich das kompiliere und mit meiner html Datei öffne. Allerdings wenn ich dann noch etwas ändere und neu kompiliere( ja sogar die alte .clas Datei lösche und komplett neu kompiliere) zeigt es mir immernoch die alte Version an. Cache habe ich bereits auch schon geleert.

mfg hyperion

Hallo,

schade funktioniert trotzdem nicht. Aber trotzdem Danke. Ich dachte schon, dass das die Lösung wäre.

mfg hyperion

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.