0% found this document useful (0 votes)
5 views3 pages

Java GUI Applications and List Management

The document contains multiple Java classes demonstrating basic programming concepts, including a simple Hello World application, a calculator GUI, a label-changing window, a click counter, and a list management console application. Each class showcases different functionalities such as user interaction through buttons and text fields, as well as handling user input in a command-line interface. The examples illustrate fundamental Java programming techniques and GUI development using Swing.

Uploaded by

bouziani.hwau
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Java GUI Applications and List Management

The document contains multiple Java classes demonstrating basic programming concepts, including a simple Hello World application, a calculator GUI, a label-changing window, a click counter, and a list management console application. Each class showcases different functionalities such as user interaction through buttons and text fields, as well as handling user input in a command-line interface. The examples illustrate fundamental Java programming techniques and GUI development using Swing.

Uploaded by

bouziani.hwau
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

public class HelloWorld {

public static void main(String[] args) {


[Link]("Hello, World!");
}
}

import [Link].*;
import [Link].*;
import [Link].*;

public class Calculatrice {


public static void main(String[] args) {
JFrame frame = new JFrame("Calculatrice");
[Link](300, 400);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new BorderLayout());

JTextField textField = new JTextField();


[Link](textField, [Link]);

JPanel panel = new JPanel();


[Link](new GridLayout(4, 4));
String[] buttons = {"7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3",
"-", "0", "=", "+", "C"};
for (String text : buttons) {
JButton button = new JButton(text);
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e) {
String command = [Link]();
if ([Link]("=")) {
[Link](calculate([Link]()));
} else if ([Link]("C")) {
[Link]("");
} else {
[Link]([Link]() + command);
}
}
});
[Link](button);
}
[Link](panel, [Link]);
[Link](true);
}

private static String calculate(String expression) {


// Vous pouvez ajouter une méthode de calcul simple ici (ex: avec un moteur
d'évaluation)
return expression; // Placeholder
}
}

import [Link].*;

public class FenetreAvecLabel {


public static void main(String[] args) {
JFrame frame = new JFrame("Fenetre avec Label");
[Link](300, 200);
[Link](JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Bienvenue", [Link]);
[Link](label, [Link]);

JButton button = new JButton("Changer le texte");


[Link](e -> [Link]("Texte changé!"));
[Link](button, [Link]);

[Link](true);
}
}

import [Link].*;

public class CompteurDeClics {


public static void main(String[] args) {
JFrame frame = new JFrame("Compteur de Clics");
[Link](300, 200);
[Link](JFrame.EXIT_ON_CLOSE);

JLabel label = new JLabel("Nombre de clics: 0", [Link]);


[Link](label, [Link]);

JButton button = new JButton("Cliquer ici");


[Link](e -> {
int count = [Link]([Link]().split(": ")[1]);
count++;
[Link]("Nombre de clics: " + count);
});
[Link](button, [Link]);

[Link](true);
}

}import [Link];
import [Link];

public class GestionDeListe {


public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
ArrayList<String> list = new ArrayList<>();

while (true) {
[Link]("1. Ajouter un élément");
[Link]("2. Afficher la liste");
[Link]("3. Supprimer un élément");
[Link]("4. Quitter");
[Link]("Choisissez une option: ");
int choice = [Link]();
[Link](); // Consomme la ligne vide

switch (choice) {
case 1:
[Link]("Entrez un élément à ajouter: ");
String item = [Link]();
[Link](item);
break;
case 2:
[Link]("Liste des éléments:");
for (String element : list) {
[Link](element);
}
break;
case 3:
[Link]("Entrez l'élément à supprimer: ");
String elementToRemove = [Link]();
[Link](elementToRemove);
break;
case 4:
[Link]("Au revoir!");
return;
default:
[Link]("Option invalide.");
}
}
}
}

You might also like