2017-06-30 2 views
0

comment casser la chaîne à chaque 100e caractères dans Jlable. j'ai essayécomment adapter Large String dans jLabel

String str = "rgwueiiiiiiiiiiiiiiiiiiiiiigthytjtjhyfghgfthythtyrhyrhythryhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiithurgtihiugtgoeim9yv8umv9,u,j89,9v8juv98yliv9ki9kj9bjj9iki9hkiykhvivjkinv"; 
    String parsedStr = str.replaceAll("(.{100})", "$1\n"); 
    System.out.println(parsedStr); 
    jLable1.getPreferredSize(); 
    jLable1.setText(str); 

chaîne est brisée. mais il ne montre pas en Jlable comme cassé

+1

Essayez HTML: 'jLabel.setText ("" + str);' –

+1

a résolu le problème .. en utilisant jLabel.setText ("" + parsedStr + "
"); merci d'ailleurs –

+0

@pawansharma Ajoutez-le comme réponse personnelle;) –

Répondre

0

Je l'ai résolu en utilisant

String str = "rgwueiiiiiiiiiiiiu  j89,9v8juv98yliv9ki9kj9bjj9iki9hkiykhvivjkinv"; 
    String parsedStr = str.replaceAll("(.{50})", "$1\n"); 
    System.out.println(parsedStr); 

    text.setText("<html>"+parsedStr+"<br/></html>"); 

By The Way Thanx