Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

help finding error?

Peace.
hi everybody ..I 'm a new beginner with java .. I 'm used to work with C++..
well I try to compile thi simpe application using awt and swing package..but I4 ve got many errors (almost all the declaration was signaled as
expected)

it s about creating a 2 panel one with composant(button..) an the other to draw on it
*********************************************************
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

class Appdess extends JFrame implements ActionListener{

private JButton ok;
private JTextField larg;
private JTextField longr;
private JCheckBox oval,rect;
private JComboBox col;
private JLabel dim;
private JPanel pancom;
private PanelDess pandess;
static public final String[] nomCouleur={"rouge","vert","jaune","bleu"};
static public final Color[] Couleur={Color.red,Color.green,Color.yellow,Color.blue};

//the class PanelDess

public class PanelDess extends JPanel{

private int index;
private int longueur=5,largeur=5;
private Boolean boval=false,brect=false;

public void paintComponent(Graphics g){

super.paintComponent(g);
if(boval) g.drawOval(10,10,10+largeur,10+longueur);
if(brect) g.drawRect(10,10,10+largeur,10+longueur);
setBackground(Appdess.Couleur[index]);

public void setOval(Boolean b){boval=b;}
public void setRect(Boolean b){brect=b;}
public void setLarg(int l){largeur=l;}
public void setLong(int l){longueur=l;}
public void setIndex(int l){index=l;}

}

}

public Appdess(){
setSize(340,260);
setTitle("application Dessin");
setVisible(true);
Container c=getContentPane();
ok=new JButton ("click");
ok.addActionListener(this);
larg=new JTextField(5);
longr=new JTextField(5);
dim=new JLabel ("Dimension");
oval=new JCheckBox("Ovale");
rect=new JCheckBox("Rectangle");
col=JComboBox(nomCouleur);
pancom=new JPanel();
pandess=new PanelDess();
pancom.add(col);
pancom.add(dim);
pancom.add(larg);
pancom.add(longr);
pancom.add(oval);
pancom.add(rect);
pancom.add(ok);
c.add(pandess);
c.add(pancom,"South");
}

public void actionPerformed(ActionEvent ev){

int lrg=Integer.paresInt(larg.getText());
int lng=Integer.paresInt(longr.getText());
pandess.setLarg(lrg);
pandess.setLong(lng);
pandess.setOval(oval.isSelected());
pandess.setRect(rect.isSelected());
pandess.setIndex(col.getSelectedIndex());
pandess.repaint();
}

public static void main(String[] agrs){
new Appdess();
}

}

**********************************************************
if someone could help me!!
thanks
[2837 byte] By [peace_comp] at [2007-11-11 11:59:53]
# 1 Re: help finding error?
oups!!! I found it
just forget to close the paintComponent fct ... Sorry Sorry
peace_comp at 2007-11-11 22:30:20 >