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
| package graphique;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class interface_graphique extends JFrame implements KeyListener{
Container contenu;
JLabel label = new JLabel ("MATIERE PRIMA");
JLabel label2 = new JLabel("MATIERE FINITA");
JLabel label3 = new JLabel("X");
JLabel label4 = new JLabel("3000");
static JTextField textfield = new JTextField();
JTextField textfield1 = new JTextField();
JButton bouton = new JButton("CERCARE");
public static JTextField getJtextfield() {
return textfield;
}
public void setJTextfield(JTextField textfield) {
this.textfield = textfield;
}
public interface_graphique(){
this.setBounds(100,100,600,400);
this.setTitle("Numero di ferro taglio");
this.setVisible(true);
setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
contenu=this.getContentPane();
contenu.setLayout(null);
contenu.add(label);
contenu.add(label2);
contenu.add(label3);
contenu.add(label4);
contenu.add(textfield);
contenu.add(textfield1);
contenu.add(bouton);
bouton.addActionListener(null);
label.setBounds(40, 10,200, 50);
label2.setBounds(100,270 , 150, 50);
label3.setBounds(255,290, 10, 10);
label4.setBounds(270, 280, 60, 30);;
textfield.setBounds(170, 10, 100, 50);
textfield1.setBounds(210, 280, 40, 30);
bouton.setBounds(400, 10, 100, 50);
go();
}
private void go() {
// TODO Auto-generated method stub
}
class BoutonListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
if (evt.getSource()==bouton ) {
textfield1= textfield;
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new interface_graphique();
}
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
int i,j,k ;
i = Integer.parseInt(textfield.getText()) ;
j = Integer.parseInt(textfield1.getText()) ;
k=i/3000 ;
j=k;
System.out.println(k);
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
} |
Partager