How to absolutely position a JPanel over another JPanel with setLayout(null) and a background image?
问题 I'm working with JFrames in Java, specifically with absolutely positioned elements that need to overlap. I understand that to overlay components, one should make a JPanel (with setOpacity(false); ), and position it with either setBounds(x,y,x2,y2); or setPosition(x,y) & setSize(x,y) . Unfortunately the panels act like CSS's inline-divs ; they take up only the needed amount of room on their line, and do not stack. This is the code I have so far, but it doesn't seem to act like I'd imagine it