applet类中 方法外 new 对象是如何被执行的呢?

ewwerpm 2010-05-17 05:40:16
package my;
import java.applet.Applet;
public class For extends Applet{// implements Runnable {

private static final long serialVersionUID = 6288499508495040201L;
private Applet client;
private Runnable loadedCallback;
Finally fina = new Finally();
public final synchronized void destroy() {
if (client != null) {
client.destroy();
}
}
public Applet getClient() {
return client;
}
public final synchronized void init() {
if (client != null) {
client.init();
}
else{
resize(868,603);
}
}
public final void paint(final Graphics graphics) {
if (client != null) {
client.paint(graphics);
}
else
{
Font font = new Font("Helvetica", 1,13);
FontMetrics fontMetrics = getFontMetrics(font);
graphics.setColor(Color.black);
graphics.fillRect(0, 0, 768, 503);
graphics.setColor(Color.red);
graphics.drawRect(232, 232, 303, 33);
String s = "正在下载。。。";
graphics.setFont(new Font("Helvetica", 1, 13));
graphics.setColor(Color.YELLOW);
//System.out.println("(768 - fontMetrics.stringWidth(s)) / 2=" + (768 - fontMetrics.stringWidth(s)) / 2);
graphics.drawString(s, (768 - fontMetrics.stringWidth(s)) / 2, 255);//255);
}
}

public void setCallback(final Runnable r) {
loadedCallback = r;
}
public final synchronized void start() {
if (client != null) {
client.start();
}
}
public final synchronized void stop() {
if (client != null) {
client.stop();
}
}
public final void update(final Graphics graphics) {
if (client != null) {
client.update(graphics);
}
}
}
...全文
179 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangmin3956 2010-08-20
  • 打赏
  • 举报
回复
继续上次的回话 还是不知道
ewwerpm 2010-05-17
  • 打赏
  • 举报
回复
问题:在applet中,Finally fina = new Finally();语句是在哪条语句执行之后执行的呢?执行完后又去执行哪条语句了呢?
ewwerpm 2010-05-17
  • 打赏
  • 举报
回复
package my;

public class Finally{
public static void main(String[] args)
{
Finally e=new Finally();
System.out.println(e.tryThis());
}
Finally(){System.out.println("in Finally");}
public int tryThis()
{
try{
System.out.println("1");
throw new Exception();
//return 1;
}catch(Exception ex){
System.out.println("2");
return 2;
}finally{
System.out.println("4");
return 3;
}
}
}

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧