熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

JAVA編程語言程序開發平方

2022-06-13   來源: Java核心技術 

  [java]

  package Second;

  import javaawt*;

  import javaxswing*;

  import javamath*;

  import javaawtevent*;

  public class test implements ActionListener{

  /**

  * @param args

  */

  public JTextField s=new JTextField(

  public JTextField s=new JTextField(

  public JLabel l=new JLabel(平方

  public JLabel l=new JLabel(立方

  public JLabel l=new JLabel( 四次方

  public JButton b=new JButton(平方結果

  public JButton b=new JButton(立方結果

  public JButton b=new JButton(四次方根

  void display()

  {

  JPanel panel=new JPanel(new GridLayout())

  JFrame jf=new JFrame(測試程序

  jfsetSize(

  jfsetContentPane(panel)

  jfsetVisible(true)

  jfsetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)

  jfsetResizable(false)

  paneladd(s)

  paneladd(s

  paneladd(l

  paneladd(b

  paneladd(l

  paneladd(b

  paneladd(l

  paneladd(b

  baddActionListener(this)

  baddActionListener(this)

  baddActionListener(this)

  }

  public void actionPerformed(ActionEvent e){

  if(egetSource()==b

  {

  double a=DoubleparseDouble(sgetText())

  a=a*a;

  ssetText(+a)

  }

  else if(egetSource()==b

  {

  double a=DoubleparseDouble(sgetText())

  a=a*a*a;

  ssetText(+a)

  }

  else if(egetSource()==b

  {

  double a=DoubleparseDouble(sgetText())

  a=a*a*a*a;

  ssetText(+a)

  }

  }

  public static void main(String[] args) {

  // TODO Autogenerated method stub

  test m=new test()

  mdisplay()

  }

  }


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26316.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.