I am writing a application.and i need to draw line in jpanel.but it is crash when jpanel add to jframe.this is my code:

public class Simplification extends JFrame
    JPanel panel;
    public Simplification(List<List<Integer>> transmitionTable , List<List<Integer>> outTable)
        this.setTitle("Simplification Result");
        this.setSize(500, 300);
        this.setLocation(50, 50);

        // do other jobs 
        panel = new JPanel()
            protected void paintComponent(Graphics g)
                g.drawLine(0, 0, 11, 11);               

Interesting bug...
in paintComponent you call super.paint, which in turn calls the paint mathods for the various parts of the JFrame, including a call to paintComponent. That's a recursive loop. You should be calling super.paintComponent

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.