RTF Support

Post Author: MGervais
CA Forum: Crystal Reports
I know that a report can display a string value encoded as RTF, but I am wondering what version of RTF is actually supported.  We have reports that print fields containing RTF tags for printing tables with borders.  None of these tags are being printed correctly.
I have tried using CR 8.5 and CR XI and get the same result.
Any ideas?

Post Author: IdoMillet
CA Forum: Crystal Reports
For a description of RTF rendering limitations in Crystal Reports, see:
http://support.businessobjects.com/library/kbase/articles/c2011504.asp

Similar Messages

  • RTF Support in RTFEditor/JEditorPane

    Hi
    Whilst using the RTFEditor to display an RTF file in JEditorPane, I'm find some stuff that doesn't get displayed.
    * Simple tables. These just show the text as if they were words typed next to each other.
    * Hyperlinks. These do not show up at all even as text
    Anyone know if this is normal, or am I likely to be missing something.
    Thanks for your help.
    Nick.

    Hi
    Thanks for your response. I was guessing the support was limited from my results.
    I've tried searching for alternatives, but there doesn't seem to be much else around.
    Since this element of the project is in its early stages, I may just opt for a different format to RTF.
    Regards.
    Nick.

  • HTML, RTF Support...

    the tutorial for printing text in the sun swing tutorials said that several file fromats are supported like HTML, RTF etc...could anyone tell me where i can find the tutorial to print in the supported formats???

    If you can 'print a component', make that component a JEditorPane - which understands/renders HTML & RTF.

  • Will RTF support be included in new iCloud for outlook?

    Since it was disabled with iCloud2 I have waited to an update to get these functions available.
    So far it seems nothing changed. Rtf, HTML, fonts... Nothing.... Only plain text.

    As long as your device will be the default device name (Dev1) in every instance the software will use, you should be fine.  If you use a specific configuration other than the default that you set up in MAX, you will want to add MAX to the installer as well as the MAX configuration for that device.
    www.movimed.com - Custom Imaging Solutions

  • German Special Characters not displayed correctly in RTF  using code

    Hi ,
    In my code we are using webdynpro method
    WDResourceFactory.createResource(
    byte[] data, String resourceName,WDWebResourceType
    Type)
    Here in our code we are implementing this as
    ITemplateElement templateEl = wdContext.currentTemplateElement();
    WDResourceFactory.createResource(
    templateEl.getReportData(),
    reportName.substring(0, reportName.lastIndexOf('.')),
    WDWebResourceType.RTF); reportName.lastIndexOf('.')),
    Here templateEl.getReportData() returns a set of bytes which has some
    german special characters.
    We are generating the Bytes using String.getByes(),Just before
    String text = new String(in);
    collector.putBusinessObject(boName, bo);
    reportDocTemplateParser(collector, text);
    collector.removeBusinessObject(boName);
    String generatedText = collector.generateRTF();
    out = (null != generatedText) ? generatedText.getBytes() : null;
    The out put is the if i am giving a word with german special characters for eg:
    Betriebsübersichten it first gets converted to bytes and then passes through method WDResouseFactory.createResourse(.....) which creates an RTF file and finally in the RTF file it appears as Betriebsbbersichten the special character is not displayed correctly.
    i came to knw that while converting into bytes we have to make it RTF supported encoding.ie for eg generatedText.getBytes('cp1252').i even tried with other charactersets like ISO-8859,cp1253 and so on but none of them worked.
    It would be really great if you could suggest the needful.
    Thanks and Regards
    Neeta

    I soved this by using get_data function of response object. Then converting this into ISO-8859-1 charset.
    See code below.
    DATA :  lv_encoding   TYPE abap_encoding,
              lv_conv       TYPE REF TO cl_abap_conv_in_ce,
              lv_x_string   type xstring.
      lv_x_string = pv_http_client->response->get_data( ).
        lv_encoding = '1100'.
        lv_conv = cl_abap_conv_in_ce=>create(
                              encoding = lv_encoding
                                 input = lv_x_string ).
        lv_conv->read( IMPORTING data = pv_result ).

  • HTML to RTF Convertor

    I've got a number of HTML formatted datafields that users have entered using the APEX text editors (FCK).
    I would like to integrate those fields with a report but the report if not interpreting the HTML very well. As such I'd actually like to convert the HTML to RTF.
    I see a number of commercial DLL's exist for doing this within end applications.
    I'd prefer to actually do this conversion at the database side - has anyone done anything similar? Or have any suggestions for an approach?
    Thanks,
    Scott

    I'm working with Crystal Reports - the report must be customer quality. And the issue surrounds the fact that Crystal only supports limited HTML tags (see http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2014842&sliceId=&dialogID=9876280&stateId=1%200%209874388)
    But it's RTF support is a lot better, hence the desire to convert the HTML to RTF.

  • How to save Pages document as a rtf?

    How to save Pages document as a rtf? There is no option in the export pull down menu on Pages version 5.1. This is possing to be a big problem as an online couse wants documents saved in this format.

    Pages 5.1 is a buggy, crippled disaster. The lack of RTF support comes under the "crippled" rubric.  It lacks about 100 features present in Pages 09. Beware of the buggy stuff, too: there are many reports of data corruption, of users being unable to open files, etc.  Adivse you use Pages 09, or Word.

  • RTF Editor

    I am scanning a fairly complex document, and then do an OCR to RTF format using Omnipage.
    WordPad is insufficient for editing the resulting RTF file. I have also not been successful in using a word processor, and then saving to RTF format, as certain formatting is often lost.
    I looked up the RTF standards, but it is difficicult to make heads or tails of.
    I can't be the first person that has run into this problem, are there certain Editors that people use for creating more complex file layouts than WordPad can handle, or is there a way to tell which formatting you will lose when you save a file in RTF format from Microsoft Word.

    Hi Lee
    The RTF spec is certainly a subset of the MSWord 'doc' format and other Word processors. Its owned by MS but an open format so its up to the individual processor developers as to how much of the spec they implement. MSWord should have the most comprehensive implementation of course.
    There are differences in what RTF supports compared to 'doc' but I have not seen a document from MS highlighting them.
    Tim

  • HT4641 Is there any way to make .rtf files work?

    I didn't notice the lack of .rtf support when I bought it (urgh!), which would make this app perfect for my needs, as half my files are .rtf and I have to actively convert each file one at a time into doc or docx if I want to use them on my ipad 2, and then back again if I want to upload them to the group that prefers .rtf files. Pain-staking process, that. This simple change would be a great feature for an update.

    What kind of parental controls are you talking about? You have full control over standard accounts on your Mac by using the Parental Controls system preference.
    If you're concerned that a child will try to circumvent the controls by changing the admin password using the installation disk, then you can certainly set an EFI password. Follow these instructions.
    Matt

  • Print RTF file within app

    Hi
    Is it possible to print an rtf file from within java app without actually viewing the file on screen? I don`t want to display the file in a jtextpane or jeditorpane. Simply want to print the file like you can with a straight text file.
    Or, is there are a command line switch to print a rtf file? through ms word?
    Any help would be appreciated.
    Thanks
    Kelly

    printing RTF files from java is amazingly hard. if not impossible.
    (just what you wanted to hear)
    basically, rtf support in java is pathetic.
    in my case, i had to create an actual RTF file in ms word and save it.
    i then opened it in notepad so that i could see all the control codes.
    then i cut and pasted each section of the document template so that each bit was a string constant in java. the bits that i wanted to add i generated in code the normal way.
    then i stuck all the bits back together again in one string and sent that off to a data stream. (to answer your question, it never went to the screen, just to the data stream)
    its a bloody stupid way of doing rtf, but it was the only way to get it to work without having to go through and figure and implement out all the rtf codes yourself.

  • How to select different parts of the text? cmd button no longer does that...

    After installing Maverics i can no longer propertly edit my work as I cannot mark different parts of text using cmd button. Shift works as before for highlighting all the text from starting point to selected point but I can no longer use cmd to highlight different areas of the text. Is this an OS bug? Or was the button for selecting different parts of the text changed? I tried everything...

    It's just a small part of what makes Pages 5 so "stunning" (Apple's word). You think stripping out the nifty ability to mark non-contiguous passages of text was neat? Sure that was nice. But Apple has gotten rid of more, so much more. And for free!
    Just wait till you put the product through its paces and you discover other nice features that are missing, such as (but not limited to):
    - no linking of text boxes!  Yes, that's right. Now a newsletter that had a "continued on page 6" or whatever will be broken by Pages 5. Stunning! (Even more stunning, Pages 5 will strip out all sorts of formatting from documents created with Pages 4.3 and it will do ao without warning and will save the document in a NEW unified file format so that it cannot be opened by Pages 4.3, thereby potentially losing users hours and hours of work. Stunning!
    There's more!
    - Pages 5 has no mail merge, no bookmarks, no images in headers/footers! Pages 4.3 has those features, but this stunning new release removes them.
    - Pages 5 features vastly reduced and simplified set of templates (there used to be about 130 Apple-cupplied templates, now there are about 60).
    - Page 5 also boasts NO RTF SUPPORT, so a paper your wrote with Apple's own TextEdit is not natively readable with Pages: Stunning!
    - No detail was too small to omit in this stunning new release: the vertical ruler, so you can easily place text or an obejct at a certain place in a document: gone! Setting the default zoom: gone!  Status bar reproting word count and pagecount (e.g., Page 4 of 48): Gone! View comments in the left side bar: Gone!  Autocapitalization: Gone! Search & Replace: drastically simplified!
    But here's the really good news: Pages 5 is just PERFECT for creating a one page-poster advertising a new concert by Apple employee Eddie Cue. What's more you can collaborate on it with someone else, even if they're using a PC. Now that's "stunning"!

  • Pass a Parameter to Function?

    Hi All,
    can you please tell me is it possible to pass a parameter to a function in the Select statement
    for example
    select * from table(test.get_trans_by_period('141', '123456874', '20000101', '20100101'))
    How can I use BI Publisher to pass the values using parameters
    I tried
    select * from table(test.get_trans_by_period(:p_param1, :p_param2, :p_param3, :p_param4))
    but it's not working
    BR,
    Rossy

    You can write a data template, and call the function from within the xml block for the data template, as in a database query.
    The rtf supports xsl code behind the tags, so can write xsl code in rtf.

  • May I open word documents on pages?

    I would like to know if i can open and format Word windows documents on pages?

    EIther Pages ’09 v4.n or the latest Pages v5.0.1 can open MS Word documents and templates. Pages is not an MS Word clone, and there may be functionality that you apply to the document in Pages, that may not accurately export back out to MS Word document formats.
    The older version of Pages could export to .doc format. The latest version can export to .doc and docx formats. There is .rtf support in the older Pages, but not in the latest, though TextEdit can open and export all of these formats.
    If you need precise, round-trip, MS Word compatibility, then I would recommend using Office for Mac 2011.

  • PrintDialog in WordProcessor

    Hi,
    Im trying to insert this dummy print function in my Wordprocessor, the code generates a new dialog with a textfield and continues generating random numbers every 2 seconds in the textfield.
    Here is the code for the wordprocessor & print functions
    Any help much appreciated..........
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import javax.swing.text.rtf.*;
    import javax.swing.undo.*;
    public class WordProcessor extends JFrame
    protected JTextPane m_monitor;
    protected StyleContext m_context;
    protected DefaultStyledDocument m_doc;
    protected RTFEditorKit m_kit;
    protected JFileChooser m_chooser;
    protected SimpleFilter m_rtfFilter;
    protected JToolBar m_toolBar;
    protected JComboBox m_cbFonts;
    protected JComboBox m_cbSizes;
    protected SmallToggleButton m_bBold;
    protected SmallToggleButton m_bItalic;
    protected String m_fontName = "";
    protected int m_fontSize = 0;
    protected boolean m_skipUpdate;
    protected int m_xStart = -1;
    protected int m_xFinish = -1;
    protected SimpleFilter m_jpgFilter;
    protected SimpleFilter m_gifFilter;
    protected ColorMenu m_foreground;
    protected ColorMenu m_background;
    protected JComboBox m_cbStyles;
    protected Hashtable m_styles;
    protected UndoManager m_undo = new UndoManager();
    protected Action m_undoAction;
    protected Action m_redoAction;
    protected String[] m_fontNames;
    protected String[] m_fontSizes;
    protected FontDialog m_fontDialog;
    protected ParagraphDialog m_paragraphDialog;
    protected FindDialog m_findDialog;//////////////////////////////////////
    public WordProcessor() {
    super("Text Editor");
    setSize(600, 400);
    m_monitor = new JTextPane();
    m_kit = new RTFEditorKit();
    m_monitor.setEditorKit(m_kit);
    m_context = new StyleContext();
    m_doc = new DefaultStyledDocument(m_context);
    m_monitor.setDocument(m_doc);
    JScrollPane ps = new JScrollPane(m_monitor);
    getContentPane().add(ps, BorderLayout.CENTER);
    JMenuBar menuBar = createMenuBar();
    setJMenuBar(menuBar);
    m_chooser = new JFileChooser();
    m_chooser.setCurrentDirectory(new File("."));
    m_rtfFilter = new SimpleFilter("rtf", "RTF Documents");
    m_chooser.setFileFilter(m_rtfFilter);
    m_gifFilter = new SimpleFilter("gif", "GIF images");
    m_jpgFilter = new SimpleFilter("jpg", "JPG images");
    CaretListener lst = new CaretListener() {
    public void caretUpdate(CaretEvent e) {
    showAttributes(e.getDot());
    m_monitor.addCaretListener(lst);
    FocusListener flst = new FocusListener() {
    public void focusGained(FocusEvent e) {
    if (m_xStart>=0 && m_xFinish>=0)
    if (m_monitor.getCaretPosition()==m_xStart) {
    m_monitor.setCaretPosition(m_xFinish);
    m_monitor.moveCaretPosition(m_xStart);
    else
    m_monitor.select(m_xStart, m_xFinish);
    public void focusLost(FocusEvent e) {
    m_xStart = m_monitor.getSelectionStart();
    m_xFinish = m_monitor.getSelectionEnd();
    m_monitor.addFocusListener(flst);
    WindowListener wndCloser = new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    addWindowListener(wndCloser);
    showAttributes(0);
    showStyles();
    m_doc.addUndoableEditListener(new Undoer());
    setVisible(true);
    protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu mFile = new JMenu("File");
    mFile.setMnemonic('f');
    ImageIcon iconNew = new ImageIcon("file_new.gif");
    Action actionNew = new AbstractAction("New", iconNew) {
    public void actionPerformed(ActionEvent e) {
    m_doc = new DefaultStyledDocument(m_context);
    m_monitor.setDocument(m_doc);
    showAttributes(0);
    showStyles();
    m_doc.addUndoableEditListener(new Undoer());
    JMenuItem item = mFile.add(actionNew);
    item.setMnemonic('n');
    ImageIcon iconOpen = new ImageIcon("file_open.gif");
    Action actionOpen = new AbstractAction("Open...", iconOpen) {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.setCursor(
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Thread runner = new Thread() {
    public void run() {
    if (m_chooser.showOpenDialog(WordProcessor.this) !=
    JFileChooser.APPROVE_OPTION)
    return;
    WordProcessor.this.repaint();
    File fChoosen = m_chooser.getSelectedFile();
    // Recall that text component read/write operations are
    // thread safe. Its ok to do this in a separate thread.
    try {
    InputStream in = new FileInputStream(fChoosen);
    m_doc = new DefaultStyledDocument(m_context);
    m_kit.read(in, m_doc, 0);
    m_monitor.setDocument(m_doc);
    in.close();
    showAttributes(0);
    showStyles();
    m_doc.addUndoableEditListener(new Undoer());
    catch (Exception ex) {
    //ex.printStackTrace();
    System.out.println("Problems encountered: Note that RTF"
    + " support is still under development.");
    WordProcessor.this.setCursor(Cursor.getPredefinedCursor(
    Cursor.DEFAULT_CURSOR));
    runner.start();
    item = mFile.add(actionOpen);
    item.setMnemonic('o');
    ImageIcon iconSave = new ImageIcon("file_save.gif");
    Action actionSave = new AbstractAction("Save...", iconSave) {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.setCursor(
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Thread runner = new Thread() {
    public void run() {
    if (m_chooser.showSaveDialog(WordProcessor.this) !=
    JFileChooser.APPROVE_OPTION)
    return;
    WordProcessor.this.repaint();
    File fChoosen = m_chooser.getSelectedFile();
    // Recall that text component read/write operations are
    // thread safe. Its ok to do this in a separate thread.
    try {
    OutputStream out = new FileOutputStream(fChoosen);
    m_kit.write(out, m_doc, 0, m_doc.getLength());
    out.close();
    catch (Exception ex) {
    ex.printStackTrace();
    // Make sure chooser is updated to reflect new file
    m_chooser.rescanCurrentDirectory();
    WordProcessor.this.setCursor(Cursor.getPredefinedCursor(
    Cursor.DEFAULT_CURSOR));
    runner.start();
    item = mFile.add(actionSave);
    item.setMnemonic('s');
    mFile.addSeparator();
    Action actionExit = new AbstractAction("Exit") {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    item = mFile.add(actionExit);
    item.setMnemonic('x');
    menuBar.add(mFile);
    m_toolBar = new JToolBar();
    JButton bNew = new SmallButton(actionNew, "New document");
    m_toolBar.add(bNew);
    JButton bOpen = new SmallButton(actionOpen, "Open RTF document");
    m_toolBar.add(bOpen);
    JButton bSave = new SmallButton(actionSave, "Save RTF document");
    m_toolBar.add(bSave);
    JMenu mEdit = new JMenu("Edit");
    mEdit.setMnemonic('e');
    Action action = new AbstractAction("Copy",
    new ImageIcon("edit_copy.gif"))
    public void actionPerformed(ActionEvent e) {
    m_monitor.copy();
    item = mEdit.add(action);
    item.setMnemonic('c');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
    KeyEvent.CTRL_MASK));
    action = new AbstractAction("Cut",
    new ImageIcon("edit_cut.gif"))
    public void actionPerformed(ActionEvent e) {
    m_monitor.cut();
    item = mEdit.add(action);
    item.setMnemonic('t');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
    KeyEvent.CTRL_MASK));
    action = new AbstractAction("Paste",
    new ImageIcon("edit_paste.gif"))
    public void actionPerformed(ActionEvent e) {
    m_monitor.paste();
    item = mEdit.add(action);
    item.setMnemonic('p');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
    KeyEvent.CTRL_MASK));
    mEdit.addSeparator();
    m_undoAction = new AbstractAction("Undo",
    new ImageIcon("edit_undo.gif"))
    public void actionPerformed(ActionEvent e) {
    try {
    m_undo.undo();
    catch (CannotUndoException ex) {
    System.err.println("Unable to undo: " + ex);
    updateUndo();
    item = mEdit.add(m_undoAction);
    item.setMnemonic('u');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,
    KeyEvent.CTRL_MASK));
    m_redoAction = new AbstractAction("Redo",
    new ImageIcon("edit_redo.gif"))
    public void actionPerformed(ActionEvent e) {
    try {
    m_undo.redo();
    catch (CannotRedoException ex) {
    System.err.println("Unable to redo: " + ex);
    updateUndo();
    item = mEdit.add(m_redoAction);
    item.setMnemonic('r');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y,
    KeyEvent.CTRL_MASK));
    mEdit.addSeparator();
    Action findAction = new AbstractAction("Find...",
    new ImageIcon("edit_find.gif"))
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    if (m_findDialog==null)
    m_findDialog = new FindDialog(WordProcessor.this, 0);
    else
    m_findDialog.setSelectedIndex(0);
    Dimension d1 = m_findDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_findDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_findDialog.show();
    item = mEdit.add(findAction);
    item.setMnemonic('f');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,
    KeyEvent.CTRL_MASK));
    Action replaceAction = new AbstractAction("Replace...") {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    if (m_findDialog==null)
    m_findDialog = new FindDialog(WordProcessor.this, 1);
    else
    m_findDialog.setSelectedIndex(1);
    Dimension d1 = m_findDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_findDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_findDialog.show();
    item = mEdit.add(replaceAction);
    item.setMnemonic('r');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,
    KeyEvent.CTRL_MASK));
    menuBar.add(mEdit);
    GraphicsEnvironment ge = GraphicsEnvironment.
    getLocalGraphicsEnvironment();
    m_fontNames = ge.getAvailableFontFamilyNames();
    m_toolBar.addSeparator();
    m_cbFonts = new JComboBox(m_fontNames);
    m_cbFonts.setMaximumSize(m_cbFonts.getPreferredSize());
    m_cbFonts.setEditable(true);
    ActionListener lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    m_fontName = m_cbFonts.getSelectedItem().toString();
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setFontFamily(attr, m_fontName);
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_cbFonts.addActionListener(lst);
    m_toolBar.add(m_cbFonts);
    m_toolBar.addSeparator();
    m_fontSizes = new String[] {"8", "9", "10", "11", "12", "14",
    "16", "18", "20", "22", "24", "26", "28", "36", "48", "72"};
    m_cbSizes = new JComboBox(m_fontSizes);
    m_cbSizes.setMaximumSize(m_cbSizes.getPreferredSize());
    m_cbSizes.setEditable(true);
    m_fontDialog = new FontDialog(this, m_fontNames, m_fontSizes);
    m_paragraphDialog = new ParagraphDialog(this);
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int fontSize = 0;
    try {
    fontSize = Integer.parseInt(m_cbSizes.
    getSelectedItem().toString());
    catch (NumberFormatException ex) { return; }
    m_fontSize = fontSize;
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setFontSize(attr, fontSize);
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_cbSizes.addActionListener(lst);
    m_toolBar.add(m_cbSizes);
    m_toolBar.addSeparator();
    ImageIcon img1 = new ImageIcon("font_bold1.gif");
    ImageIcon img2 = new ImageIcon("font_bold2.gif");
    m_bBold = new SmallToggleButton(false, img1, img2,
    "Bold font");
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setBold(attr, m_bBold.isSelected());
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_bBold.addActionListener(lst);
    m_toolBar.add(m_bBold);
    img1 = new ImageIcon("font_italic1.gif");
    img2 = new ImageIcon("font_italic2.gif");
    m_bItalic = new SmallToggleButton(false, img1, img2,
    "Italic font");
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setItalic(attr, m_bItalic.isSelected());
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_bItalic.addActionListener(lst);
    m_toolBar.add(m_bItalic);
    JMenu mFormat = new JMenu("Format");
    mFormat.setMnemonic('o');
    item = new JMenuItem("Font...");
    item.setMnemonic('o');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    AttributeSet a = m_doc.getCharacterElement(
    m_monitor.getCaretPosition()).getAttributes();
    m_fontDialog.setAttributes(a);
    Dimension d1 = m_fontDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_fontDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_fontDialog.show();
    if (m_fontDialog.getOption()==JOptionPane.OK_OPTION) {
    setAttributeSet(m_fontDialog.getAttributes());
    showAttributes(m_monitor.getCaretPosition());
    item.addActionListener(lst);
    mFormat.add(item);
    item = new JMenuItem("Paragraph...");
    item.setMnemonic('p');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    AttributeSet a = m_doc.getCharacterElement(
    m_monitor.getCaretPosition()).getAttributes();
    m_paragraphDialog.setAttributes(a);
    Dimension d1 = m_paragraphDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_paragraphDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_paragraphDialog.show();
    if (m_paragraphDialog.getOption()==JOptionPane.OK_OPTION) {
    setAttributeSet(m_paragraphDialog.getAttributes(), true);
    showAttributes(m_monitor.getCaretPosition());
    item.addActionListener(lst);
    mFormat.add(item);
    mFormat.addSeparator();
    JMenu mStyle = new JMenu("Style");
    mStyle.setMnemonic('s');
    mFormat.add(mStyle);
    item = new JMenuItem("Update");
    item.setMnemonic('u');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    String name = (String)m_cbStyles.getSelectedItem();
    Style style = m_doc.getStyle(name);
    int p = m_monitor.getCaretPosition();
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    style.addAttributes(a);
    m_monitor.repaint();
    item.addActionListener(lst);
    mStyle.add(item);
    item = new JMenuItem("Reapply");
    item.setMnemonic('r');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    String name = (String)m_cbStyles.getSelectedItem();
    Style style = m_doc.getStyle(name);
    setAttributeSet(style);
    item.addActionListener(lst);
    mStyle.add(item);
    mFormat.addSeparator();
    m_foreground = new ColorMenu("Selection Foreground");
    m_foreground.setColor(m_monitor.getForeground());
    m_foreground.setMnemonic('f');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setForeground(attr, m_foreground.getColor());
    setAttributeSet(attr);
    m_foreground.addActionListener(lst);
    mFormat.add(m_foreground);
    MenuListener ml = new MenuListener() {
    public void menuSelected(MenuEvent e) {
    int p = m_monitor.getCaretPosition();
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    Color c = StyleConstants.getForeground(a);
    m_foreground.setColor(c);
    public void menuDeselected(MenuEvent e) {}
    public void menuCanceled(MenuEvent e) {}
    m_foreground.addMenuListener(ml);
    // Bug Alert! JEditorPane background color
    // doesn't work as of Java 2 FCS.
    m_background = new ColorMenu("Selection Background");
    m_background.setColor(m_monitor.getBackground());
    m_background.setMnemonic('b');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setBackground(attr, m_background.getColor());
    setAttributeSet(attr);
    m_background.addActionListener(lst);
    mFormat.add(m_background);
    ml = new MenuListener() {
    public void menuSelected(MenuEvent e) {
    int p = m_monitor.getCaretPosition();
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    Color c = StyleConstants.getBackground(a);
    m_background.setColor(c);
    public void menuDeselected(MenuEvent e) {}
    public void menuCanceled(MenuEvent e) {}
    m_background.addMenuListener(ml);
    // Bug Alert! Images do not get saved.
    mFormat.addSeparator();
    item = new JMenuItem("Insert Image");
    item.setMnemonic('i');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    m_chooser.addChoosableFileFilter(m_gifFilter);
    m_chooser.addChoosableFileFilter(m_jpgFilter);
    m_chooser.setFileFilter(m_gifFilter);
    m_chooser.removeChoosableFileFilter(m_rtfFilter);
    Thread runner = new Thread() {
    public void run() {
    if (m_chooser.showOpenDialog(WordProcessor.this) !=
    JFileChooser.APPROVE_OPTION)
    return;
    WordProcessor.this.repaint();
    File fChoosen = m_chooser.getSelectedFile();
    ImageIcon icon = new ImageIcon(fChoosen.getPath());
    int w = icon.getIconWidth();
    int h = icon.getIconHeight();
    if (w<=0 || h<=0) {
    JOptionPane.showMessageDialog(WordProcessor.this,
    "Error reading image file\n"+
    fChoosen.getPath(), "Warning",
    JOptionPane.WARNING_MESSAGE);
    return;
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setIcon(attr, icon);
    int p = m_monitor.getCaretPosition();
    try {
    m_doc.insertString(p, " ", attr);
    catch (BadLocationException ex) {}
    // Its ok to do this outside of the event-dispatching
    // thread because the chooser is not visible here.
    m_chooser.addChoosableFileFilter(m_rtfFilter);
    m_chooser.setFileFilter(m_rtfFilter);
    m_chooser.removeChoosableFileFilter(m_gifFilter);
    m_chooser.removeChoosableFileFilter(m_jpgFilter);
    runner.start();
    item.addActionListener(lst);
    mFormat.add(item);
    menuBar.add(mFormat);
    m_toolBar.addSeparator();
    m_cbStyles = new JComboBox();
    m_cbStyles.setMaximumSize(m_cbStyles.getPreferredSize());
    m_cbStyles.setEditable(true);
    m_toolBar.add(m_cbStyles);
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (m_skipUpdate || m_cbStyles.getItemCount()==0)
    return;
    String name = (String)m_cbStyles.getSelectedItem();
    int index = m_cbStyles.getSelectedIndex();
    int p = m_monitor.getCaretPosition();
    // New name entered
    if (index == -1) {
    m_cbStyles.addItem(name);
    Style style = m_doc.addStyle(name, null);
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    style.addAttributes(a);
    return;
    // Apply the selected style
    Style currStyle = m_doc.getLogicalStyle(p);
    if (!currStyle.getName().equals(name)) {
    Style style = m_doc.getStyle(name);
    setAttributeSet(style);
    m_cbStyles.addActionListener(lst);
    JMenu mTools = new JMenu("Tools");
    mTools.setMnemonic('t');
    Action spellAction = new AbstractAction("Print...",
    new ImageIcon("tools_abc.gif"))
    public void actionPerformed(ActionEvent e) {
    SpellChecker checker = new SpellChecker(WordProcessor.this);
    WordProcessor.this.setCursor(Cursor.getPredefinedCursor(
    Cursor.WAIT_CURSOR));
    checker.start();
    item = mTools.add(spellAction);
    item.setMnemonic('s');
    item.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_F7, 0));
    menuBar.add(mTools);
    m_toolBar.addSeparator();
    m_toolBar.add(new SmallButton(spellAction,
    "Spell checker"));
    getContentPane().add(m_toolBar, BorderLayout.NORTH);
    return menuBar;
    protected void showAttributes(int p) {
    m_skipUpdate = true;
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    String name = StyleConstants.getFontFamily(a);
    if (!m_fontName.equals(name)) {
    m_fontName = name;
    m_cbFonts.setSelectedItem(name);
    int size = StyleConstants.getFontSize(a);
    if (m_fontSize != size) {
    m_fontSize = size;
    m_cbSizes.setSelectedItem(Integer.toString(m_fontSize));
    boolean bold = StyleConstants.isBold(a);
    if (bold != m_bBold.isSelected())
    m_bBold.setSelected(bold);
    boolean italic = StyleConstants.isItalic(a);
    if (italic != m_bItalic.isSelected())
    m_bItalic.setSelected(italic);
    Style style = m_doc.getLogicalStyle(p);
    name = style.getName();
    m_cbStyles.setSelectedItem(name);
    if (m_styles!=null && m_styles.get(name)==null) {
    style = m_doc.addStyle(name, null);
    a = m_doc.getCharacterElement(p).getAttributes();
    style.addAttributes(a);
    m_styles.put(name, style);
    m_skipUpdate = false;
    protected void setAttributeSet(AttributeSet attr) {
    setAttributeSet(attr, false);
    protected void setAttributeSet(AttributeSet attr,
    boolean setParagraphAttributes)
    if (m_skipUpdate)
    return;
    int xStart = m_monitor.getSelectionStart();
    int xFinish = m_monitor.getSelectionEnd();
    if (!m_monitor.hasFocus()) {
    xStart = m_xStart;
    xFinish = m_xFinish;
    if (setParagraphAttributes)
    m_doc.setParagraphAttributes(xStart,
    xFinish - xStart, attr, false);
    else if (xStart != xFinish)
    m_doc.setCharacterAttributes(xStart,
    xFinish - xStart, attr, false);
    else {
    MutableAttributeSet inputAttributes =
    m_kit.getInputAttributes();
    inputAttributes.addAttributes(attr);
    protected void showStyles() {
    m_skipUpdate = true;
    if (m_cbStyles.getItemCount() > 0)
    m_cbStyles.removeAllItems();
    Enumeration en = m_doc.getStyleNames();
    while (en.hasMoreElements()) {
    String str = en.nextElement().toString();
    m_cbStyles.addItem(str);
    m_styles = new Hashtable();
    m_skipUpdate = false;
    protected void updateUndo() {
    if(m_undo.canUndo()) {
    m_undoAction.setEnabled(true);
    m_undoAction.putValue(Action.NAME,
    m_undo.getUndoPresentationName());
    else {
    m_undoAction.setEnabled(false);
    m_undoAction.putValue(Action.NAME, "Undo");
    if(m_undo.canRedo()) {
    m_redoAction.setEnabled(true);
    m_redoAction.putValue(Action.NAME,
    m_undo.getRedoPresentationName());
    else {
    m_redoAction.setEnabled(false);
    m_redoAction.putValue(Action.NAME, "Redo");
    public Document getDocument() { return m_doc; }
    public JTextPane getTextPane() { return m_monitor; }
    public void setSelection(int xStart, int xFinish, boolean moveUp) {
    if (moveUp) {
    m_monitor.setCaretPosition(xFinish);
    m_monitor.moveCaretPosition(xStart);
    else
    m_monitor.select(xStart, xFinish);
    m_xStart = m_monitor.getSelectionStart();
    m_xFinish = m_monitor.getSelectionEnd();
    public static void main(String argv[]) {
    new WordProcessor();
    class Undoer implements UndoableEditListener
    public Undoer() {
    m_undo.die();
    updateUndo();
    public void undoableEditHappened(UndoableEditEvent e) {
    UndoableEdit edit = e.getEdit();
    m_undo.addEdit(e.getEdit());
    updateUndo();
    // Class SmallButton unchanged from section 4.8
    class SmallButton extends JButton implements MouseListener
    protected Border m_raised;
    protected Border m_lowered;
    protected Border m_inactive;
    public SmallButton(Action act, String tip) {
    super((Icon)act.getValue(Action.SMALL_ICON));
    m_raised = new BevelBorder(BevelBorder.RAISED);
    m_lowered = new BevelBorder(BevelBorder.LOWERED);
    m_inactive = new EmptyBorder(2, 2, 2, 2);
    setBorder(m_inactive);
    setMargin(new Insets(1,1,1,1));
    setToolTipText(tip);
    addActionListener(act);
    addMouseListener(this);
    setRequestFocusEnabled(false);
    public float getAlignmentY() { return 0.5f; }
    public void mousePressed(MouseEvent e) {
    setBorder(m_lowered);
    public void mouseReleased(MouseEvent e) {
    setBorder(m_inactive);
    public void mouseClicked(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {
    setBorder(m_raised);
    public void mouseExited(MouseEvent e) {
    setBorder(m_inactive);
    // Class SimpleFilter unchanged from section 14.1.9
    class SimpleFilter extends javax.swing.filechooser.FileFilter
    private String m_description = null;
    private String m_extension = null;
    public SimpleFilter(String extension, String description) {
    m_description = description;
    m_extension = "."+extension.toLowerCase();
    public String getDescription() {
    return m_description;
    public boolean accept(File f) {
    if (f == null)
    return false;
    if (f.isDirectory())
    return true;
    return f.getName().toLowerCase().endsWith(m_extension);
    // Class SmallToggleButton unchanged from section 4.8
    class SmallToggleButton extends JToggleButton implements ItemListener
    protected Border m_raised;
    protected Border m_lowered;
    public SmallToggleButton(boolean selected, ImageIcon imgUnselected,
    ImageIcon imgSelected, String tip)
    super(imgUnselected, selected);
    setHorizontalAlignment(CENTER);
    setBorderPainted(true);
    m_raised = new BevelBorder(BevelBorder.RAISED);
    m_lowered = new BevelBorder(BevelBorder.LOWERED);
    setBorder(selected ? m_lowered : m_raised);
    setMargin(new Insets(1,1,1,1));
    setToolTipText(tip);
    setRequestFocusEnabled(false);
    setSelectedIcon(imgSelected);
    addItemListener(this);
    public float getAlignmentY() { return 0.5f; }
    public void itemStateChanged(ItemEvent e) {
    setBorder(isSelected() ? m_lowered : m_raised);
    // Class ColorMenu unchanged from section 12.5
    class ColorMenu extends JMenu
    protected Border m_unselectedBorder;
    protected Border m_selectedBorder;
    protected Border m_activeBorder;
    protected Hashtable m_panes;
    protected ColorPane m_selected;
    public ColorMenu(

    Sorry about that...newbie here....
    Here we go.....what im having trouble doing is inserting this print dialog into my menu
    Here is the print snippet
    public void print()
            new TimerTestDialog(this);
        class TimerTestDialog extends JDialog
            TimerTestDialog(Frame parent)
                super(parent);
                setLocationRelativeTo(parent);
                setupDialog();
                setModal(false);    // this will allow you to do still stuff with the main frame
                                         //The popup window in this case is not modal. This means that the
                                         //user isnt required to respond to the popup before the program continues running
                 * sorry, using a Timer instead of your original TimerTask - it's simpler
                Timer t = new Timer(2000, ticker);
                t.start();
            private void setupDialog()
                Container c = getContentPane();
                c.setLayout(new BorderLayout());
                c.add(getDisplayPanel(), BorderLayout.CENTER);
                c.add(getButtonPanel(), BorderLayout.SOUTH);
                setSize(300, 150);
                setVisible(true);
            private Component getDisplayPanel()
                label = new JLabel("---", JLabel.CENTER);
                label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                JPanel panel = new JPanel(new BorderLayout());
                panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
                JPanel backing = new JPanel(new BorderLayout());
                backing.add(label, BorderLayout.NORTH);     // this will ensure the label doesn't go all tall
                panel.add(backing, BorderLayout.CENTER);
                return panel;
            private Component getButtonPanel()
                JPanel panel = new JPanel(new BorderLayout());
                panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
                JPanel backing = new JPanel(new BorderLayout());
                JButton closeButton = new JButton("Close");
                closeButton.addActionListener(new ActionListener()
                    public void actionPerformed(ActionEvent e)
                        dispose();
                backing.add(closeButton, BorderLayout.CENTER);
                panel.add(backing, BorderLayout.LINE_END);
                return panel;
            private ActionListener ticker = new ActionListener()
                public void actionPerformed(ActionEvent e)
                    label.setText(String.valueOf(getRandomNumber()));
            private int getRandomNumber()
                return r.nextInt(1000) + 1;       // shift from 0-9 to 1-1000
            private JLabel label;
         * NOTE - this is the best way to use random stuff in java.  if you use instance members
         * you can sometimes get the same result each time.  not really sure how that works but
         * i've seen it happen
        private static Random r = new Random();
    Here is my menu code
    Action actionPrint = new AbstractAction("Print...", iconPrint) {
          public void actionPerformed(ActionEvent e) {
            WordProcessor.this.setCursor(
              Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            Thread runner = new Thread() {
              public void run() {
              //this is where I want to put the print function, so when the user click on print the print dialog box will appear

  • Why is there no support for RTF files in Pages?

    Why is there no support for RTF files in Pages?
    This is nuts!

    You are not alone.
    Actions speak louder than words, but Apple does manage to still distract many from what is self evident before them.
    I am astonished by those who swear that non-existent features, or features that pre-exist the current version make Pages 5.2 a major upgrade.
    An affect that does seem to wear off with familiarity, as each version of Pages 5 gets a boost in the App Store, only to see the disapproval rating surge back again.
    Pages was always one of the top purchases in the App Store, now it doesn't even rate.
    Peter

Maybe you are looking for

  • Po print from ME22N

    Hi All, I have a issue where i am not able to take printout from ME22N.The Print option is appearing in grey mode. I am able to take print from ME9F. What can be the possible reason. Kindly help me solve this issue. Thanks in advance. Regards, Neeraj

  • How do i clear the space used by MAIL on my iPhone5 ?

    I am using the iPhone5 16GB and lately am facing free memory space available issues. I checked on the memory used by various apps and found that MAIL is using 5GB alone. Kindly help me in reducing this... Earlier iOS version, I recollect we had an op

  • Opening Excel Files from DB (blob column)

    My project has implemented a WEBUTIL solution to attach files into the database, view the files stored in the database (in a BLOB column), and remove the files stored in the database. Everything has been running smoothly. We are in final testing and

  • Wasting screen space in German Lightroom 2

    Hello, I've compared Lightroom 1.3 and 2.0 both in German and it seems that the new German version takes a *lot* more screen space for its right panel in the develop module to show completely. In the normal view it's okay, but in the crop and repair

  • Can't import some Quicktime files into FCP X 10.0.5

    I'm new to FCP X.  Trying to import Qiicktime files from hard drive and keep getting "no supported files" dialog box.  Or sometimes it imports audio only. Only once was I successfully able to import video files.  All of the files were originally crea