93 lines
2.3 KiB
Java
93 lines
2.3 KiB
Java
|
package fr.blankoworld.ihm;
|
|||
|
|
|||
|
import java.awt.BorderLayout;
|
|||
|
import java.awt.Dimension;
|
|||
|
import java.awt.Insets;
|
|||
|
import java.awt.event.ActionEvent;
|
|||
|
import java.awt.event.ActionListener;
|
|||
|
|
|||
|
import javax.swing.JButton;
|
|||
|
import javax.swing.JFrame;
|
|||
|
import javax.swing.JLabel;
|
|||
|
import javax.swing.JPanel;
|
|||
|
import javax.swing.JScrollPane;
|
|||
|
import javax.swing.JTextPane;
|
|||
|
|
|||
|
|
|||
|
public class IHMRequete extends JFrame {
|
|||
|
// Requis par la classe JFrame (ne pas demander pourquoi)
|
|||
|
private static final long serialVersionUID = 1L;
|
|||
|
|
|||
|
// Creation de la zone de texte
|
|||
|
private JTextPane panneauTexte;
|
|||
|
|
|||
|
private IHMPrincipale pr;
|
|||
|
|
|||
|
public IHMRequete(IHMPrincipale pr){
|
|||
|
|
|||
|
this.pr = pr;
|
|||
|
// Creation d'une etiquette
|
|||
|
JLabel jRequete = new JLabel("Entrez votre requete : ");
|
|||
|
|
|||
|
// Creation des boutons
|
|||
|
JButton jOk = new JButton("Ok");
|
|||
|
JButton jAnnuler = new JButton("Quitter");
|
|||
|
|
|||
|
// Creation de la zone de texte
|
|||
|
panneauTexte = new JTextPane();
|
|||
|
panneauTexte.setCaretPosition(0);
|
|||
|
panneauTexte.setMargin(new Insets(5,5,5,5));
|
|||
|
JScrollPane zoneTexteRequete = new JScrollPane(panneauTexte);
|
|||
|
zoneTexteRequete.setPreferredSize(new Dimension(200, 130));
|
|||
|
|
|||
|
// Creation des panneaux bas et centre
|
|||
|
JPanel Panneau_Bas = new JPanel();
|
|||
|
JPanel Panneau_Centre = new JPanel();
|
|||
|
Panneau_Centre.setLayout(new BorderLayout());
|
|||
|
|
|||
|
// Ajout des boutons a chacun des panneaux
|
|||
|
Panneau_Centre.add(jRequete, BorderLayout.NORTH);
|
|||
|
Panneau_Centre.add(zoneTexteRequete, BorderLayout.CENTER);
|
|||
|
|
|||
|
Panneau_Bas.add(jOk);
|
|||
|
Panneau_Bas.add(jAnnuler);
|
|||
|
|
|||
|
// Gestionnaire de contenus
|
|||
|
this.getContentPane().setLayout(new BorderLayout());
|
|||
|
this.add(Panneau_Centre, BorderLayout.CENTER);
|
|||
|
this.add(Panneau_Bas, BorderLayout.SOUTH);
|
|||
|
|
|||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|||
|
|
|||
|
this.setSize(400,200);
|
|||
|
this.setLocation(200,200);
|
|||
|
this.setResizable(false);
|
|||
|
this.setTitle("Requete");
|
|||
|
|
|||
|
// ******************************** //
|
|||
|
// Mise en place des <20>couteurs //
|
|||
|
// ******************************** //
|
|||
|
|
|||
|
jOk.addActionListener(new ActionListener(){
|
|||
|
public void actionPerformed(ActionEvent ev){
|
|||
|
valider();
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
jAnnuler.addActionListener(new ActionListener(){
|
|||
|
public void actionPerformed(ActionEvent ev){
|
|||
|
annuler();
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void valider(){
|
|||
|
this.pr.envoiRequete(this.panneauTexte.getText());
|
|||
|
}
|
|||
|
|
|||
|
private void annuler(){
|
|||
|
dispose();
|
|||
|
}
|
|||
|
}
|