How do I repaint the farthest right card last and the left most first so the overlapping will reverse?
So I have a JPanel in flowlayout which contains JButtons. I want to emulate the feel of holding cards in hand, so I overlapped the JButtons. The problem is that the overlapping of the images of the JButtons is so that the numbers only appear at the bottom right corner, where I want them to be top left. This is what I have now:
ZOrdering didn't work, it only reversed the order of the cards (ace on other side, king first, etc). What I want is to repaint the farthest right card last and the left most first so the overlapping will reverse.
Edit: The code for constructing the hand:
hand= new JPanel();
hand.setLayout(new FlowLayout(FlowLayout.CENTER, -45, 0));
hand.setOpaque(false);
for(int i=0; i<p1.getHand().size(); i++){
JButton te=new JButton();
//button customization, icons and such
te.addActionListener(this);
//here I tried the ZOrdering that didn't work
//hand.setComponentZOrder(te, 0)
hand.add(te);
}
this.add(hand);
}
//yes, the setBounds is long and weird
hand.setBounds(WINDW/2-((p1.getHand().size())*CARDWHAND*2/5), WINDH-CARDHHAND-30, p1.getHand().size()*CARDWHAND*4/5+50, CARDHHAND+30);
this layout manager is null