In your case where you have only one button and you don't use the ActionEvent you can simp;ly pass null as ActionEvent
The JButton class has also a doClick() class that simnulates a click in the JButton which will fired the actionPerformed()
For the paintComponent() you can always added the paintComponent at the JPanel creation but I think this is horrible code practice to add execution code in a constructor. Then you can call repaint() in your panel. You cannot just invent a Graphics object as you do and call directly paintComponent().
panel = new JPanel() {
public void paintComponent(Graphics g) {
// code
}
};
}
panels[0].repaint();

New Topic/Question
Reply




MultiQuote



|