zor_k | c'est bien ce que je pensais mais je dois mal faire quelque chose.. en effet rien ne s'affiche. voici mon code (et pour info l'image est bien dans le meme repertoire que le code )
Code :
- package frames.produit.ajout;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.image.*;
- import java.awt.event.*;
- /**
- * @author zork
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
- public class AjoutProduit extends JFrame{
- public static void main(String[] args) {
- AjoutProduit frame = new AjoutProduit();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setLocation(450,350);
- frame.show();
- }
- public AjoutProduit()
- {
- setTitle("PhotoService - Ajout produit" );
- setSize(WIDTH,HEIGHT);
- JMenuBar menuBar = new JMenuBar();
- setJMenuBar(menuBar);
- JMenu fichierMenu = new JMenu("Fichier" );
- fichierMenu.setMnemonic('F');
- JMenuItem ajouterItem = new JMenuItem("Ajouter" );
- //ajouterItem.addActionListener(ajouterListener);
- fichierMenu.add(ajouterItem);
- fichierMenu.add(new
- AbstractAction("Quitter" )
- {
- public void actionPerformed(ActionEvent event)
- {
- System.exit(0);
- }
- });
- menuBar.add(fichierMenu);
- //definition du layout manager
- Container contentPane = getContentPane();
- GridBagLayout layout = new GridBagLayout();
- contentPane.setLayout(layout);
- titreLabel=new JLabel(" Ajout produit " );
- videLabel=new JLabel();
- videLabel.setIcon(new ImageIcon("dncr_logo_en.gif" ));
- numeroLabel= new JLabel("Numero de produit :" );
- GridBagConstraints constraints = new GridBagConstraints();
- constraints.fill = GridBagConstraints.BOTH;
- constraints.anchor = GridBagConstraints.CENTER;
- constraints.weightx = 0;
- constraints.weighty = 0;
- add(titreLabel,constraints,0,0,3,1);
- add(videLabel,constraints,0,1,3,1);
- add(videLabel,constraints,1,1,3,1);
- constraints.fill = GridBagConstraints.NONE;
- constraints.anchor = GridBagConstraints.WEST;
- add(numeroLabel,constraints,0,2,1,1);
- }
- public void add(Component c, GridBagConstraints constraints, int x, int y, int w, int h)
- {
- constraints.gridx = x;
- constraints.gridy = y;
- constraints.gridwidth = w;
- constraints.gridheight = h;
- getContentPane().add(c, constraints);
- }
- public final static int WIDTH = 400;
- public final static int HEIGHT = 400;
- private JLabel titreLabel;
- private JLabel videLabel;
- private JLabel numeroLabel;
- }
|
|