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
| import java.awt.Container;
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.JList;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
//Les conditions:
//Pour comparer, faut utiliser le getText().equals(x), et x est le texte à comparer!
public class AceQuest extends JFrame{
Container contenu;
//Composants
JLabel label = new JLabel("Nom de la quête:");
JButton button = new JButton("Définir maximum...");
JTextField textfield = new JTextField();
JList listebox = new JList();
public AceQuest(){
//Création de la fenêtre principale
this.setBounds(100, 100, 798, 431);
this.setTitle("Ace Quest - V3");
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//Initialise et Ajouts des composants
contenu = this.getContentPane();
contenu.add(label);
contenu.add(button);
contenu.add(textfield);
contenu.add(listebox);
//Modification contenu pour placer les objets n'importe où
contenu.setLayout(null);
//Placement des objets
label.setBounds(350, 30, 100, 50);
button.setBounds(7, 357, 138, 30);
textfield.setBounds(450, 45, 100, 25);
listebox.setBounds(7, 74, 138, 277);
//Action de chaque objets
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
if (textfield.getText().equals("motdepasse"))
JOptionPane.showMessageDialog(null,"alert");
new Maximum().setVisible(true);
}
});
String[] arr = {"one", "two", "three"};
listebox.setListData(arr);
}
public static void main(String[] args) {
new AceQuest();
}
} |
Partager