Probleme en java
saif87
Messages postés
131
Statut
Membre
-
mype Messages postés 2449 Statut Membre -
mype Messages postés 2449 Statut Membre -
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.
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:
- Probleme en java
- Jeux java itel - Télécharger - Jeux vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Waptrick java voiture - Télécharger - Jeux vidéo
- Eclipse java - Télécharger - Langages
- Java apk - Télécharger - Langages
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);
}*/
}
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 ?