add random sentence

This commit is contained in:
Orange 2016-11-14 17:33:12 +01:00
parent 742dc8a1be
commit 21af98e43f
3 changed files with 22 additions and 4 deletions

View File

@ -0,0 +1,13 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.util.Random;
public class NoListener implements ActionListener{
public void actionPerformed(ActionEvent event){
Random rand = new Random();
String str[] = {"Hai condannato la tua gente alla miseria", "Populista di sto c@zzo", "L'apocalisse è vicina"};
JOptionPane.showMessageDialog(null, str[rand.nextInt(3)]);
}
}

View File

@ -49,7 +49,9 @@ public class Referendum {
scheda.add(voto, BorderLayout.SOUTH);
frame.add(scheda);
ActionListener listener = new SiListener();
si.addActionListener(listener);
ActionListener siListener = new SiListener();
ActionListener noListener = new NoListener();
si.addActionListener(siListener);
no.addActionListener(noListener);
}
}

View File

@ -1,8 +1,11 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.util.Random;
public class SiListener implements ActionListener{
public void actionPerformed(ActionEvent event){
System.out.println("Hai votato si");
}
Random rand = new Random();
String str[] = {"Grazie per aver venduto la sovranità popolare", "Radical chic di sto c@zzo", "Sei appena entrato in dittatura"};
JOptionPane.showMessageDialog(null, str[rand.nextInt(3)]); }
}