import javax.swing.*;
import javax.swing.text.*;
import de.jal.moviecollector.language.LanguageConstants;
public class MovieInfoJTextPane extends JTextPane
{
private static final long serialVersionUID = 1L;
private final String newLine = "\n", regular = "regular", bold = "bold";
private final String[] constantText = { LanguageConstants.getValue("NAME_MOVIE")+this.newLine,
LanguageConstants.getValue("DIRECTOR")+this.newLine,
LanguageConstants.getValue("ACTORS")+this.newLine,
LanguageConstants.getValue("RELEASE_YEAR")+this.newLine,
LanguageConstants.getValue("OWN_INFO")+this.newLine
};
private final int textSize = 13;
private StyledDocument doc;
/**
*
*/
public MovieInfoJTextPane()
{
this.init();
}
/**
*
*/
private void init()
{
this.setBackground(Color.LIGHT_GRAY);
this.setEditable(false);
this.doc = this.getStyledDocument();
this.addStylesToDocument(this.doc);
this.setDefaultValues();
}
/**
*
*/
public void setDefaultValues()
{
try
{
this.doc.remove(0, this.doc.getLength());
for(int i=0; i<this.constantText.length; i++)
{
this.doc.insertString(this.doc.getLength(), this.constantText[i],
this.doc.getStyle(this.bold));
this.doc.insertString(this.doc.getLength(), this.newLine,
this.doc.getStyle(this.regular));
}
}
catch (BadLocationException ble)
{
ble.printStackTrace();
}
}
/**
*
*/
private void addStylesToDocument(StyledDocument _doc)
{
Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
Style regular = _doc.addStyle(this.regular, def);
StyleConstants.setForeground(regular, Main_Default.INFO_TEXTPANE_COLOR);
StyleConstants.setFontFamily(def, "SansSerif");
Style s = _doc.addStyle(this.bold, def);
StyleConstants.setBold(s, true);
StyleConstants.setFontSize(s, this.textSize);
StyleConstants.setUnderline(s, true);
}
}