debugger an eternal mystery (reload)
From: Québec (notAgain_at_enough.ca)
Date: 04/02/04
- Next message: Bryce (Work): "Re: convert date and time, please help."
- Previous message: John Harlow: "Re: Evaluate basic arithmatic in a string"
- Next in thread: Québec: "Re: debugger an eternal mystery (reload)"
- Reply: Québec: "Re: debugger an eternal mystery (reload)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 2 Apr 2004 09:59:26 -0500
Hi again,
Gee, I am working hard on this. And you too unfortunately.
This is what I have when I reload the applet in appletviewer 1.4
:java.lang.NullPointerException
How comes thirdG = offBeanSlant.getGraphics(); is not
reinitialized on reload?
Jean
------------------
C:\learnJava\Applets_divers\MixedWires>appletviewer -debug MixedWires.html
Initializing jdb ...
> run
run sun.applet.Main MixedWires.html
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: true
====================== if I stop the appplet ====================
Exception occurred: java.lang.ThreadDeath (uncaught)"thread=Thread-2",
java.lang
.Thread.sleep(), line=-1 bci=-1
Thread-2[1] cont
====================== here I restart the applet then RELOAD
IT==================
> java.lang.NullPointerException
at MixedWires.init(MixedWires.java:103) see below
<<<<<<<<<<<<<<<<LINE 103
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:534)
quit
============= init ===================
public class MixedWires extends Applet
implements Runnable {
double angle = 0;
static final int MAXIMAGES = 21;
AudioClip bgsound;
boolean DEBUG = false;
boolean barFlag = true;
boolean pointFlag = true;
boolean cauldronFlag = true;
boolean gnuFlag = true;
boolean gooFlag = true;
boolean meltingpotFlag = true;
boolean trainFlag = true;
boolean urneFlag = true;
boolean virusFlag = true;
boolean spielbergFlag = true;
boolean nineFlag = true;
boolean bringCenterFlag = true;
boolean endFigureFlag = true;
boolean startFaceFlag = true;
MediaTracker tracker;
MemoryImageSource source;
Image offImage, myOffImage, offBeanSlant, i, o;
Image[] tmp, img;
Graphics g, offG, secondG, thirdG;
int facesNum;
int tracked;
int[] imgw, imgh;
int absCenterX, absCenterY, abswidth, absheight;
int frame_rate;
int[] parameterX;
int[] parameterY;
Font f;
FontMetrics fm;
Label emboss;
final int FLIP_H_V = 1;
final int FLIP_H_RIGHT = 2;
final int FLIP_V = 3;
final int SCALE = 4;
final static double flot = 0.842696629213483;
final static double flot2 = 0.75;
final static Color violet = new Color(150, 0, 255);
final static int Xarra[] = {203, 203, 244, 285, 326, 367, 396, 408, 405,
386, 349,
349, 308, 267, 226, 186, 145, 104, 63, 24, 3,
3, -2, 7, 33, 74, 115, 156, 197, 237, 278,
278, 319, 360, 390, 403, 400, 381, 344, 303, 262,
262, 221, 181, 140, 99, 58, 23, 5, 4, 18,
18, 50, 91, 132, 173};
final static int Yarra[] = {305, 305, 302, 292, 274, 243, 202, 161, 121,
80, 41,
41, 17, 2, -4, -5, 1, 14, 36, 74, 115,
115, 155, 196, 237, 271, 290, 301, 305, 298, 289,
289, 273, 243, 203, 162, 122, 81, 43, 20, 6,
6, 0, 0, 7, 22, 46, 85, 126, 166, 207,
207, 247, 275, 291, 299};
String imagePieces, str, imagination;
String name[];
String s, target, password, musique;
Thread cdPlayer, ong;
URL link;
Vector vecX = new Vector();
Vector vecY = new Vector();
Dimension dimension;
public void init() {
f = new Font("Serif", Font.BOLD | Font.ITALIC, 16);
setBackground(Color.white);
setForeground(Color.white);
dimension = this.getSize();
abswidth = dimension.width;
absheight = dimension.height;
absCenterX = abswidth / 2;
absCenterY = absheight / 2;
offBeanSlant = createImage(abswidth, absheight);
thirdG = offBeanSlant.getGraphics();
<<<<<<<<<<<<<<<<LINE 103
frame_rate = 18;
img = new Image[MAXIMAGES];
tmp = new Image[MAXIMAGES];
name = new String[MAXIMAGES];
parameterX = new int[MAXIMAGES];
parameterY = new int[MAXIMAGES];
imgw = new int[MAXIMAGES];
imgh = new int[MAXIMAGES];
facesNum = 0;
tracked = 0;
imagePieces = "head+yeuL+yeuR+yeuGooL+yeuGooR+nose+nosev+noseLw+"
+
"nostL+nostR+moustache+moustachev+lipUp+lipLw+cheekUp+cheek+startFigure+"
+ "gnu..hu..eu...eu...+yeuGooLV+yeuGooRV+endFigure";
str = "Jean Pierre Daviau.com";
imagination = "Imagination needs time and money.";
// Get parameter "size" from Web page:
bgsound = getAudioClip(getCodeBase(), getParameter("musique"));
password = getParameter("password");
s = getParameter("link");//getCodeBase().toString()
target = getParameter("target");
if (s == null)
s = "file:/C:/learnJava/Applets_divers/MixedWires";
if (musique == null)
musique = "files/Chinois.mid";
if (target == null)
target = "_blank";
if (password == null)
password = "";
if ((s.substring(11, 23)).equals("arnJava/Applets_")) {
} else {
if ((new Y().getIt()).equals("") ) {
try{
this.stop();
}catch(ThreadDeath e){
e.printStackTrace();
}
}
}
if (s != null)
try {
link = new URL(s);
} catch (Exception _ex) { }
tracker = new MediaTracker(this);
for (StringTokenizer stringtokenizer = new StringTokenizer(imagePieces,
"+");
stringtokenizer.hasMoreTokens() && tracked < MAXIMAGES; tracked++) {
name[tracked] = stringtokenizer.nextToken();
img[tracked] = getImage(getDocumentBase(), "files/" + name[tracked] +
".gif");
tracker.addImage(img[tracked], tracked);
while (!tracker.checkID(tracked, true)) {
pause(50);
}
imgw[tracked] = img[tracked].getWidth(null);
imgh[tracked] = img[tracked].getHeight(null);
parameterX[tracked] = (absCenterX - (imgw[tracked] / 2));
parameterY[tracked] = (absCenterY - (imgh[tracked] / 2));
if (DEBUG)
System.out.println ("inTracker " + name[tracked] + " " +
imgw[tracked] + " " + imgh[tracked] + " tracked " + tracked);
}
barFlag = false;
int c, t = abswidth-20;
int[] pixels = new int [t * absheight];
double radianConversion = (0.45 * Math.PI / 180.0);
for (int index = 0, y = 0;y < absheight / 5;y++) {
c = (int)(Math.abs (Math.sin((y + absheight) * radianConversion)) *
255);
for (int x = 0;x < t;x++) {
pixels[index++] = ((c << 24) | (0 << 16) | (0 << 8) | 255);
}
}
i = createImage (new MemoryImageSource (
//could be new DirectColorModel(255 * 3, 255 * 2, 255,24)
t, absheight / 5, new DirectColorModel((255 << 16) , (255 << 8),
255, (255 << 24)), pixels, 0, t));
//Creates a graphics context for this component. This method will return
null if this component is currently not on the screen.
offImage = createImage (t, absheight / 5);
offG = offImage.getGraphics();
offG.drawImage(i, 0, 0, this);
offG.setFont(f);
fm = offG.getFontMetrics();
offG.setColor(Color.red);
offG.drawString(str, (t - fm.stringWidth(str)) / 2, (absheight / 5) -
fm.getHeight());
//offG.dispose();
=============== end init ============================
void pause(int i) {
try {
Thread.sleep(i);
} catch (InterruptedException _ex) { }
return ;
}
public void run() {
if (bgsound != null)
startPlaying(bgsound);
cdPlayer.setPriority(1);
do {
repaint();
try {
Thread.sleep(1000 / frame_rate);
} catch (InterruptedException _ex) { }}
while (true);
}
public void start() {
cdPlayer = new Thread(this);
cdPlayer.start();
ong = new Thread(this);
}
void startPlaying(AudioClip audioclip) {
if (audioclip != null)
audioclip.loop();
}
public void stop() {
cdPlayer.stop();
}
void stopPlaying(AudioClip audioclip) {
if (audioclip != null)
audioclip.stop();
}
- Next message: Bryce (Work): "Re: convert date and time, please help."
- Previous message: John Harlow: "Re: Evaluate basic arithmatic in a string"
- Next in thread: Québec: "Re: debugger an eternal mystery (reload)"
- Reply: Québec: "Re: debugger an eternal mystery (reload)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|