public class Sistemas extends Frame implements ActionListener {
Label label1;
Label label2;
Label label3;
Label label4;
Label label5;
Label label6;
Label label7;
Label bar;
TextField textfield1;
TextField textfield2;
Choice choice1;
Button button1;
Button button2;
Button button3;
int x;
MenuBar barra;
Menu m1;
MenuItem m1Item1;
int Win98;
int WinXP;
int Linux;
Sistemas()
{
x=0;
Win98=0;
WinXP=0;
Linux=0;
setLayout(null);
barra = new MenuBar ();
setMenuBar (barra);
m1 = new Menu ("Sistema Operativo");
barra.add (m1);
m1Item1 = new MenuItem (" INFO");
m1.addActionListener(this);
m1.add (m2Item1);
label1 = new Label("Nombre de Usuario",Label.CENTER);
label1.setBounds(32,56,120,24);
label2 = new Label("Clave",Label.CENTER);
label2.setBounds(32,112,91,20);
label3 = new Label("Window 98",Label.CENTER);
label3.setBounds(144,180,91,20);
label4 = new Label("Window XP",Label.CENTER);
label4.setBounds(144,240,91,20);
label5 = new Label("Linux",Label.CENTER);
label5.setBounds(144,298,91,20);
label6 = new Label("Tipo de Usuario",Label.CENTER);
label6.setBounds(332,48,91,20);
label7 = new Label("Correcto/Incorrecto",Label.CENTER);
label7.setBounds(330,272,110,20);
bar = new Label("0");
bar.setBounds(100,190,40,120);
//bar.setBackground (Color.red);
//bar.setForeground (Color.red);
textfield1 = new TextField("");
textfield1.setBounds(152,56,90,25);
textfield2 = new TextField("");
textfield2.setBounds(152,104,90,25);
choice1 = new Choice();
choice1.setBounds(320,88,112,24);
button1 = new Button("^");
button1.setBounds(40,208,32,24);
button2 = new Button("v");
button2.setBounds(40,256,32,24);
button3 = new Button("Conectar");
button3.setBounds(344,216,75,25);
choice1.add("--------");
choice1.add("Administrador");
choice1.add("Juanita la loca");
choice1.add("Localhost");
add(label1);
add(label2);
add(label3);
add(label4);
add(label5);
add(label6);
add(label7);
add(bar);
add(textfield1);
add(textfield2);
add(choice1);
add(button1);
add(button2);
add(button3);
button1.addActionListener (this);
button2.addActionListener (this);
button3.addActionListener (this);
m1Item1.addActionListener (this);
m1Item3.addActionListener (this);
CerrarVentana fin = new CerrarVentana();
addWindowListener(fin);
EscucharTeclado te = new EscucharTeclado ();
addKeyListener (te);
button1.addKeyListener(te);
button2.addKeyListener(te);
button3.addKeyListener(te);
}
public void actionPerformed (ActionEvent e)
{
if ( e.getSource()==button3)
{
String s1=textfield1.getText();
String s2=textfield2.getText();
String s3=choice1.getSelectedItem();
if(s1.equalsIgnoreCase("xxxx")&& s2.equalsIgnoreCase("xxxx") && s3.equals("Administrador") )
{
label7.setText("Correcto");
}
else
{
label7.setText("Incorrecto");
}
}
if (e.getSource () == button1)
{
if (x < 30)
{
x=x+20;
Linux++;
Win98++;
WinXP++;
label2.setText(String.valueOf(Win98));
bar.setText (String.valueOf (x));
repaint ();
}
}
if (e.getSource () == button2)
{
if (x > 0)
{
x=x-20;
bar.setText (String.valueOf (x));
repaint ();
}
}
if(e.getSource() == m1Item1)
{
Sistemas2 j2 = new Sistemas2(this,Win98,WinXP,Linux);
j2.setBounds(100,100,400,200);
j2.show();
}
if( e.getSource()== buttonA)
System.exit(1);
}
public void paint (Graphics g)
{
g.drawLine (90 , 312 -x*3 , 130 , 312 - x *3 );
}
public class CerrarVentana extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
d.show();
}
}
public class EscucharTeclado extends KeyAdapter
{
public void keyPressed (KeyEvent k)
{
if (k.getKeyText (k.getKeyCode ()).equals ("Escape"))
System.exit (0);
}
}
ahora de donde llamo a Sistemas2
if(e.getSource() == m1Item1)
{
Sistemas2 j2 = new Sistemas(this,Win98,WinXP,Linux); // aqui es donde me da el error deberia de recojerme los valores del acumulador
j2.setBounds(100,100,400,200);
j2.show();
} |