Probleme en java

Fermé
saif87 Messages postés 109 Date d'inscription dimanche 12 octobre 2008 Statut Membre Dernière intervention 2 juin 2011 - 18 déc. 2008 à 16:25
mype Messages postés 2435 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 16 août 2010 - 18 déc. 2008 à 17:08
Bonjour,
bonjour je suis débutant en graphique de java et je veut créer une application pour une gestion bancaire donc il y'a une interface graphique(frame)composer de 3 boutton
b1:creation du client
b2:cretaion du compte
b3:affichage des inforamtion
si l'utilisateur tape b1 une frame apparait composer d'une suite de zone de text
et ainsi de suite......
voici mon code mais l'orsque je tape le boutton 3 frame apparait
aidez moi svp
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ButtonPanel extends JPanel
{
ButtonPanel()
{

JButton client=new JButton("cree un client");
JButton compte=new JButton("cree un compte");
JButton information=new JButton("afficher vos informations");
add(client,BorderLayout.WEST);
add(compte,BorderLayout.CENTER);
add(information,BorderLayout.EAST);
client.addActionListener(new ColorAction());
compte.addActionListener(new ColorAction());
information.addActionListener(new ColorAction());
}


class ColorAction implements ActionListener
{

ColorAction()
{
}

public void actionPerformed(ActionEvent event)
{
//setBackground(color);
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
int w=screenSize.width;
int h=screenSize.height;


JFrame frame1=new MainFrame(w/2,h/2,100,100,"frame1");
//setBackground(color);
/*frame.setBackground(Color.red);*/
frame1.show();

JFrame frame2=new MainFrame(w/2,h/2,100,100,"frame2");
//setBackground(color);
/*frame.setBackground(Color.red);*/
frame2.show();
JFrame frame3=new MainFrame(w/2,h/2,100,100,"frame3**");
//setBackground(color);
/*frame.setBackground(Color.red);*/
frame3.show();



}
}
}
class MainGraphique4
{
public static void main(String[] args)
{
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
int w=screenSize.width;
int h=screenSize.height;
JFrame frame=new MainFrame(w/2,h/2,0,0,"GESTION BANCAIRE");

// JFrame frame=new MainFrame(300,150,400,0);
frame.show();
}

}
class MainFrame extends JFrame
{
MainFrame(int w,int h,int x,int y,String ch)
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle(ch);
setSize(w,h);
setLocation(x,y);
getContentPane().add(new ButtonPanel());
//setBackground();
}
/* MainFrame(int w,int h,int x,int y,Color c)
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("soussi saif ");
setSize(w,h);
setLocation(x,y);
getContentPane().add(new ButtonPanel());
setBackground(c);
}*/
}
j'utilise le jdk 1.4 c'est une obligation du prof
merci.
A voir également:

1 réponse

mype Messages postés 2435 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 16 août 2010 436
18 déc. 2008 à 16:39
voici mon code mais l'orsque je tape le boutton 3 frame apparait
aidez moi svp

j'ai pas trop compris le probleme là ?
0
saif87 Messages postés 109 Date d'inscription dimanche 12 octobre 2008 Statut Membre Dernière intervention 2 juin 2011
18 déc. 2008 à 16:52
bonjour merci de maidez voici mon code essai svp de le corriger il genere une seule faute
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ButtonPanel extends JPanel
{
ButtonPanel()
{

JButton client=new JButton("cree un client");
JButton compte=new JButton("cree un compte");
JButton information=new JButton("afficher vos informations");
add(client,BorderLayout.WEST);
add(compte,BorderLayout.CENTER);
add(information,BorderLayout.EAST);
client.addActionListener(new ColorAction("client"));
compte.addActionListener(new ColorAction("compte"));
information.addActionListener(new ColorAction("information"));
}

class Texte extends JPanel implements ActionListener
{
JLabel nom;
JTextField n;
JLabel prenom;
JTextField p;
JLabel telephone;
JTextField t;
public Texte()
{
nom=new JLabel("nom");
n=new JTextField();
n.addActionListener(this);
prenom=new JLabel("prenom");
p=new JTextField();
p.addActionListener(this);
telephone=new JLabel("telephone");
t.addActionListener(this);
add(nom);
add(n);
add(prenom);
add(p);
add(telephone);
add(t);
}
public void actionPerformed(ActionEvent event)
{
}



}
class ColorAction implements ActionListener
{
private String s;
ColorAction()
{
}
ColorAction(String s)
{
this.s=s;
}
public void actionPerformed(ActionEvent event)
{
//setBackground(color);
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
int w=screenSize.width;
int h=screenSize.height;
if(s.equals("client"))
{
JFrame frame1=new MainFrame(w/2,h/2,100,100,"frame1");

//setBackground(color);
/*frame.setBackground(Color.red);*/
frame1.show();
}
if(s.equals("compte"))
{
JFrame frame2=new MainFrame(w/2,h/2,100,100,"frame2");
//setBackground(color);
/*frame.setBackground(Color.red);*/
frame2.show();
}
if(s.equals("information"))
{
JFrame frame3=new MainFrame(w/2,h/2,100,100,"frame3**");
//setBackground(color);
/*frame.setBackground(Color.red);*/
frame3.show();
}



}
}
}
class MainGraphique4
{
public static void main(String[] args)
{
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
int w=screenSize.width;
int h=screenSize.height;
JFrame frame=new MainFrame(w/2,h/2,0,0,"GESTION BANCAIRE");

frame.show();
}

}
class MainFrame extends JFrame
{
MainFrame(int w,int h,int x,int y,String ch)
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle(ch);
setSize(w,h);
setLocation(x,y);
getContentPane().add(new ButtonPanel());
getContentPane().add(new Texte());
//setBackground();
}
/* MainFrame(int w,int h,int x,int y,Color c)
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("soussi saif ");
setSize(w,h);
setLocation(x,y);
getContentPane().add(new ButtonPanel());
setBackground(c);
}*/
}
0
mype Messages postés 2435 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 16 août 2010 436 > saif87 Messages postés 109 Date d'inscription dimanche 12 octobre 2008 Statut Membre Dernière intervention 2 juin 2011
18 déc. 2008 à 17:08
ben il faudrait nous dire qu'elle faute...
erreur a la compilation ? quels message du compilateur ? a quel ligne ?
erreur a l'execution ?
pas d'erreur mais le programme fait pas ce que tu veux ?
0