Rectangle is not drawn on top
问题 I have a class "Map" which extends JPanel. I add it to a class that extends a JFrame. public void paintComponent(Graphics g) { super.paintComponent(g); int width = Math.abs(startX - endX); int height= Math.abs(startY - endY); g.setColor(Color.RED); g.fillRect(startX, startY, width, height); } My class "Map" also contains a label with an image in it. If the image is smalled than the window, when I draw a rectangle it is seen. In short, it is under the label. 回答1: paintComponent is the "bottom"