java中的BREAK和CONTINUE语句的应用

package aac;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Frame1 extends JFrame {
  JPanel contentPane;
  BorderLayout borderLayout1 = new BorderLayout();
  TextArea textArea1 = new TextArea();

  //Construct the frame
  public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception  {
    contentPane = (JPanel) this.getContentPane();


    for(int i=0;i<100;i++){
    if(i==46)break;
  if(i%9!=0)continue;
textArea1.append(i+"\n");
}
     int i = 0;
     while(true){
     i++;
   if(i==40)break;
 if(i%10!=0)continue;
    textArea1.append(i+"\n");}
    contentPane.setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    contentPane.add(textArea1,  BorderLayout.NORTH);
  }
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
}

posted @ 2006-04-08 17:43  Tnu  阅读(825)  评论(0编辑  收藏  举报