Article View: borland.public.jbuilder.java.language
Article #8079Local Variable Needs to be Declared Final
From: Harry Whitehouse
Date: Tue, 24 Apr 2001 05:25
Date: Tue, 24 Apr 2001 05:25
43 lines
2162 bytes
2162 bytes
Well, I guess it's time to learn about the modifier "final"!
I'm trying to spawn a thread for the printer dialog on my applet, so the
dialog has time to close on slower connections without blanking the
underlying applet GUI. Heaven knows if my approach is even correct (that's
another question <g>) but for now I need to understand about the compiler
error message indicated a local variable (in this case printerJob) needs to
be declared final. I've seen this in some other threads I've created (to
handle URL transactions), but have managed to sidestep this issue by
declaring and using non-local variables.
First, what is the proper syntax for this? I've tried some obvious
permutations but with no luck.
And second, what is the significance of this modifier?
void PrintButton_actionPerformed(ActionEvent e) {
PrinterJob printerJob=null;
bprintpostage=jCheckPrintPostage.isSelected();
printerJob = PrinterJob.getPrinterJob();
Thread printthread = new Thread() {
public void run() {
doPrint = printerJob.printDialog();
}
};
printthread.start();
try {
printthread.join();
}
catch (Exception jprintexp) {
jprintexp.printStackTrace(System.out);
return;
}
TIA
Harry
Technical Details
Message-ID:
<3ae50e3c$1_1@dnews>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!sn-xit-04!supernews.com!newsfeed.mesh.ad.jp!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,4be1a32d6ef1248,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-04-23 22:48:04 PST From: "Harry Whitehouse" <harry@envmgr.com> Newsgroups: borland.public.jbuilder.java.language Subject: Local Variable Needs to be Declared Final Date: Mon, 23 Apr 2001 22:25:24 -0700 Lines: 46 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 38.168.115.135 Message-ID: <3ae50e3c$1_1@dnews> X-Trace: dnews 988089916 38.168.115.135 (23 Apr 2001 22:25:16 -0700) Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!sn-xit-04!supernews.com!newsfeed.mesh.ad.jp!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews