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
|
package texteditor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class GraphVersion extends JFrame implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel container = null;//Declaration de l objet JPanel
//Composants
private JButton valider= null ;
private JTextField texte= null;
public GraphVersion(){
super();
build();
}
public static void main(String[] args){
GraphVersion g = new GraphVersion();
g.setVisible(true);
}
private void build(){
this.setTitle("TextEditor"); //On donne un titre � l�application
this.setSize(300,200); //On donne une taille � notre fen�tre
this.setLocationRelativeTo(null); //On centre la fen�tre sur l��cran
this.setContentPane(getContainer()) ;//On lui dit de mettre le panel en fond
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//On dit � l�application de se fermer lors du clic sur la croix
}
private JPanel getContainer(){
//layout = new SpringLayout() ; //Instanciation du layout
container = new JPanel() ; //On cr�e notre objet
//container.setLayout(layout);
texte= new JTextField("Fichier",15);
container.add(texte);
valider= new JButton("Action");
valider.setSize(75,75);
valider.setLocation(300,200);
valider.addActionListener(this);
container.add(valider);
return container ;
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==valider){
texte.setText("Vous avez cliqué!");
}
}
} |
Partager