2 つの JPanel の間に線を引きたい。"g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);" で NULL ポインター例外が発生するので、私のコードを確認してください。
コード::
Draw(JPanel one , JPanel two)
{
//Draw Line
Graphics2D g=null;
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.lightGray);
2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setColor(Color.black);
Stroke s = new BasicStroke(4.0f);
// For getting the points of JPanel ona and two//
int x1 = one.getX() + one.getWidth() / 2;
int y1 = one.getY() + one.getHeight() / 2;
int x2 = one.getX() + one.getWidth() / 2;
int y2 = two.getY() + two.getHeight() / 2;
//Drawing line
g2d.drawLine(x1, y1, x2, y2);
}