Java - MouseListener Action Event in paintComponent
问题 Here i have a code which draws a rectangle on the mouseClicked position using the paintComponent.I can get the output message but anything related to graphics and .draw() wont work. Code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public final class testclass extends JFrame { static JPanel p; Timer t; int x = 1; int y = 1; int xspeed = 1; int yspeed = 1; public testclass() { initComponents(); this.setBounds(100, 300, 500, 500); this.setDefaultCloseOperation(JFrame.EXIT