1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| package trigo;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.math.*;
/**
* <p>Titre : </p>
*
* <p>Description : </p>
*
* <p>Copyright : Copyright (c) 2007</p>
*
* <p>Société : </p>
*
* @author non attribuable
* @version 1.0
*/
public class CadreTrigo extends JFrame {
public CadreTrigo() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
setSize(480,510);
setVisible(true);
}
private void jbInit() throws Exception {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.getContentPane().setLayout(null);
jLabel1.setFont(new java.awt.Font("Dialog", Font.BOLD, 15));
jLabel1.setText("Trigo");
jLabel1.setBounds(new Rectangle(58, 0, 51, 28));
jLabel2.setText("min");
jLabel2.setBounds(new Rectangle(42, 292, 27, 15));
jLabel3.setText("max");
jLabel3.setBounds(new Rectangle(134, 290, 29, 18));
jLabel4.setText("step");
jLabel4.setBounds(new Rectangle(225, 291, 28, 17));
jScrollPane1.setBounds(new Rectangle(36, 35, 355, 249));
jTextArea1.setEditable(false);
jTextArea1.setText("");
jButton1.addActionListener(new CadreTrigo_jButton1_actionAdapter(this));
this.getContentPane().add(jLabel1);
jButton1.setBounds(new Rectangle(331, 289, 60, 23));
jButton1.setText("Go !");
jTextField4.setText("0");
jTextField4.setBounds(new Rectangle(256, 288, 39, 25));
jTextField3.setText("0");
jTextField3.setBounds(new Rectangle(166, 288, 41, 25));
jTextField2.setText("0");
jTextField2.setBounds(new Rectangle(73, 288, 43, 25));
this.getContentPane().add(jTextField2);
this.getContentPane().add(jTextField4);
this.getContentPane().add(jButton1);
this.getContentPane().add(jTextField3);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jLabel4);
this.getContentPane().add(jScrollPane1);
jScrollPane1.getViewport().add(jTextArea1);
}
JLabel jLabel1 = new JLabel();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JTextField jTextField4 = new JTextField();
JButton jButton1 = new JButton();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JScrollPane jScrollPane1 = new JScrollPane();
JTextArea jTextArea1 = new JTextArea();
public static double sin (double a){
return sin (a) ;
}
public static double cos (double a){
return cos (a) ;
}
public static double tan (double a){
return tan (a) ;
}
public void jButton1_actionPerformed(ActionEvent e) {
double angle,step,min,max;
jTextArea1.append(" DEGRES \t SIN \t COS \t TAN\n");
jTextArea1.append("+---------------------------------------------------------------------+");
min=Double.parseDouble(jTextField2.getText());
max=Double.parseDouble(jTextField3.getText());
step=Double.parseDouble(jTextField4.getText());
System.out.println("min: "+min + " max: " + max + " step: " + step);
double c,s,t;
double radian;
boolean erreur=false;
for(angle=min;angle<=max;angle=angle+step)
{
if(angle==90 || angle==-90) erreur=true;
radian=angle*3.14159/180;
c = cos(radian);
s = sin(radian);
t = tan(radian);
if (erreur) jTextArea1.append("| "+angle+" | "+c+" | "+s+" | INFINI | \n");
else jTextArea1.append("| "+angle+" | "+c+" | "+s+" | "+t+" | \n");
}
}
}
class CadreTrigo_jButton1_actionAdapter implements ActionListener {
private CadreTrigo adaptee;
CadreTrigo_jButton1_actionAdapter(CadreTrigo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
} |
Partager