Quando compilo il mio applet il compilatore non mi dà errori ma quando poi carico l' applet con IE, Opera o Netscape non ottengo nulla o solo il messaggio: applet crashes
Cosa può essere successo?
Grazie.
Quando compilo il mio applet il compilatore non mi dà errori ma quando poi carico l' applet con IE, Opera o Netscape non ottengo nulla o solo il messaggio: applet crashes
Cosa può essere successo?
Grazie.
di tutto![]()
posta qualche altra informazione
Ok questo è l' applet:
import java.awt.*;
import java.applet.*;
public class Calcolatrice extends Applet {
private Button makeButton(String label,Color color) {//metodo ausiliario per creare i pulsanti
Button b = new Button(label); //data l'etichetta e il colore
b.setBackground(color);
b.setFont(new Font("Courier", Font.BOLD, 10));
return b;
}
private Panel makePanel(LayoutManager lm,Color c) {
Panel p = new Panel();
p.setLayout(lm);
p.setBackground(c);
return p;
}
private void makeButtons() {
Color lightRed = new Color(255,100,100);
Color lightBlue = new Color(100,100,255);
Color yellow = new Color(255,255,100);
c = makeButton("C",lightRed);
eq = makeButton("=",lightBlue);
div = makeButton("/",lightBlue);
per = makeButton("*",lightBlue);
meno = makeButton("-",lightBlue);
più = makeButton("+",lightBlue);
eq2 = makeButton("=",lightBlue);
b1 = makeButton("1",yellow);
b2 = makeButton("2",yellow);
b3 = makeButton("3",yellow);
b4 = makeButton("4",yellow);
b5 = makeButton("5",yellow);
b6 = makeButton("6",yellow);
b7 = makeButton("7",yellow);
b8 = makeButton("8",yellow);
b9 = makeButton("9",yellow);
bp = makeButton(".",yellow);
}
public void init() {
background = new Color(200,255,255);
this.setLayout(new FlowLayout(FlowLayout.CENTER,4,1));
result = new Label("0.00000 ",Label.RIGHT);
result.setBackground(new Color(255,255,255));
add(result);
makeButtons();
row1 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
row1.add(c);
row1.add(eq);
row1.add(div);
row1.add(per);
row2 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
row2.add(b7);
row2.add(b8);
row2.add(b9);
row2.add(meno);
row3 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
row3.add(b4);
row3.add(b5);
row3.add(b6);
row3.add(più);
add(row1);
add(row2);
add(row3);
p12 = makePanel(new BorderLayout(2,2),background);
p12.add("West",b1);
p12.add("East",b2);
p120 = makePanel(new BorderLayout(2,2),background);
p120.add("North",p12);
p120.add("South",b0);
p3p = makePanel(new BorderLayout(2,2),background);
p3p.add("Norht",b3);
p3p.add("South",bp);
p3peq = makePanel(new BorderLayout(2,2),background);
p3peq.add("West",p3p);
p3peq.add("East",eq2);
add(p120);
add(p3peq);
setBackground(background);
}
public void paint(Graphics g) {
setSize(row1.getSize().width,8*b1.getSize().height );
validate();
}
private Panel row1,row2,row3,p12,p120,p3p,p3peq;
private Button c,eq,div,per,meno,più,b1,b2,b3,b4,b5,b6,b7,b8,b9,b 0,bp,eq2;
private Color background;
private Label result;
}
e questa è la pagina in cui dovrebbe visualizzarsi:
<HTML>
<HEAD>
<TITLE> First page </TITLE>
</HEAD>
<BODY>
<HR>
<APPLET CODE="Calcolatrice.class" WIDTH=500
HEIGHT=500></APPLET>
<HR>
</BODY>
</HTML>
ciao
Hai provato a lanciarla con l'appletwiever per sapere se ci sono errori run-time?![]()
Windows Xp
[Java]
[PHP]Notepad++
[Fortran90-77]elf90 g77
[C++ /WinAPI] DevC++ VisualC++
Scusate la mia ignoranza ma cos' è l' applet viewer? dove lo trovo?
vai da prompt e scrivi appletviewer Calcolatrice
si usa per testare le applet
dunque ho provato ad utilizzare l'appletviewer e quello che ho ottenuto è:
Microsoft Windows XP [Versione 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
D:\Documents and Settings\Pina>cd java
D:\Documents and Settings\Pina\Java>appletviewer Calcolatrice
Avviso: Impossibile leggere il file di proprietÓ di AppletViewer: D:\Documents a
nd Settings\Pina\.hotjava\properties verranno utilizzati i valori di default.
Eccezione di I/O durante la lettura: D:\Documents and Settings\Pina\Java\Calcola
trice (Impossibile trovare il file specificato)
Riga 76:
p120.add("South",b0);
b0 non viene creato assieme agli altri pulsanti...
I don't wanna have to shout it out / I don't want my hair to fall out
I don't wanna be filled with doubt / I don't wanna be a good boy scout
I don't wanna have to learn to count / I don't wanna have the biggest amount
I don't wanna grow up
Linea 80: hai scritto "norht"
I don't wanna have to shout it out / I don't want my hair to fall out
I don't wanna be filled with doubt / I don't wanna be a good boy scout
I don't wanna have to learn to count / I don't wanna have the biggest amount
I don't wanna grow up
Correggi questi due e parte... ma tieniti pronto/a a chiudere il browser perchè non si comporta esattamente come dovrebbe...![]()
I don't wanna have to shout it out / I don't want my hair to fall out
I don't wanna be filled with doubt / I don't wanna be a good boy scout
I don't wanna have to learn to count / I don't wanna have the biggest amount
I don't wanna grow up