0% found this document useful (0 votes)
33 views4 pages

Java

The document defines a Java application with a menu bar and internal frames. It creates a main frame with menus to open internal frames for examples 1 and 2 of topics 1 and 2. It then defines the internal frame classes with basic GUI components like buttons and labels.

Uploaded by

Iram Kasan
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)
33 views4 pages

Java

The document defines a Java application with a menu bar and internal frames. It creates a main frame with menus to open internal frames for examples 1 and 2 of topics 1 and 2. It then defines the internal frame classes with basic GUI components like buttons and labels.

Uploaded by

Iram Kasan
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/ 4

import java.awt.

BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class Bureau extends JFrame {


// declaration globale des composantes
private JMenuBar menuBar;

private JMenu menutp1,menutp2;

private JMenuItem itemex1_tp1,itemex2_tp1,itemex1_tp2,itemex2_tp2,menutp3;

private JLabel lbl_help;

private JDesktopPane desktop;

public Bureau() {
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(700, 500);
this.setTitle("tps java");

menuBar=new JMenuBar();

menutp1=new JMenu("tp1");
menutp2=new JMenu("tp2");

menutp3=new JMenuItem("tp3");
menutp3.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
InternalFrame_tp3 fn3=new InternalFrame_tp3();
desktop.add(fn3);
}
});

itemex1_tp1=new JMenuItem("ex1");

itemex1_tp1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
InternalFrameEx1_tp1 fr1=new InternalFrameEx1_tp1();
desktop.add(fr1);

}
});
menutp1.add(itemex1_tp1);

itemex2_tp1=new JMenuItem("ex2");
itemex2_tp1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
IntrnallFrameEx1_tp2 fen2=new IntrnallFrameEx1_tp2();
desktop.add(fen2);

}
});
menutp1.add(itemex2_tp1);

itemex1_tp2=new JMenuItem("ex1");
menutp2.add(itemex1_tp2);

itemex2_tp2=new JMenuItem("ex2");
menutp2.add(itemex2_tp2);

menuBar.add(menutp1);
menuBar.add(menutp2);
menuBar.add(menutp3);

this.setJMenuBar(menuBar);

// layout par defaut = borderlayout

this.setLayout(new BorderLayout());

lbl_help=new JLabel("annee universitaire 2020-2021");


this.add(lbl_help,BorderLayout.SOUTH);

desktop=new JDesktopPane();
this.add(desktop,BorderLayout.CENTER);

public static void main(String[] args) {


// TODO Auto-generated method stub
Bureau b=new Bureau();
b.setVisible(true);

------------------------------------------------------------------------------
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JInternalFrame;

public class InternalFrameEx1_tp1 extends JInternalFrame {


private JButton btnval;

public InternalFrameEx1_tp1() {
this.setTitle("fenetre interne 1");
this.setBounds(10, 10, 400, 300);
this.setClosable(true);
this.setResizable(true);
this.setIconifiable(true);

this.setLayout(new FlowLayout());

btnval=new JButton("valider");
this.add(btnval);

this.setVisible(true);

---------------------------------------------------------------------------------

import javax.swing.JInternalFrame;

public class IntrnallFrameEx1_tp2 extends JInternalFrame{

public IntrnallFrameEx1_tp2() {
this.setTitle("fenetre interne 1");
this.setBounds(10, 10, 400, 300);
this.setClosable(true);
this.setResizable(true);
this.setIconifiable(true);
this.setVisible(true);

-------------------------------------------------------------------------------

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class InternalFrame_tp3 extends JInternalFrame{


JLabel lbl_nom,lbl_prenom,lbl_pseudo;
JTextField txt_nom,txt_prenom,txt_pseudo;
JButton btn_val;
JList list_pseudo;
public InternalFrame_tp3() {
this.setTitle("Gestion profil");
this.setSize(600, 500);
this.setClosable(true);
this.setLocation(0, 0);
this.setBounds(0, 0, 600, 500);
JPanel pn=new JPanel();
lbl_nom=new JLabel("nom");
txt_nom=new JTextField(10);
lbl_prenom=new JLabel("prenom");
txt_prenom=new JTextField(10);
lbl_pseudo=new JLabel("pseudo");
txt_pseudo=new JTextField(10);
btn_val=new JButton("Valider");
pn.setLayout(new FlowLayout());
pn.add(lbl_nom);
pn.add(txt_nom);
pn.add(lbl_prenom);
pn.add(txt_prenom);
pn.add(lbl_pseudo);
pn.add(txt_pseudo);
pn.add(btn_val);
list_pseudo=new JList<>();
this.setLayout(new BorderLayout());
this.add(pn,BorderLayout.NORTH);
this.add(list_pseudo,BorderLayout.CENTER);
//JOptionPane.showMessageDialog(InternalFrame_tp3.this, "erreur de sasie");
this.setVisible(true);
}

43:25

You might also like