public class FileView extends JPanel {
private ModelInterface model;
private JTextPane textPane = new JTextPane();
// creating TextPane
public FileView(ModelInterface model) {
this.model = model;
add(textPane);
refreshFile();
}
...
// thats how I append new lines to the TextPane. TextPane can also be modified from client view
private void appendToPane(JTextPane textPane, String msg, Color c)
{
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);
int len = textPane.getDocument().getLength();
textPane.setCaretPosition(len);
textPane.setCharacterAttributes(aset, false);
textPane.replaceSelection(msg);
}
}
public class FileView extends JPanel {
private ModelInterface model;
private JTextPane textPane = new JTextPane();
// creating TextPane
public FileView(ModelInterface model) {
this.model = model;
add(textPane);
refreshFile();
}
...
// thats how I append new lines to the TextPane. TextPane can also be modified from client view
private void appendToPane(JTextPane textPane, String msg, Color c)
{
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);
int len = textPane.getDocument().getLength();
textPane.setCaretPosition(len);
textPane.setCharacterAttributes(aset, false);
textPane.replaceSelection(msg);
}
}