0% found this document useful (0 votes)
5 views1 page

TP Ihm

The document contains a Java program that creates a simple graphical user interface (GUI) with a main window titled 'HELLO WORLD'. It includes a menu bar with 'File', 'Edit', and 'Help' menus, and a 'New' menu item that opens a second window when clicked. The program sets up the main window to be visible and ensures it closes properly when exited.

Uploaded by

Lina
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 views1 page

TP Ihm

The document contains a Java program that creates a simple graphical user interface (GUI) with a main window titled 'HELLO WORLD'. It includes a menu bar with 'File', 'Edit', and 'Help' menus, and a 'New' menu item that opens a second window when clicked. The program sets up the main window to be visible and ensures it closes properly when exited.

Uploaded by

Lina
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
You are on page 1/ 1

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package menuu;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Menuu {
public static void main(String[] args) {
/**** creation fenetre principale ****/
JFrame fenetre = new JFrame("HELLO WORLD");
fenetre.setSize(400, 300);

JFrame f2 = new JFrame();


f2.setSize(400, 300);

JMenuBar menuBar = new JMenuBar();

JMenu file = new JMenu("file");


JMenu edit = new JMenu("Edit");
JMenu help = new JMenu("help");

menuBar.add(file);
menuBar.add(edit);
menuBar.add(help);

JMenuItem New = new JMenuItem("New");


JMenuItem exit = new JMenuItem("Exit");

file.add(New);
file.addSeparator();
file.add(exit);

fenetre.setJMenuBar(menuBar);

New.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
f2.setVisible(true);

}
});

fenetre.setVisible(true);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

You might also like