Reputation: 357
i have two panels: pnl and pnl2, pnl2 has a label named car added to it (pnl2.add(car);). i changed layout manager of pnl to border layout and add pnl2 to its south (pnl.add(pnl2, BorderLayout.SOUTH);). pnl itself is added to a frame named GameFrame which extends JFrame (this.add(pnl);).
pnl2 is a normal JPanel, but pnl is of class i made named Road which extends JPanel, in this class i overrided paint method to draw specific objects (white rectangles at different positions), and in the constructor of the frame GameFrame i am using timer to repaint pnl every specific delay to produce an animation (moving white rectangles).
everything is working well but the white rectangles are always drawn on the top of the label named car, is there a way to make this car label always be on the top ?
Upvotes: 0
Views: 185
Reputation: 285403
Suggestions:
Upvotes: 1