Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

why doesnt work this program??????? pls help

lwiqlwiq Posts: 15Member
i dont know how to do in class autentificare (variable logat) so this variable returne true after i press the button. the programm is::

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class autentificare extends JFrame implements ActionListener
{
JButton b1 = new JButton("Log In");
JTextField text1 = new JTextField(10);
JPasswordField psw1 = new JPasswordField();
JLabel labelUser = new JLabel("user: ");
JLabel labelPsw = new JLabel("parola: ");
boolean logat1=false;

public autentificare(JButton b2,JLabel user, JTextField text2, JLabel parola, JPasswordField psw2,boolean logat)
{
b1=b2;
text1=text2;
psw1=psw2;
labelUser=user;
labelPsw = parola;
logat=logat1;

JFrame frame = new JFrame("AUTENTIFICARE!!!");
frame.setLayout(null);
JPanel panou = new JPanel();
frame.getContentPane().setLayout(new FlowLayout());
frame.setContentPane(panou);
panou.add(b2);
panou.add(labelUser).reshape(100,100,80,30);
panou.add(text2);
panou.add(labelPsw);
panou.add(psw2);
b2.addActionListener(this);

frame.setSize(300,200);
frame.setResizable(false);
frame.setVisible(true);
}

public void actionPerformed(ActionEvent e)
{
System.out.println("hello");
logat1=true;
}
}

public class frame4 extends JFrame
{
public frame4(String titlu)
{
super(titlu);
}

public static void main(String args[])
{
JLabel labelUser = new JLabel("utilizator: ");
JTextField user = new JTextField(10);
JLabel labelParola = new JLabel("parola: ");
JPasswordField psw = new JPasswordField(10);
JButton b = new JButton("Log In");
boolean show = false;

frame4 aplicatie = new frame4("Baza de date");
JPanel panou = new JPanel();
JButton buton = new JButton("Click me");
aplicatie.getContentPane().setLayout(null);
aplicatie.setContentPane(panou);
panou.getAccessibleContext().setAccessibleName("vali");
panou.add(buton);
buton.reshape(30,80,80,30);
aplicatie.setSize(400,400);
aplicatie.show();
autentificare login = new autentificare(b,labelUser, user,labelParola,psw,show);
System.out.println(show);
labelUser.reshape(30,40,60,20);
user.reshape(120,40,140,20);
user.setFocusable(true);
labelParola.reshape(30,60,70,20);
psw.reshape(120,70,140,20);
b.reshape(100,100,80,30);
}
}

Sign In or Register to comment.