import OOPLS.CompleteGraphPanel;
import java.awt.BorderLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class CGClient extends JFrame 
                      implements ActionListener {
    Point DEFAULTBASE = new Point(50,50);
    final int DEFAULTWIDTH = 500, DEFAULTHEIGHT = 500, 
              MAXVERTICES = 50, MINVERTICES = 3;
    Random rnd = new Random();
    JButton randomizeButton = new JButton("Randomize");
    CompleteGraphPanel cgPanel = new CompleteGraphPanel(8);
    public CGClient() {
        initComponents();
    }
    private void initComponents() {
        setDefaultCloseOperation(
            WindowConstants.EXIT_ON_CLOSE);        
        setBounds(DEFAULTBASE.x,DEFAULTBASE.y,
            DEFAULTWIDTH,DEFAULTHEIGHT);
        getContentPane().add(cgPanel);
        randomizeButton.addActionListener(this);
        getContentPane().add(
            randomizeButton,BorderLayout.SOUTH);
    }
    public void actionPerformed(ActionEvent e) {
        cgPanel.setNumVertices(
            Math.abs(rnd.nextInt()) 
            % (MAXVERTICES - MINVERTICES + 1) + MINVERTICES);
        cgPanel.repaint();
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CGClient().setVisible(true);
            }
        });
    }    
}
