Here is my problem: I have a JPannel Order, in which I have different components; one JTable, and a few JLabel.
These components are filled with datas coming from an object "commande"(order)ex: idOrder, customer, Price...
This JPannel is inside an other Jpanel which contains also a jtable (orderlist)
When I click on an order in the jtable orderlist, I want the information about this order to be printed on the jpannel Order.
Now, I click, my object order is updated correctly but I cannot do the repaint() of the JPannel. Nothing happens.
Here is the code
public class PanneauDetailCommande extends JPanel{
Commande commande;
PanneauDetailCommande(){}
public void setCommande(Commande commande){this.commande=commande;}
public void paintComponent(Graphics g){
String colorPaye=commande.isPaye()? "GREEN" : "RED";
this.setBackground(Color.white);
this.setBorder(BorderFactory.createLineBorder(Color.black));
this.setPreferredSize(new Dimension(600,300));
JLabel labelDetail=new JLabel("<html><p style=\"padding-left:15px;\"><font size=4 > Détail commande<font color=\""+colorPaye+"\" size=4 > No "+(commande.getIdCommande())+"</font> :</font></p></html>");
labelDetail.setPreferredSize(new Dimension(598,20));
labelDetail.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black));
labelDetail.setOpaque(true);
labelDetail.setBackground(Color.white );
this.add(labelDetail);
}}
Another class JPannel which calls JPannel detailCommande:
historique.table.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
@Override
public void valueChanged(ListSelectionEvent e) {
// TODO Auto-generated method stub
int newId=Integer.parseInt(historique.table.getValueAt(historique.table.getSelectedRow(), 0).toString());
Commande newCommande = gestionCommande.getCommande(newId);
detail.setCommande(newCommande);
detail.repaint();
}});