Reputation: 159
I have problem ; / I set in global variable :
public static boolean wystawianie;
On other button i set to this variable true. But this if dont see this true/false... This code do always :
JOptionPane.showMessageDialog(null, "Faktura została wystawiona poprawnie");
dispose();
Kod:
public void actionPerformed(ActionEvent e)
{
if(zmienne.wystawianie = true)
{
JOptionPane.showMessageDialog(null, "Faktura została wystawiona poprawnie");
dispose();
}
else
{
try
{
String url = "jdbc:mysql://localhost:3306/faktury";
String userid = "root";
String password = "w4t3q99j";
Connection conn= DriverManager.getConnection( url, userid, password );
Statement stmt = conn.createStatement();
String sql = "DROP DATABASE "+zmienne.a+"";
stmt.executeUpdate(sql);
System.out.println("usuniete");
}
catch(Exception e3)
{
System.out.println(e3);
}
JOptionPane.showMessageDialog(null, "Faktura została nie zapisana");
dispose();
}
}
});
Anyone know why ? ^^
Upvotes: 0
Views: 186
Reputation: 68715
You are doing assignment(single=) instead of comparison(==) here:
if(zmienne.wystawianie = true)
Change it to:
if(zmienne.wystawianie == true)
Upvotes: 0
Reputation: 19284
This statement:
if(zmienne.wystawianie = true)
sets the value of zmienne.wystawianie
to true.
You should use:
if(zmienne.wystawianie)
instead.
Upvotes: 1