am try to call paint in action perform but it not work
btnNewButton_5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
class MyCanvas extends JComponent {
public void paint(Graphics g) {
g.drawLine(10,20,50,60);
}
}
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setBounds(30, 30, 300, 300);
window.getContentPane().add(new MyCanvas());
window.setVisible(true);
}
});
problem is it show only frame but rectangle doesn't draw
how can i edit this code help me