Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Give me example of drawline into child component of frame

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to draw line into child component of frame, not directly into frame. Thanks
 
import java.awt.*;
import javax.swing.*;

public class drawLineDemo extends JFrame
{
public drawLineDemo()
{
getContentPane().setLayout(null);
setSize(200,200);

drawLinePanel dlp = new drawLinePanel();
dlp.setBounds(new Rectangle(10,10,50,50));

getContentPane().add(dlp,null);

repaint();
}

public static void main(String[] args)
{
drawLineDemo dld = new drawLineDemo();
dld.show();
}
}

class drawLinePanel extends JPanel
{
public void paintComponent(Graphics g)
{
g.drawLine(10,10,50,10);
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top