En fait j'ai quelque probleme pour mettre un style precis sur mon document. J'ai creer un SimpleAttributeSet et l'initialise avec les styles que je souhaite, j'essaye de l'appliquer a mon document mais ca marche pas, je debute donc j'ai un peu de mal...
Je joint mon code pour voir si vous trouver la betise que j'ai du ecrire,
pour l'instant j'essaye juste d'applique le style a un String.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
40
41
42
43
44
45
46
47
public static void main(String[] args)
  {
//	  Color[] patColors={Color.PINK,Color.RED,Color.GREEN,Color.BLUE,Color.ORANGE,
//			  Color.CYAN,Color.MAGENTA,Color.YELLOW,Color.LIGHT_GRAY};
 
 
    //create style and font
	  	SimpleAttributeSet textStyle = new SimpleAttributeSet();
	  	//Font seqFont=new Font("TimesRoman",Font.PLAIN,10);//set new font
	  	//Color col_stats_bg=new Color(255,240,210);//bkgnd color of stats pane
	  	StyleConstants.setFontFamily(textStyle,"Courier");
	  	StyleConstants.setFontSize(textStyle,16);
	  	StyleConstants.setForeground(textStyle,Color.RED);
 
 
  	// create a document
    DefaultStyledDocument doc = new DefaultStyledDocument();
    doc.setCharacterAttributes(0, 10, textStyle, false);
	  try
	  {
	    doc.insertString(0,"jkhvkmimimimimijhvkjvh",textStyle);
	    doc.setCharacterAttributes(0,doc.getLength(),textStyle,true); 
	  }
	  catch(BadLocationException ble)
	  { System.err.println("Could not insert text ..... "+ble);
	  }
 
 
    Display_MEME_Output2 testApp = new Display_MEME_Output2();
    testApp.setEditable(false);
    testApp.setAutoscrolls(true);
    testApp.setDocument(doc);
    testApp.setCaretPosition(0);
    testApp.setMargin(new Insets(10,10,10,10));
 
    JScrollPane scroll = new JScrollPane(testApp,
        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
        JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
 
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(scroll);
    frame.getContentPane().add(testApp.getSouthPanel(),"South"); //add SAVE button
    frame.setSize(PIXEL_WIDTH/2,PIXEL_HT);
    frame.setLocation(200,200);
    frame.setVisible(true);
  }