Prova questo (ridimensiona anche la finestra e guarda cosa succede):

codice:
import java.awt.*;
import javax.swing.*;

public class TestFrame extends JFrame
{
    public TestFrame ()
    {
        super ("Test Frame");

        setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        setSize (300, 300);

        getContentPane ().add (new SinusoidPanel ());
    }

    public static void main (String[] args)
    {
        SwingUtilities.invokeLater (new Runnable ()
        {
            public void run ()
            {
                TestFrame f = new TestFrame ();
                f.setVisible (true);
            }
        });
    }
}

class SinusoidPanel extends JPanel
{
    public void paintComponent (Graphics g)
    {
        super.paintComponent (g);

        int width = getWidth ();
	int height = getHeight ();
	int c = height/2;

	for (int x = 0; x < width; x++)
	{
            int y = (int) (c * Math.sin (x/200.0 * 2*Math.PI));
            g.drawLine (x, c, x, c+y);
        }
    }
}