import java.awt.*; import java.awt.event.*; public class TransformationDialog extends Dialog implements ActionListener { private String selection = null; private Button s1,s2,s3,s4; public TransformationDialog(Frame f) { super(f,"Select the piece",true); //modal dialog setSize(240,80); setLocation(400,0); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().setVisible(false); System.exit(0); } } ); //make closeable setLayout(new GridLayout(1,4)); s1 = new Button("queen"); s2 = new Button("rook"); s3 = new Button("bishop"); s4 = new Button("knight"); s1.addActionListener(this); s2.addActionListener(this); s3.addActionListener(this); s4.addActionListener(this); add(s1); add(s2); add(s3); add(s4); //setVisible(true); } public String getSelection() {return selection;} public void actionPerformed(ActionEvent e) { if (e.getSource() == s1) selection = "queen"; else if (e.getSource() == s2) selection = "rook"; else if (e.getSource() == s3) selection = "bishop"; else if (e.getSource() == s4) selection = "knight"; else return; setVisible(false); } }