1 Reply Latest reply on Sep 26, 2007 12:47 PM by 843807

    draw a line on a JFrame

      I have 2 panels inside a JFrame and I want to separate the 2 panels using a visible line. How can I draw this line?
        • 1. Re: draw a line on a JFrame
          You will need to over ride the paint(Graphics g) method.

          From there you can use the g.drawLine(startX,startY,endX,endY). So for instance if you had two panels next to each other and the line is a vertical line then you would do something similar to this.
          public void paint(Graphics g){
                  int x = this.jPanel1.getWidth();
                  g.drawLine(x, 0, x, this.getHeight());
          This is probably a good place to start learning java2d