SortGraphics(){
		
		JFrame frame = new JFrame("Sorting Algorithms");

		canvas.setForeground(Color.black);
		canvas.setBackground(Color.white);
		Sort.setPointNumber(300);  // calls init

		frame.getContentPane().add(canvas);
		frame.getContentPane().validate();
        
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
		frame.setSize(400,450);
        
		JMenuBar menubar = new JMenuBar();
        
		JMenu initMenu = new JMenu("Initialization");
        
		JMenuItem randomItem = new JMenuItem("Random");
		JMenuItem randomUniqueItem = new JMenuItem("Random, unique");
		JMenuItem backwardsItem = new JMenuItem("Sorted, decreasing");
		JMenuItem sortedItem = new JMenuItem("Sorted, increasing");
		JMenuItem reuseItem = new JMenuItem("Start over without init");
        
		initMenu.add(randomItem);
		initMenu.add(randomUniqueItem);
		initMenu.add(backwardsItem);
		initMenu.add(sortedItem);
		initMenu.add(new JSeparator());
		initMenu.add(reuseItem);
		
		randomItem.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {
			Sort.initRandom(new Random().nextInt() );
			Dimension d = canvas.getSize();
			if( d == null ) return;
			canvas.repaint(0,0,d.width,d.height);
		   }
		});
		randomUniqueItem.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {
			// TODO: initRandomUnique not implemented yet!!
			Sort.initRandom(new Random().nextInt() );
			Dimension d = canvas.getSize();
			if( d == null ) return;
			canvas.repaint(0,0,d.width,d.height);
		   }
		});
		backwardsItem.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {
			Sort.initBackwards();
			Dimension d = canvas.getSize();
			if( d == null ) return;
			canvas.repaint(0,0,d.width,d.height);
		   }
		});
		sortedItem.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {
			Sort.initSorted();
			Dimension d = canvas.getSize();
			if( d == null ) return;
			canvas.repaint(0,0,d.width,d.height);
		   }
		});
		reuseItem.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {
			Sort.initOldNumbers();
			Dimension d = canvas.getSize();
			if( d == null ) return;
			canvas.repaint(0,0,d.width,d.height);
		   }
		});

		sortMenu = new JMenu("Sorting Algorithms");
		
		JMenuItem stopSort = new JMenuItem("Stop Sorting");
		sortMenu.add(stopSort);
		
		stopSort.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {
			if( sortT == null ) return;
			sortT.stop();  // destroy the current thread
		   }
		});		

		sortMenu.add(new JSeparator());

		menubar.add(initMenu);
		menubar.add(sortMenu);
        
		frame.setJMenuBar(menubar);
        
		frame.pack();
		frame.setVisible(true);   

	}