package multiplicationtable;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;/**
 * <p>Title: 九九乘法口诀表</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: Redv.com</p>
 * @author unascribed
 * @version 1.0
 */public class Frame1 extends JFrame
{
  private JPanel contentPane;
  private TextArea textArea1 = new TextArea();
  private XYLayout xYLayout1 = new XYLayout();
  private Button button1 = new Button();  //Construct the frame
  public Frame1()
  {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try
    {
      jbInit();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception
  {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    textArea1.setText("textArea1");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    button1.setLabel("button1");
    button1.addActionListener(new java.awt.event.ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        button1_actionPerformed(e);
      }
    });
    contentPane.add(textArea1,    new XYConstraints(0, 0, 400, 209));
    contentPane.add(button1,    new XYConstraints(114, 214, 162, 56));
  }
  //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);
    }
  }  void button1_actionPerformed(ActionEvent e)
  {
    //主要部分
    String str = "";
    for(int i = 1; i <= 9; i++)
    {
      for(int j = i; j <= 9; j++)
      {
        if(i == j && i != 1)
        {
          str += "\n";
        }
        str += i + "×" + j + "=" + (i*j + " ");
      }
    }
    this.textArea1.setText(str);
  }
}

解决方案 »

  1.   

    for(int i=1;i<=9;i++) {
      for(int j=1;j<=i;j++) {
        if(j!=1)
          System.out.print(",");
        System.out.print(j+"*"+i+"="+i*j);
      }
      System.out.println("");
        }
      

  2.   

    beyond_xiruo(离开csdn去避难)的很好
      

  3.   

    do not copy codes from jb directly
    not everybody using jb.
      

  4.   

    一样???不一样吧
    一楼的两个循环都是0-9,我那个不是哦
    public class test {
    public static void main(String args[]) {
    for(int i=1;i<=9;i++) {
      for(int j=1;j<=i;j++) {
        if(j!=1)
          System.out.print(",");
        System.out.print(j+"*"+i+"="+i*j);
      }
      System.out.println("");
    }
    }
    }
      

  5.   

    我的二重循环是从 i(not 1)到9,你的二重循环是1到i,不还是一样?