CIB jrec2 technischer Leitfaden
7. Einbindung des CIB jrec2 in Java Swing-Applikation
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import de.cib.gui.framework.ICibApplication;
import de.cib.gui.framework.ICibRecApplication;
import de.cib.jrec2.JCibRec2;
public class MyRecTest extends JFrame {
private static final long serialVersionUID = 1L;
public static final String TEST_FILENAME = "c://tmp//rtf_data.rtf";
JCibRec2 m_cibRec;
public MySwingRecTest() {
m_cibRec = new JCibRec2();
JPanel recPanel = new JPanel();
recPanel.add(m_cibRec);
getContentPane().add(recPanel);
m_cibRec.setPreferredSize(new Dimension(650, 200));
// set standard formatting
initDocumentAttributes();
// set input file (optional)
m_cibRec.setProperty(ICibApplication.PROPERTY_INPUTFILE, TEST_FILENAME);
m_cibRec.setProperty(ICibApplication.PROPERTY_TITLE, "CIB JRec2 integriert in Swing");
// Keine Ini-Datei schreiben
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_JREC_INIFILENAME, null);
// Write default font size
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_WRITE_DEFAULTFONTSIZE,
Boolean.TRUE);
// Set list of allowed fonts
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_ALLOWED_FONT_LIST,
"Times New Roman; Arial; Frutiger VR; Papyrus");
// Enable hyphenation
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_HYPHENATION_ENABLED, Boolean.TRUE);
// Set hyphenation dictionary path
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_HYPHENATION_DICTIONARY_PATH, "./lib/dict/");
// Enable spell checking
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_SPELLCHECKING_ENABLED, Boolean.TRUE);
// Set spell checking dictionary path
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_SPELLCHECKING_DICTIONARY_PATH, "./lib/dict/");
// Set spell checking native library path - it must be absolute
m_cibRec.setProperty(ICibRecApplication
.PROPERTY_SPELLCHECKING_NATIVE_LIBRARY_PATH,
"D:/Products/CIB jrec2/lib/win32/");
// Set spell checking language
m_cibRec.setProperty(
ICibRecApplication.PROPERTY_SPELLCHECKING_LANGUAGE, "de_DE");
// set other Properties
//...
// jrec start and load
m_cibRec.start();
m_cibRec.load();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setLocation(200, 50);
setResizable(false);
pack();
}
// set standard formatting
private void initDocumentAttributes() {
m_cibRec.setProperty(ICibRecApplication
.PROPERTY_DEFAULT_FONT_FAMILY, "Courier New");
m_cibRec.setProperty(ICibRecApplication
.PROPERTY_DEFAULT_FONT_SIZE, new Integer(8));
}
public static void main(String[] args)
{
MySwingRecTest recTest = new MySwingRecTest();
recTest.setVisible(true);
}
}
Die Funktion initDocumentAttributes() zeigt beispielhaft, wie Sie die standardmäßige Schriftart und Schriftgröße für das Dokument setzen können.