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
|
helpP = new JPanel();
helpP.setLayout(new GridBagLayout());
help_tp = new JTextPane();
StyledDocument doc = help_tp.getStyledDocument();
Style defaut = help_tp.getStyle("default");
MutableAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
StyleConstants.setForeground(defaut, Color.red);
doc.setParagraphAttributes(0, 0, center, true);
help_tp.setText("Le debut\n");
help_tp.setForeground(Color.RED);
StyleConstants.setForeground(defaut, Color.red);
String s1 = "Affichage du texte";
try {
doc.insertString(9, s1, defaut);
} catch (BadLocationException e) {
}
help_tp.setEnabled(false);
Layout.constrain(helpP, help_tp, 1, 1, 1, 1, java.awt.GridBagConstraints.NONE,
java.awt.GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
this.setLayout(new GridBagLayout());
Layout.constrain(this, helpP, 0, 0, 1, 1, java.awt.GridBagConstraints.HORIZONTAL,
java.awt.GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
} |
Partager