1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public void verificationTabbed(int courantPosition){
JTextPane temp=null;
boolean verification=false;
try{
for(int i=0;i<jTabbedPane1.getComponentCount()-1;i++){
System.out.println("titre jtabbed panel"+jTabbedPane1.getTitleAt(i));
System.out.println("jlist="+jList1.getModel().getElementAt(courantPosition));
if(jTabbedPane1.getTitleAt(i).equals(jList1.getModel().getElementAt(courantPosition))){
verification=true;
temp=(JTextPane)jTabbedPane1.getComponentAt(i);
String texteAncien=temp.getText();
String nouveau;
if(texteAncien.equals("")){
nouveau=_messageRecu;
}
else{
nouveau=texteAncien+"\n"+_messageRecu;
}
if(!_messageRecu.equals("")){
temp.setText(nouveau);
jTabbedPane1.setComponentAt(i, temp);
}
}
else{
}
}
if(verification==false){
JTextPane textPane=new JTextPane();
textPane.setText(_messageRecu);
jTabbedPane1.add((String)(jList1.getModel().getElementAt(courantPosition)), textPane);
initTabComponent((jTabbedPane1.getTabCount())-1);
}
}catch(IndexOutOfBoundsException e){
System.out.println("erreur e="+e);
e.printStackTrace();
}
_messageRecu="";
} |
Partager