Multicolored JTextPane

I am using a JTextPane to display a online report.
Each new line / set of new lines signify a record in the report. Since there could be variable number of records all with variable number of lines it becomes difficult to distinguish between records. Hence, what I intend to do is create the text pane such that alternate record areas have different backgrounds or foregrounds.
Can I get some pointers as to how to go about doing this ?
Thanks in advance,

Heres an example of how to change the background color of alternate lines. I haven't tried it with groups of lines.
import java.awt.*;
import java.net.*;
import javax.swing.*;
import javax.swing.text.*;
public class BackgroundLines extends JFrame
     public BackgroundLines()
          throws Exception
          JTextArea textComponent = new JTextArea()
               public void paintComponent(Graphics g)
                    Rectangle drawHere = g.getClipBounds();
                    int lineHeight = g.getFontMetrics().getHeight();
                    int startOffset = getInsets().top;
                    int start = (drawHere.y / lineHeight) * lineHeight + startOffset;
                    int startLineNumber = (drawHere.y / lineHeight);
                    int endLineNumber = startLineNumber + (drawHere.height / lineHeight) + 1;
                    for (int i = startLineNumber; i <= endLineNumber; i++)
                         g.setColor( i % 2 == 0 ? getBackground() : Color.lightGray );
                         g.fillRect(drawHere.x, start, drawHere.width, lineHeight);
                         start += lineHeight;
                    super.paintComponent(g);
          textComponent.setOpaque( false );
          JScrollPane scrollPane = new JScrollPane(textComponent);
          scrollPane.setPreferredSize(new Dimension(300, 250));
          getContentPane().add( scrollPane );
     public static void main(String[] args)
          throws Exception
          BackgroundLines frame = new BackgroundLines();
          frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
          frame.pack();
          frame.setVisible(true);
}

Similar Messages

  • ComponentView does not redraw component in JTextPane Cell Rend

    We have created a JTable implementation that uses JTextPanes as cell renderers/editors so that text styles and the like are available. We want insert a component, such as a JButton, into the JTextPane. However, the component is only visible when the cell is in an editable state. In the renderer, the ComponentView looks like it has set aside the space where the component is to be, but the component is not visible.
    I have looked at this problem for several days now, and have only determined that this seems to be occuring at a low level. What I have found is that the ButtonUI's update method is not called when the document is in the cell renderer, while it seems called continuously in the cell editor (on each caret blink).
    Does anybody have any insight as to the problem? I have submitted this as a bug to Sun but wanted to find out if anybody else has come across anything similar to this.
    Thank for any help.
    Steve Feveile
    Here is sample code to reproduce the problem:
    // Main Class
    * Main frame for the testing of the component not painting. This simplifies
    * an issue we have come across when trying to set up using a JTextPane as a
    * renderer/editor as the cells in a table.
    * Under these conditions we have found that a component inserted into the JTextPanes document
    * only appears in the editing state of the cell, whereas the rendering state leaves
    * the spacing for the component but does not make it visible.
    * Note that creating a JTextPane with the one of these documents will show the component,
    * even when not editing.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.table.*;
    public class tableFrame extends JFrame
         public tableFrame()
              //set up frame
              getContentPane().setLayout(new BorderLayout());
              setSize(500,300);
              setTitle("Table Missing Component Test");
    addWindowListener(
         new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
                             setVisible(false);                         
                   System.exit(0);     
              //set up components the table
              JTable table = new JTable(createDocumentTableModel(2,2));
              table.setRowHeight(60);
              //set the default renderer/editor to use the JTextPane implementation
              for (int x = 0; x < table.getColumnCount(); x++) {
                   table.setDefaultEditor(table.getColumnClass(x), new TextPaneCellEditor());
                   table.setDefaultRenderer(table.getColumnClass(x), new TextPaneRenderer());
              JScrollPane pane = new JScrollPane(table);
              getContentPane().add(pane, BorderLayout.CENTER);
              //this adds a textpane without the table involved
              //uising the same way of inserting a document
              JTextPane tPane = new JTextPane();
              DefaultStyledDocument doc = new DefaultStyledDocument();
              try
                   doc.insertString(0, "Some text in a JTextPane", null);
                   JButton b = new JButton("Button");
         SimpleAttributeSet inputAttributes = new SimpleAttributeSet();
              StyleConstants.setComponent(inputAttributes, b);
              doc.insertString(0 , " ", inputAttributes);
              catch (Throwable t)
                   System.out.println("createDocumentTableModel error: " + t.getMessage());
              tPane.setDocument(doc);
              tPane.setSize(490, 60);
              JScrollPane pane2 = new JScrollPane(tPane);
              getContentPane().add(pane2, BorderLayout.SOUTH);
         * this creates a table model where the documents are the value
         * in each cell, and the cell renderer/editor can use this instead
         * of a string value
         private TableModel createDocumentTableModel(int row, int col)
              Vector headerData = new Vector();
              Vector tableData = new Vector();
              for (int i=0;i<row;i++)
                   headerData.add("Column" + i);
                   Vector rowData = new Vector();
                   for (int j=0;j<col;j++)
                        DefaultStyledDocument doc = new DefaultStyledDocument();
                        try
                             //this inserts some string to see that this is visible
                             //when editing and rendering
                             doc.insertString(0, ("Row: " + i + ", Column: " + j), null);
                             //this button will only be visible when the cell is in
                             //an editing state
                             JButton b = new JButton("Button" + i + "-" + j);
                   SimpleAttributeSet inputAttributes = new SimpleAttributeSet();
                        StyleConstants.setComponent(inputAttributes, b);
                        doc.insertString(0 , " ", inputAttributes);
                        catch (Throwable t)
                             System.out.println("createDocumentTableModel error: " + t.getMessage());
                        rowData.add(doc);
                   tableData.add(rowData);
              return new DefaultTableModel(tableData, headerData);
         //starts the ball rolling
         static public void main(String args[])
              (new tableFrame()).setVisible(true);
    // Custom Cell Editor
    * Sets the editor to use a JTextPane implementation
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.util.EventObject;
    import java.io.Serializable;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TextPaneCellEditor implements TableCellEditor
    /** Event listeners */
    protected EventListenerList listenerList = new EventListenerList();
    transient protected ChangeEvent changeEvent = null;
    protected JTextPane editorComponent;
    protected EditorDelegate delegate;
    protected int clickCountToStart = 1;
         * constructor.
    public TextPaneCellEditor() {
              editorComponent = new JTextPane();
              //use 1 click count to edit a cell
              clickCountToStart = 1;
              * controls the values of the editor
              delegate = new EditorDelegate() {
                   * sets the text value cell.
                   * @param value - value to set in the document
                   public void setValue(Object value) {
                        if (value instanceof Document)
                             editorComponent.setDocument((Document) value);
                        else
                             editorComponent.setText("");
                   * gets the text value cell.
                   * @return the document in the textpane
                   public Object getCellEditorValue() {
                        return editorComponent.getDocument();
         // implements the setting the value for the editor
         public Component getTableCellEditorComponent(JTable table, Object value,
                   boolean isSelected, int row, int column) {
              if (value != null)          
                   delegate.setValue(value);
              else
                   delegate.setValue("");
              return editorComponent;
    // Implementing the CellEditor Interface
         // implements javax.swing.CellEditor
         public Object getCellEditorValue() {
              return delegate.getCellEditorValue();
         // implements javax.swing.CellEditor
         public boolean isCellEditable(EventObject anEvent) {
              if (anEvent instanceof MouseEvent) {
                   return ((MouseEvent)anEvent).getClickCount() >= clickCountToStart;
              return true;
    // implements javax.swing.CellEditor
         public boolean shouldSelectCell(EventObject anEvent) {
              return delegate.shouldSelectCell(anEvent);
         // implements javax.swing.CellEditor
         public boolean stopCellEditing() {
              fireEditingStopped();
              return true;
         // implements javax.swing.CellEditor
         public void cancelCellEditing() {
              fireEditingCanceled();
    // Handle the event listener bookkeeping
         // implements javax.swing.CellEditor
         public void addCellEditorListener(CellEditorListener l) {
              listenerList.add(CellEditorListener.class, l);
         // implements javax.swing.CellEditor
         public void removeCellEditorListener(CellEditorListener l) {
              listenerList.remove(CellEditorListener.class, l);
         * Notify all listeners that have registered interest for
         * notification on this event type. The event instance
         * is lazily created using the parameters passed into
         * the fire method.
         * @see EventListenerList
         protected void fireEditingStopped() {
              // Guaranteed to return a non-null array
              Object[] listeners = listenerList.getListenerList();
              // Process the listeners last to first, notifying
              // those that are interested in this event
              for (int i = listeners.length-2; i>=0; i-=2) {
                   if (listeners==CellEditorListener.class) {
                        // Lazily create the event:
                        if (changeEvent == null)
                             changeEvent = new ChangeEvent(this);
                        ((CellEditorListener)listeners[i+1]).editingStopped(changeEvent);
         * Notify all listeners that have registered interest for
         * notification on this event type. The event instance
         * is lazily created using the parameters passed into
         * the fire method.
         * @see EventListenerList
         protected void fireEditingCanceled() {
              // Guaranteed to return a non-null array
              Object[] listeners = listenerList.getListenerList();
              // Process the listeners last to first, notifying
              // those that are interested in this event
              for (int i = listeners.length-2; i>=0; i-=2) {
                   if (listeners[i]==CellEditorListener.class) {
                        // Lazily create the event:
                        if (changeEvent == null)
                             changeEvent = new ChangeEvent(this);
                        ((CellEditorListener)listeners[i+1]).editingCanceled(changeEvent);
    // Protected EditorDelegate class
    protected class EditorDelegate implements ActionListener, ItemListener, Serializable {
              //made up of unimplemented methods
              protected Object value;
              public Object getCellEditorValue() {
                   return null;
              public void setValue(Object x) {}
              public void setDocument(Object x) {}
              public Document getDocument() {
                   return null;
              public boolean isCellEditable(EventObject anEvent) {
                   return true;
              /** Unfortunately, restrictions on API changes force us to
              * declare this method package private.
              boolean shouldSelectCell(EventObject anEvent) {
                   return true;
              public boolean startCellEditing(EventObject anEvent) {
                   return true;
              public boolean stopCellEditing() {
                   return true;
                   public void cancelCellEditing() {
              public void actionPerformed(ActionEvent e) {
                   fireEditingStopped();
              public void itemStateChanged(ItemEvent e) {
                   fireEditingStopped();
    // Custom Cell Renderer
    * renders a table cell as a JTextPane.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.table.*;
    public class TextPaneRenderer extends JTextPane implements TableCellRenderer                                                  
         * Constructor - just set to noneditable
         public TextPaneRenderer() {
              setEditable(false);
         * implementation of table cell renderer. If the value is a document
         * the, the text panes setDocument is used, otherwise a string value
         * is set
         public Component getTableCellRendererComponent(JTable table, Object value,
                   boolean isSelected, boolean hasFocus, int row, int column) {
              if (value != null)
                   if (value instanceof Document)
                        //set the value to a document
                        setDocument((Document) value);
                   else
                        //convert the value to a string
                        setText(value.toString());
              else
                   //set text to an empty string
                   setText("");
              return this;

    Hi, I came across the forum and found your problem is very similar to what I am having now. Your post has been a year old, I just wonder if you come up anything productive to what you had? Could you let us know what you (or Sun) find out if you do have one? Thanks.

  • Problem description: My computer is running very slow ever since I switched to Yosemite.  I get the multicolored wheel just opening my browser at times and waiting for a page to open, or an application.  Any ideas other than rebooting my computer to

    Problem description:
    My computer is running very slow ever since I switched to Yosemite.  I get the multicolored wheel just opening my browser at times and waiting for a page to open, or an application.  Any ideas other than rebooting my computer to get the problem to alleviate for a few days?
    EtreCheck version: 2.1.8 (121)
    Report generated February 16, 2015 at 2:35:55 PM PST
    Download EtreCheck from http://etresoft.com/etrecheck
    Click the [Click for support] links for help with non-Apple products.
    Click the [Click for details] links for more information about that line.
    Hardware Information: ℹ️
        iMac (21.5-inch, Late 2009) (Technical Specifications)
        iMac - model: iMac10,1
        1 3.06 GHz Intel Core 2 Duo CPU: 2-core
        4 GB RAM Upgradeable
            BANK 0/DIMM0
                Empty  
            BANK 1/DIMM0
                Empty  
            BANK 0/DIMM1
                2 GB DDR3 1067 MHz ok
            BANK 1/DIMM1
                2 GB DDR3 1067 MHz ok
        Bluetooth: Old - Handoff/Airdrop2 not supported
        Wireless:  en1: 802.11 a/b/g/n
    Video Information: ℹ️
        NVIDIA GeForce 9400 - VRAM: 256 MB
            iMac 1920 x 1080
    System Software: ℹ️
        OS X 10.10.2 (14C109) - Time since boot: 11 days 19:34:2
    Disk Information: ℹ️
        ST3500418ASQ disk0 : (500.11 GB)
            EFI (disk0s1) <not mounted> : 210 MB
            Recovery HD (disk0s3) <not mounted>  [Recovery]: 650 MB
            BOOTCAMP (disk0s4) /Volumes/BOOTCAMP : 60.76 GB (15.30 GB free)
            Macintosh HD (disk1) / : 438.11 GB (351.62 GB free)
                Encrypted AES-XTS Unlocked
                Core Storage: disk0s2 438.49 GB Online
        HL-DT-ST DVDRW  GA11N 
    USB Information: ℹ️
        Apple Inc. Built-in iSight
        Apple Internal Memory Card Reader
        Apple, Inc. Keyboard Hub
            Apple Inc. Apple Keyboard
        hp officejet 4200 series
        Apple Computer, Inc. IR Receiver
        Apple Inc. BRCM2046 Hub
            Apple Inc. Bluetooth USB Host Controller
    Gatekeeper: ℹ️
        Mac App Store and identified developers
    Problem System Launch Agents: ℹ️
        [killed]    com.apple.accountsd.plist
        [killed]    com.apple.AirPlayUIAgent.plist
        [killed]    com.apple.bird.plist
        [killed]    com.apple.CallHistoryPluginHelper.plist
        [killed]    com.apple.CallHistorySyncHelper.plist
        [killed]    com.apple.cloudd.plist
        [killed]    com.apple.coreservices.appleid.authentication.plist
        [killed]    com.apple.coreservices.uiagent.plist
        [killed]    com.apple.EscrowSecurityAlert.plist
        [killed]    com.apple.icloud.fmfd.plist
        [killed]    com.apple.iconservices.iconservicesagent.plist
        [killed]    com.apple.nsurlsessiond.plist
        [killed]    com.apple.pluginkit.pkd.plist
        [killed]    com.apple.printtool.agent.plist
        [killed]    com.apple.recentsd.plist
        [killed]    com.apple.secd.plist
        [killed]    com.apple.security.cloudkeychainproxy.plist
        [killed]    com.apple.spindump_agent.plist
        [killed]    com.apple.telephonyutilities.callservicesd.plist
        19 processes killed due to memory pressure
    Problem System Launch Daemons: ℹ️
        [killed]    com.apple.AssetCacheLocatorService.plist
        [killed]    com.apple.awdd.plist
        [killed]    com.apple.coresymbolicationd.plist
        [killed]    com.apple.ctkd.plist
        [killed]    com.apple.diagnosticd.plist
        [killed]    com.apple.emond.aslmanager.plist
        [killed]    com.apple.iconservices.iconservicesagent.plist
        [killed]    com.apple.iconservices.iconservicesd.plist
        [killed]    com.apple.ifdreader.plist
        [killed]    com.apple.nehelper.plist
        [killed]    com.apple.nsurlsessiond.plist
        [killed]    com.apple.periodic-daily.plist
        [killed]    com.apple.periodic-monthly.plist
        [killed]    com.apple.periodic-weekly.plist
        [killed]    com.apple.sandboxd.plist
        [killed]    com.apple.softwareupdate_download_service.plist
        [killed]    com.apple.spindump.plist
        [killed]    com.apple.tccd.system.plist
        [killed]    com.apple.wdhelper.plist
        [killed]    com.apple.xpc.smd.plist
        20 processes killed due to memory pressure
    User Launch Agents: ℹ️
        [loaded]    com.adobe.ARM.[...].plist [Click for support]
        [running]    com.GoodShop.updater.plist [Click for support]
    User Login Items: ℹ️
        None
    Internet Plug-ins: ℹ️
        o1dbrowserplugin: Version: 5.38.6.0 - SDK 10.8 [Click for support]
        Google Earth Web Plug-in: Version: 5.2 [Click for support]
        Default Browser: Version: 600 - SDK 10.10
        Flip4Mac WMV Plugin: Version: 2.4.2.4 [Click for support]
        RealPlayer Plugin: Version: Unknown [Click for support]
        AdobePDFViewerNPAPI: Version: 10.1.13 [Click for support]
        DivXBrowserPlugin: Version: 2.0 [Click for support]
        Silverlight: Version: 5.1.30514.0 - SDK 10.6 [Click for support]
        QuickTime Plugin: Version: 7.7.3
        iPhotoPhotocast: Version: 7.0
        googletalkbrowserplugin: Version: 5.38.6.0 - SDK 10.8 [Click for support]
        AdobePDFViewer: Version: 10.1.13 [Click for support]
        GarminGpsControl: Version: 4.2.0.0 - SDK 10.8 [Click for support]
    User internet Plug-ins: ℹ️
        CitrixOnlineWebDeploymentPlugin: Version: 1.0.79 [Click for support]
        VSeeHelper: Version: VSeeHelper 1.0.0.0 - SDK 10.8 [Click for support]
    Safari Extensions: ℹ️
        avast! Online Security
        Goodshop app
    3rd Party Preference Panes: ℹ️
        DivX  [Click for support]
        Flip4Mac WMV  [Click for support]
        MacFUSE  [Click for support]
    Time Machine: ℹ️
        Skip System Files: NO
        Mobile backups: OFF
        Auto backup: YES
        Volumes being backed up:
            Macintosh HD: Disk size: 438.11 GB Disk used: 86.50 GB
        Destinations:
            Backup [Local]
            Total size: 159.70 GB
            Total number of backups: 3
            Oldest backup: 2014-11-24 05:20:18 +0000
            Last backup: 2015-02-01 03:04:02 +0000
            Size of backup disk: Too small
                Backup size 159.70 GB < (Disk used 86.50 GB X 3)
    Top Processes by CPU: ℹ️
             8%    WindowServer
             5%    DashboardClient
             3%    mds
             2%    launchd
             0%    ocspd
    Top Processes by Memory: ℹ️
        64 MB    WindowServer
        52 MB    thunderbird
        34 MB    mds
        34 MB    Mail
        30 MB    mds_stores
    Virtual Memory Information: ℹ️
        654 MB    Free RAM
        834 MB    Active RAM
        777 MB    Inactive RAM
        903 MB    Wired RAM
        102.49 GB    Page-ins
        1.46 GB    Page-outs
    Diagnostics Information: ℹ️
        Standard users cannot read /Library/Logs/DiagnosticReports.
        Run as an administrator account to see more information.

    Hi Linc!  Sorry for the delay.  Here is the information:
    Start time: 16:48:08 02/28/15
    Revision: 1241
    Model Identifier: iMac10,1
    System Version: OS X 10.10.2 (14C109)
    Kernel Version: Darwin 14.1.0
    Time since boot: 10 days 21:04
    UID: 502
    SerialATA
        ST*******ASQ                          
    USB
        officejet 4200 series (Hewlett Packard)
    Bluetooth
        Apple Wireless Mouse
    FileVault 2: On FileVault master keychain appears to be installed
    FileVault 1: On
    I/O wait time (ms/s)
        launchd (UID 0): 53
    Font issues: 40
    Firewall: On
    System caches/logs
        1987 MB: /System/Library/Caches/com.apple.coresymbolicationd/data
    Diagnostic reports
        2015-01-31 SecurityAgent crash
        2015-02-01 2BUA8C4S2C.com.agilebits.onepassword4-helper crash
        2015-02-01 IMDPersistenceAgent crash
        2015-02-01 secd crash
        2015-02-20 Inkjet7 crash
        2015-02-28 IMDPersistenceAgent crash
        2015-02-28 secd crash x2
    Kernel log
        Feb 23 07:06:08 Failed to get hibernate image filename
        Feb 23 17:07:05 Failed to get hibernate image filename
        Feb 24 07:06:05 Failed to get hibernate image filename
        Feb 24 17:47:13 Failed to get hibernate image filename
        Feb 24 18:31:50 IOAudioStream[0xffffff802df40400]::clipIfNecessary() - Error: counted 1 clip more than one buffer ahead errors.
        Feb 24 19:14:41 Failed to get hibernate image filename
        Feb 24 20:56:40 Failed to get hibernate image filename
        Feb 24 22:14:14 Failed to get hibernate image filename
        Feb 24 22:38:31 Failed to get hibernate image filename
        Feb 25 06:58:23 Failed to get hibernate image filename
        Feb 25 17:40:53 Failed to get hibernate image filename
        Feb 25 21:04:27 Failed to get hibernate image filename
        Feb 25 21:31:52 Failed to get hibernate image filename
        Feb 26 07:03:06 Failed to get hibernate image filename
        Feb 26 17:06:59 Failed to get hibernate image filename
        Feb 27 06:58:56 Failed to get hibernate image filename
        Feb 27 17:02:56 Failed to get hibernate image filename
        Feb 27 19:17:20 Failed to get hibernate image filename
        Feb 27 23:04:12 Failed to get hibernate image filename
        Feb 28 10:09:19 Failed to get hibernate image filename
        Feb 28 13:07:21 Failed to get hibernate image filename
        Feb 28 14:08:38 Failed to get hibernate image filename
        Feb 28 15:11:16 Failed to get hibernate image filename
        Feb 28 16:18:21 msdosfs_fat_uninit_vol: error 6 from msdosfs_fat_cache_flush
        Feb 28 16:29:32 Failed to get hibernate image filename
    System log
            label = "2.5.4.3";
            "localized label" = "2.5.4.3";
            type = string;
            value = "courier.sandbox.push.apple.com";
        Feb 28 16:30:55 loginwindow ERROR | __50-[MCXDLauncher(Private) startNetworkChangeThread:]_block_invoke | Unable to GetMCXAgentPort
        Feb 28 16:31:09 apsd Failed entitlement check 'com.apple.private.aps-connection-initiate' for ManagedClientAgent[8424]
        Feb 28 16:31:44 apsd Failed entitlement check 'com.apple.private.aps-connection-initiate' for ManagedClientAgent[8433]
        Feb 28 16:32:36 WindowServer disable_update_timeout: UI updates were forcibly disabled by application "Mail" for over 1.00 seconds. Server has re-enabled them.
        Feb 28 16:34:16 WindowServer disable_update_timeout: UI updates were forcibly disabled by application "Finder" for over 1.00 seconds. Server has re-enabled them.
        Feb 28 16:38:37 WindowServer disable_update_timeout: UI updates were forcibly disabled by application "1Password mini" for over 1.00 seconds. Server has re-enabled them.
        Feb 28 16:38:49 WindowServer WSGetSurfaceInWindow : Invalid surface 769181205 for window 4518
        Feb 28 16:38:49 WindowServer WSGetSurfaceInWindow : Invalid surface 769181205 for window 4518
        Feb 28 16:38:56 WindowServer WSGetSurfaceInWindow : Invalid surface 1023641180 for window 4522
        Feb 28 16:38:56 WindowServer WSGetSurfaceInWindow : Invalid surface 1023641180 for window 4522
        Feb 28 16:39:06 WindowServer WSGetSurfaceInWindow : Invalid surface 1058035653 for window 4525
        Feb 28 16:39:06 WindowServer WSGetSurfaceInWindow : Invalid surface 1058035653 for window 4525
        Feb 28 16:39:22 WindowServer WSGetSurfaceInWindow : Invalid surface 996085260 for window 4530
        Feb 28 16:39:22 WindowServer WSGetSurfaceInWindow : Invalid surface 996085260 for window 4530
        Feb 28 16:39:33 WindowServer WSGetSurfaceInWindow : Invalid surface 1034343505 for window 4534
        Feb 28 16:39:33 WindowServer WSGetSurfaceInWindow : Invalid surface 1034343505 for window 4534
        Feb 28 16:39:39 Google Chrome Helper CoreText CopyFontsForRequest received mig IPC error (FFFFFFFFFFFFFECC) from font server
        Feb 28 16:39:39 Google Chrome Helper CoreText CopyFontsForRequest received mig IPC error (FFFFFFFFFFFFFECC) from font server
        Feb 28 16:46:20 apsd Failed entitlement check 'com.apple.private.aps-connection-initiate' for ManagedClientAgent[8979]
        Feb 28 16:49:02 loginwindow ERROR | __50-[MCXDLauncher(Private) startNetworkChangeThread:]_block_invoke | Unable to GetMCXAgentPort
    Daemons
        com.apple.AccountPolicyHelper
        com.apple.AssetCacheLocatorService
        com.apple.CodeSigningHelper
        com.apple.MobileFileIntegrity
        com.apple.awdd
        com.apple.backupd-auto
        com.apple.cache_delete
        com.apple.coresymbolicationd
        com.apple.ctkd
        com.apple.diagnosticd
        com.apple.emond.aslmanager
        com.apple.iconservices.iconservicesagent
        com.apple.iconservices.iconservicesd
        com.apple.ifdreader
        com.apple.installd
        com.apple.installer.osmessagetracing
        com.apple.nehelper
        com.apple.networkd_privileged
        com.apple.nsurlsessiond_privileged
        com.apple.nsurlstoraged
        com.apple.periodic-daily
        com.apple.periodic-monthly
        com.apple.periodic-weekly
        com.apple.sandboxd
        com.apple.secinitd
        com.apple.security.syspolicy
        - status: -15
        com.apple.softwareupdate_download_service
        com.apple.softwareupdated
        com.apple.spindump
        com.apple.sysmond
        com.apple.systemstatsd
        com.apple.tccd.system
        com.apple.watchdogd
        com.apple.wdhelper
        org.cups.cupsd
    Agents
        2BUA8C4S2C.com.agilebits.onepassword4-helper
        com.adobe.ARM.UUID
        com.apple.AirPortBaseStationAgent
        com.apple.imdpersistence.IMDPersistenceAgent
        - status: -10
        com.apple.secd
        - status: -10
    User crontab
        59 16 * * 7 /Applications/MacScan\ 2/MacScan.app/Contents/MacOS/MacScan -autoscan YES
    Firefox extensions
        Mozilla Firefox hotfix
    Widgets
        iCal
    iCloud errors
        cloudd 7
        comapple.InputMethodKit.UserDictionary 2
        CallHistorySyncHelper 1
    Continuity errors
        sharingd 1
    Restricted files: 174
    Lockfiles: 30
    High file counts
        Desktop: 54
    Accessibility
        Scroll Zoom: On
    Contents of /System/Library/Security/authorization.plist
        - mod date: Oct  9 02:17:00 2014
        - checksum: 2720110640
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
        <key>comment</key>
        <string>The name of the requested right is matched against the keys.  An exact match has priority, otherwise the longest match from the start is used. Note that the right will only match wildcard rules (ending in a ".") during this reduction.
        allow rule: this is always allowed
        &lt;key&gt;com.apple.TestApp.benign&lt;/key&gt;
        &lt;string&gt;allow&lt;/string&gt;
        deny rule: this is always denied
        &lt;key&gt;com.apple.TestApp.dangerous&lt;/key&gt;
        &lt;string&gt;deny&lt;/string&gt;
        user rule: successful authentication as a user in the specified group(5) allows the associated right.
        The shared property specifies whether a credential generated on success is shared with other apps (i.e., those in the same "session"). This property defaults to false if not specified.
        The timeout property specifies the maximum age of a (cached/shared) credential accepted for this rule.
        The allow-root property specifies whether a right should be allowed automatically if the requesting process is running with uid == 0.  This defaults to false if not specified.
        See remaining rules for examples.
        </string>
        <key>rights</key>
        <dict>
        <key></key>
        <dict>
        <key>class</key>
        <string>rule</string>
        <key>comment</key>
        ...and 1850 more line(s)
    Contents of /private/etc/authorization.deprecated
        - mod date: Oct 25 13:37:39 2014
        - checksum: 842352627
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
        <key>comment</key>
        <string>The name of the requested right is matched against the keys.  An exact match has priority, otherwise the longest match from the start is used. Note that the right will only match wildcard rules (ending in a ".") during this reduction.
        allow rule: this is always allowed
        &lt;key&gt;com.apple.TestApp.benign&lt;/key&gt;
        &lt;string&gt;allow&lt;/string&gt;
        deny rule: this is always denied
        &lt;key&gt;com.apple.TestApp.dangerous&lt;/key&gt;
        &lt;string&gt;deny&lt;/string&gt;
        user rule: successful authentication as a user in the specified group(5) allows the associated right.
        The shared property specifies whether a credential generated on success is shared with other apps (i.e., those in the same "session"). This property defaults to false if not specified.
        The timeout property specifies the maximum age of a (cached/shared) credential accepted for this rule.
        The allow-root property specifies whether a right should be allowed automatically if the requesting process is running with uid == 0.  This defaults to false if not specified.
        See remaining rules for examples.
        </string>
        <key>rights</key>
        <dict>
        <key></key>
        <dict>
        <key>class</key>
        <string>rule</string>
        <key>comment</key>
        ...and 1013 more line(s)
    Contents of /private/etc/pam.d/prl_disp_service
        - mod date: Mar  5 03:24:01 2010
        - checksum: 1160556194
        auth       required       pam_nologin.so
        auth       optional       pam_afpmount.so
        auth       sufficient     pam_securityserver.so nullok
        auth       sufficient     pam_unix.so  nullok
        auth       required       pam_deny.so
        account    required       pam_permit.so
        password   required       pam_deny.so
        session    required       pam_permit.so
        session    optional       pam_afpmount.so
    Contents of /private/etc/pam.d/prl_disp_service.snow_leopard
        - mod date: Mar  5 03:24:01 2010
        - checksum: 2633576920
        auth       optional       pam_krb5.so
        auth       optional       pam_mount.so
        auth       sufficient     pam_serialnumber.so serverinstall legacy
        auth       required       pam_opendirectory.so
        account    required       pam_nologin.so
        account    required       pam_opendirectory.so
        password   required       pam_deny.so
        session    required       pam_launchd.so
        session    required       pam_uwtmp.so
        session    optional       pam_mount.so
        auth       optional       pam_krb5.so
        auth       optional       pam_mount.so
        auth       sufficient     pam_serialnumber.so serverinstall legacy
        auth       required       pam_opendirectory.so
        account    required       pam_nologin.so
        account    required       pam_opendirectory.so
        password   required       pam_deny.so
        session    required       pam_launchd.so
        session    required       pam_uwtmp.so
        session    optional       pam_mount.so
    Contents of Library/LaunchAgents/com.adobe.ARM.UUID.plist
        - mod date: Aug  1 17:37:19 2012
        - checksum: 408149527
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
        <key>Label</key>
        <string>com.adobe.ARM.UUID</string>
        <key>ProgramArguments</key>
        <array>
        <string>/Applications/Adobe Reader.app/Contents/MacOS/Updater/Adobe Reader Updater Helper.app/Contents/MacOS/Adobe Reader Updater Helper</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>12600</integer>
        </dict>
        </plist>
    Applications
        /Applications/Acrobat 6.0 Professional/Acrobat 6.0.2 Professional.app
        - N/A
        /Applications/Acrobat 6.0 Professional/Acrobat Distiller 6.0.2.app
        - com.adobe.distiller
        /Applications/Adobe/Acrobat.com.app
        - com.adobe.mauby.UUID.1
        /Applications/Adobe/Adobe Help.app
        - chc.UUID.1
        /Applications/Bible Explorer 4.app
        - com.BE8.wordsearchbible.corp
        /Applications/DivX Converter.app
        - N/A
        /Applications/DivX Player.app
        - com.divx.DivX_Player
        /Applications/DivX/DivX Community.app
        - com.spritec.DVD
        /Applications/DivX/DivX Products.app
        - com.spritec.DVD
        /Applications/DivX/DivX Support.app
        - com.spritec.DVD
        /Applications/DivX/Uninstall DivX for Mac.app
        - com.divxinc.uninstalldivxformac
        /Applications/FOX News Live.app
        - FoxPlayerAIR.UUID.1
        /Applications/Flip4Mac/WMV Player.app
        - net.telestream.wmv.player
        /Applications/Garmin Express.app
        - com.garmin.renu.client
        /Applications/Garmin WebUpdater.app
        - com.garmin.WebUpdater
        /Applications/Hewlett-Packard/HP Image Edit.app
        - com.hp.hpimageedit
        /Applications/Hewlett-Packard/HP Image Print.app
        - com.hp.photo.imageprint
        /Applications/Hewlett-Packard/HP Image Zone.app
        - com.hp.imagezone
        /Applications/Hewlett-Packard/HP Instant Share.app
        - com.hp.photo.instantshare
        /Applications/Hewlett-Packard/HP Panorama Stitching.app
        - com.hp.PanoramaStitching
        /Applications/Hewlett-Packard/HP Photo and Imaging Software/HP E-mail Portal/HP E-mail Portal
        - N/A
        /Applications/Hewlett-Packard/HP Photo and Imaging Software/HP Photo and Imaging Director/Director Docker.app
        - com.hp.director.docker
        /Applications/Hewlett-Packard/HP Software Update.app
        - com.hp.softwareupdate
        /Applications/Hewlett-Packard/HP Uninstaller
        - N/A
        /Applications/Karaoke Maker/Audacity.app
        - net.sourceforge.audacity
        /Applications/Macromedia Studio 8/Macromedia Contribute 3/Contribute
        - com.macromedia.Contribute
        /Applications/Macromedia Studio 8/Macromedia Contribute 3/Contribute/Contents/MacOS/Contribute
        - N/A
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8
        - com.macromedia.Dreamweaver
        /Applications/Macromedia Studio 8/Macromedia Extension Manager/Extension Manager.app
        - com.macromedia.ExtensionManager
        /Applications/Macromedia Studio 8/Macromedia Fireworks 8/Fireworks 8.app
        - com.macromedia.fireworks
        /Applications/Macromedia Studio 8/Macromedia Flash 8 VideoEncoder/Flash 8 Video Encoder.app
        - com.macromedia.FLVEncoder
        /Applications/Macromedia Studio 8/Macromedia Flash 8/Flash 8.app
        - com.macromedia.flash.8
        /Applications/Microsoft AutoUpdate.app
        - com.microsoft.autoupdate
        /Applications/Microsoft Office 2004/Additional Tools/Handheld Sync Installer
        - com.MindVision.VISEX
        /Applications/Microsoft Office 2004/Additional Tools/Handheld Sync Installer/Contents/MacOSClassic/Handheld Sync Installer
        - N/A
        /Applications/Microsoft Office 2004/Additional Tools/Microsoft Language Register/Microsoft Language Register
        - N/A
        /Applications/Microsoft Office 2004/Additional Tools/Remote Desktop Connection/Remote Desktop Connection
        - N/A
        /Applications/Microsoft Office 2004/Additional Tools/Remove Office/Remove Office
        - N/A
        /Applications/Microsoft Office 2004/Additional Tools/Windows Media Installer
        - N/A
        /Applications/Microsoft Office 2004/Additional Tools/Windows Media Installer/Contents/MacOS/Windows Media Installer
        - N/A
        /Applications/Microsoft Office 2004/MSN Messenger.app
        - Microsoft/com.microsoft.Messenger
        /Applications/Microsoft Office 2004/Microsoft Entourage
        - N/A
        /Applications/Microsoft Office 2004/Microsoft Excel
        - N/A
        /Applications/Microsoft Office 2004/Microsoft PowerPoint
        - N/A
        /Applications/Microsoft Office 2004/Microsoft Word
        - N/A
        /Applications/Microsoft Office 2004/Office/Alerts Daemon.app
        - Microsoft/com.microsoft.AlertsDaemon
        /Applications/Microsoft Office 2004/Office/Database Utility
        - N/A
        /Applications/Microsoft Office 2004/Office/Equation Editor
        - N/A
        /Applications/Microsoft Office 2004/Office/Microsoft Cert Manager.app
        - com.microsoft.certmgr
        /Applications/Microsoft Office 2004/Office/Microsoft Clip Gallery
        - N/A
        /Applications/Microsoft Office 2004/Office/Microsoft Database Daemon
        - N/A
        /Applications/Microsoft Office 2004/Office/Microsoft Error Reporting.app
        - com.microsoft.error_reporting
        /Applications/Microsoft Office 2004/Office/Microsoft Graph
        - N/A
        /Applications/Microsoft Office 2004/Office/Microsoft Office Notifications
        - N/A
        /Applications/Microsoft Office 2004/Office/Microsoft Query
        - N/A
        /Applications/Microsoft Office 2004/Office/Microsoft Sync Services.app
        - com.microsoft.entourage.syncservices
        /Applications/Microsoft Office 2004/Office/Organization Chart
        - N/A
        /Applications/Microsoft Office 2004/Office/Project Gallery Launcher
        - N/A
        /Applications/Open XML Converter.app
        - com.microsoft.OfficeConverter
        /Applications/OpenOffice.app
        - org.openoffice.script
        /Applications/Quicken 2007/Quicken 2007
        - com.intuit.quicken
        /Applications/Quicken 2007/Quicken 2007/Contents/MacOS/Quicken 2007
        - N/A
        /Applications/Quicken 2007/Quicken 2007/Contents/SupportApps/Emergency Records Organizer
        - com.intuit.ero
        /Applications/Quicken 2007/Quicken 2007/Contents/SupportApps/Emergency Records Organizer/Contents/MacOSClassic/Emergency Records Organizer
        - N/A
        /Applications/Quicken 2007/Quicken 2007/Contents/SupportApps/Home Inventory.app
        - com.intuit.HomeInventory
        /Applications/Quicken 2007/Quicken 2007/Contents/SupportApps/Quicken Backup Utility.app
        - com.intuit.quicken.dotmac
        /Applications/Quicken 2007/Quicken 2007/Contents/SupportApps/Quicken Scheduler
        - N/A
        /Applications/RealPlayer Converter.app
        - com.real.converter
        /Applications/RealPlayer.app
        - com.RealNetworks.RealPlayer
        /Applications/TorBrowser.app
        - N/A
        /Applications/Utilities/Adobe AIR Application Installer.app
        - com.adobe.air.ApplicationInstaller
        /Applications/Utilities/Adobe Utilities.localized/Adobe Updater6/Adobe Updater.app
        - "com.Adobe.ESD.AdobeUpdaterApplication"
        /Library/Application Support/Adobe/AdobePDF.app
        - com.Adobe.print.AdobePDF.bef
        /Library/Application Support/DivX/DivXUpdater.app
        - com.divx.DivXUpdater
        /Library/Application Support/Hewlett-Packard/Software Update/HP Rules Processor.app
        - com.hp.rulesprocessor
        /Library/Application Support/Hewlett-Packard/Software Update/HP Scheduler.app
        - com.hp.HPScheduler
        /Library/Application Support/Hewlett-Packard/Software Update/HP Software Updater
        - N/A
        /Library/Application Support/Hewlett-Packard/Software Update/HP Software Updater/Contents/MacOS/HP Software Updater
        - N/A
        /Library/Application Support/Microsoft/HV1.0/Microsoft Help Viewer.app
        - com.microsoft.helpviewer
        /Library/Application Support/Microsoft/Office Converter Support/Open XML for Charts.app
        - com.microsoft.openxml.chartconverter.app
        /Library/Application Support/Microsoft/Office Converter Support/Open XML for Excel.app
        - com.microsoft.openxml.excel.app
        /Library/Application Support/Microsoft/Office Converter Support/Open XML for Word.app
        - com.microsoft.openxml.word.app
        /Library/Application Support/Microsoft/Office Converter Support/pptfc.app
        - com.microsoft.openxml.powerpoint.app
        /Library/Application Support/Microsoft/Silverlight/OutOfBrowser/SLLauncher.app
        - com.microsoft.silverlight.sllauncher
        /Library/Application Support/Script Editor/Templates/Cocoa-AppleScript Applet.app
        - com.apple.ScriptEditor.id.cocoa-applet-template
        /Library/Application Support/Script Editor/Templates/Droplets/Droplet with Settable Properties.app
        - com.apple.ScriptEditor.id.droplet-with-settable-properties-template
        /Library/Application Support/Script Editor/Templates/Droplets/Recursive File Processing Droplet.app
        - com.apple.ScriptEditor.id.file-processing-droplet-template
        /Library/Application Support/Script Editor/Templates/Droplets/Recursive Image File Processing Droplet.app
        - com.apple.ScriptEditor.id.image-file-processing-droplet-template
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/flashplayer
        - N/A
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/fscommand/c_burn_cd.app
        - N/A
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/fscommand/c_export_images.app
        - N/A
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/fscommand/c_import_images.app
        - N/A
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/fscommand/c_panorama_stitch.app
        - N/A
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/fscommand/c_use_folders.app
        - N/A
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/fscommand/c_use_image_edit.app
        - N/A
        /Library/Documentation/Help/HP Photo and Imaging Help/shrd/fscommand/c_use_image_print.app
        - N/A
        /Library/Documentation/User Guides and Information.localized/Apple Hardware Test Read Me.app
        - com.apple.AppleHardwareTestReadMe
        /Library/Frameworks/Adobe AIR.framework/Versions/1.0/Adobe AIR Application Installer.app
        - com.adobe.air.ApplicationInstaller
        /Library/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/Template.app
        - com.adobe.air.Template
        /Library/Image Capture/Scripts/Import and View with iPhoto.app
        - com.hp.iPhoto.icautotask
        /Library/Parallels/Parallels Mounter.app
        - com.parallels.server.mounter
        /Library/Printers/hp/Fax/fax.backend
        - com.hp.fax
        /Library/Printers/hp/Fax/rastertofax.filter
        - com.hp.rastertofax
        /Library/Printers/hp/cups/filters/commandtohp.filter
        - com.hp.print.cups.filter.commandtohp
        /Library/Printers/hp/cups/filters/pdftopdf.filter
        - com.hp.print.cups.filter.pdftopdf
        /Library/Printers/hp/cups/tools/autosetup.tool
        - com.hp.print.autosetup
        /Users/USER/Library/Application Support/Google/Chrome/Default/Web Applications/_crx_bepbmhgboaologfdajaanbcjmnhjmhfn/Default bepbmhgboaologfdajaanbcjmnhjmhfn.app
        - com.google.Chrome.app.Default-bepbmhgboaologfdajaanbcjmnhjmhfn-internal
        /Users/USER/Library/Application Support/Google/Chrome/Default/Web Applications/_crx_blpcfgokakmgnkcojhhkbfbldkacnbeo/Default blpcfgokakmgnkcojhhkbfbldkacnbeo.app
        - com.google.Chrome.app.Default-blpcfgokakmgnkcojhhkbfbldkacnbeo-internal
        /Users/USER/Library/Caches/com.adobe.Reader.ARM/UUID/Adobe Reader Updater.app
        - com.adobe.ARM
        /mike's old computer/Adobe/AdobePDF.app
        - com.Adobe.print.AdobePDF.bef
        /mike's old computer/Adobe/Installers/R2/Setup.app
        - com.adobe.Installers.Setup
        /mike's old computer/Deimos Rising/Deimos Rising
        - N/A
        /mike's old computer/IA_Installers/TypingMaster_for_Mac/TypingMasterMac.app
        - N/A
        /mike's old computer/TypingMasterMac/UninstallerData/Uninstall TypingMaster for Mac.app
        - N/A
        /mike's old computer/TypingMasterMac/itutoreng.app
        - N/A
        /mike's old computer/adobe applications/Adobe GoLive CS/Adobe GoLive CS.app
        - com.adobe.GoLive
        /mike's old computer/adobe applications/Adobe Illustrator CS/2.app
        - com.adobe.illustrator
        /mike's old computer/adobe applications/Adobe InDesign CS/InDesign CS.app
        - com.adobe.InDesign
        /mike's old computer/adobe applications/Adobe InDesign CS/Plug-Ins/Online/AUMLibrary.cfm/Contents/SharedSupport/Adobe Update Manager.app
        - com.adobe.ESD.AUM
        /mike's old computer/adobe applications/Adobe Photoshop CS/Adobe ImageReady CS.app
        - com.adobe.ImageReady
        /mike's old computer/adobe applications/Adobe Photoshop CS/Adobe Photoshop CS.app
        - com.adobe.Photoshop
        /mike's old computer/adobe applications/Adobe Version Cue/Uninstall Adobe Version Cue.app
        - N/A
        /old computer stuff/At Ease Setup Folder/At Ease Setup
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Apple System Profiler
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Calculator
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Chooser
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/FaxStatus
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Graphing Calculator
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Internet Access/Browse the Internet
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Internet Access/Connect To...
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Internet Access/Mail
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Key Caps
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Note Pad
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Remote Access Status
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Scrapbook
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Sherlock
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/SimpleSound
        - N/A
        /old computer stuff/OLDIESystem Folder/Apple Menu Items/Stickies
        - N/A
        /old computer stuff/OLDIESystem Folder/Application Support/IntelliTools/Classic Sending Helper
        - N/A
        /old computer stuff/OLDIESystem Folder/Application Support/Norton AntiVirus ƒ/NAV Small Scanner
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Appearance
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Apple Menu Options
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/AppleTalk
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/ColorSync
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Configuration Manager
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Control Strip
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Date & Time
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/DialAssist
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Energy Saver
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Extensions Manager
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/File Exchange
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/File Sharing
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/General Controls
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Infrared
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Internet
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Keyboard
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Location Manager
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Memory
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Microsoft Office Manager
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Modem
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Monitors & Sound
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Mouse
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Numbers
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/QuickTime™ Settings:™ Settings:
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/QuikSync
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Remote Access
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Speech
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Startup Disk
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/TCP:IP
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Text
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Users & Groups
        - N/A
        /old computer stuff/OLDIESystem Folder/Control Panels/Web Sharing
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Application Switcher
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/ColorSync Extension
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Control Strip Extension
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Desktop PrintMonitor
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Desktop Printer Spooler
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/FBC Indexing Scheduler
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/FaxMonitor
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Find/Find by Content Indexing
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Folder Actions
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Norton Scheduler
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/PrintMonitor
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Time Synchronizer
        - N/A
        /old computer stuff/OLDIESystem Folder/Extensions/Web Sharing Extension
        - N/A
        /old computer stuff/OLDIESystem Folder/Help/Apple Help Viewer/Help Viewer
        - N/A
        /old computer stuff/OLDIESystem Folder/MacTCP DNR
        - N/A
        /old computer stuff/OLDIESystem Folder/Scripting Additions/Desktop Printer Manager
        - N/A
        /old computer stuff/OLDIESystem Folder/Scripting Additions/Network Setup Scripting
        - N/A
        /old computer stuff/OLDIESystem Folder/Scripting Additions/URL Access Scripting
        - N/A
        /old computer stuff/OLDIESystem Folder/System Extensions (Disabled)/AOL 5.0 Backup Installer
        - N/A
        /old computer stuff/Tony Hawk's Pro Skater 4/Tony Hawk's Pro Skater 4.app
        - com.aspyr.thps4
    Frameworks
        /Library/Frameworks/Adobe AIR.framework
        - com.adobe.AIR
        /Library/Frameworks/DivX Toolkit.framework
        - com.divx.divxtoolkit
        /Library/Frameworks/EWSMac.framework
        - com.eSellerate.EWSMac67108868
        /Library/Frameworks/HPSmartPrint.framework
        - com.hp.print.HPSmartPrint
        /Library/Frameworks/MacFUSE.framework
        - com.google.MacFUSE
        /Library/Frameworks/PrintMeSSL.framework
        - com.efi.printme.ssl
        /Library/Frameworks/TSLicense.framework
        - net.telestream.license
    PrefPane
        /Library/PreferencePanes/DivX.prefPane
        - com.divx.divxprefs
        /Library/PreferencePanes/Flip4Mac WMV.prefPane
        - net.telestream.wmv.prefpane
        /Library/PreferencePanes/MacFUSE.prefPane
        - com.google.MacFUSE
    Bundles
        /Library/Audio/MIDI Drivers/EmagicUSBMIDIDriver.plugin
        - info.emagic.driver.unitor
        /Library/Contextual Menu Items/ParallelsCM.plugin
        - com.parallels.cmplugin
        /Library/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/AdobeCP15.plugin
        - com.adobe.adobecp
        /Library/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/Flash Player.plugin
        - com.macromedia.FlashPlayer-10.6.plugin
        /Library/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/adobecp.plugin
        - com.adobe.adobecp20
        /Library/Internet Plug-Ins/AdobePDFViewer.plugin
        - com.adobe.acrobat.pdfviewer
        /Library/Internet Plug-Ins/AdobePDFViewerNPAPI.plugin
        - com.adobe.acrobat.pdfviewerNPAPI
        /Library/Internet Plug-Ins/DivXBrowserPlugin.plugin
        - com.divx.DivXBrowserPlugin
        /Library/Internet Plug-Ins/Flip4Mac WMV Plugin.plugin
        - net.telestream.wmv.plugin
        /Library/Internet Plug-Ins/GarminGpsControl.plugin
        - com.garmin.GarminGpsControl
        /Library/Internet Plug-Ins/Google Earth Web Plug-in.plugin
        - com.Google.GoogleEarthPlugin.plugin
        /Library/Internet Plug-Ins/Silverlight.plugin
        - com.microsoft.SilverlightPlugin
        /Library/Internet Plug-Ins/googletalkbrowserplugin.plugin
        - com.google.googletalkbrowserplugin
        /Library/Internet Plug-Ins/iPhotoPhotocast.plugin
        - com.apple.plugin.iPhotoPhotocast
        /Library/Internet Plug-Ins/o1dbrowserplugin.plugin
        - com.google.o1dbrowserplugin
        /Library/Printers/Macromedia/PDEs/FlashPaperPDE.plugin
        - com.macromedia.flashpaper.pde.FlashPaperPDE
        /Library/Printers/PPD Plugins/AdobePDFPDE.plugin
        - com.Adobe.print.AdobePDF.pde
        /Library/QuickLook/GBQLGenerator.qlgenerator
        - com.apple.garageband.quicklookgenerator
        /Library/QuickLook/ParallelsQL.qlgenerator
        - com.parellels.quicklookgenerator
        /Library/Spotlight/GBSpotlightImporter.mdimporter
        - com.apple.garageband.spotlightimporter
        /Library/Spotlight/Microsoft Entourage.mdimporter
        - com.microsoft.entourageMDImporter
        /Library/Spotlight/ParallelsMD.mdimporter
        - com.parallels.mdimporter
        /Users/USER/Library/Application Support/Google/Chrome/PepperFlash/12.0.0.70/PepperFlashPlayer.plugin
        - com.macromedia.PepperFlashPlayer.pepper
        /Users/USER/Library/Internet Plug-Ins/CitrixOnlineWebDeploymentPlugin.plugin
        - com.citrixonline.mac.WebDeploymentPlugin
    Library paths
        /Applications/Karaoke Maker/libmp3lame.dylib
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8/Contents/Frameworks/libwchar.dylib
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8/Contents/MacOS/CoreTypes.dylib
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8/Contents/MacOS/LibCURL.dylib
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8/Contents/MacOS/LibCrypto.dylib
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8/Contents/MacOS/LibSSL.dylib
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8/Contents/MacOS/SystemFrameworkUtils.dylib
        /Applications/Macromedia Studio 8/Macromedia Dreamweaver 8/Dreamweaver 8/Contents/MacOS/ZLib.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/DWA/DWANative.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/DWA/resources/libraries/ARKCmdCaps.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/DWA/resources/libraries/ARKCmdFS.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/DWA/resources/libraries/ARKEngine.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/DWA/resources/libraries/AdobePIM.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/LWA/PWANative.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/LWA/adobe_caps.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/LWA/adobe_oobelib.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/LWA/adobe_upgrade.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/UWA/UWANative.dylib
        /Library/Application Support/Adobe/OOBE/PDApp/core/AdobePIM.dylib
        /Library/Application Support/DivX/Libraries/libDivXDesktopSupport.dylib
        /Library/Application Support/DivX/QtPlugins/accessible/libqtaccessiblewidgets.dylib
        /Library/Application Support/DivX/QtPlugins/iconengines/libqsvgicon.dylib
        /Library/Application Support/DivX/QtPlugins/imageformats/libqgif.dylib
        /Library/Application Support/DivX/QtPlugins/imageformats/libqico.dylib
        /Library/Application Support/DivX/QtPlugins/imageformats/libqjpeg.dylib
        /Library/Application Support/DivX/QtPlugins/imageformats/libqmng.dylib
        /Library/Application Support/DivX/QtPlugins/imageformats/libqsvg.dylib
        /Library/Application Support/DivX/QtPlugins/imageformats/libqtiff.dylib
        /Library/Application Support/DivX/QtPlugins/script/libqtscriptdbus.dylib
        /Library/Application Support/DivX/QtPlugins/sqldrivers/libqsqlite.dylib
        /Library/Frameworks/Adobe AIR.framework/Versions/1.0/Resources/WebKit.dylib
        /Library/Frameworks/MacFUSE.framework/Versions/A/Resources/Debug/libfuse.dylib. dSYM/Contents/Resources/DWARF/libfuse.dylib
        /Library/Frameworks/MacFUSE.framework/Versions/A/Resources/Debug/libfuse_ino64. dylib.dSYM/Contents/Resources/DWARF/libfuse_ino64.dylib
        /Library/Printers/hp/Frameworks/HPDeviceModel.framework/Versions/3.0/Frameworks /Core.framework/Versions/3.0/Libraries/libHPIOnetsnmp.5.dylib
        /Library/Printers/hp/Frameworks/HPSmartX.framework/Versions/B/Resources/lib/SxC FReader.dylib
        /Library/Printers/hp/Frameworks/HPSmartX.framework/Versions/C/Resources/lib/SxC FReader.dylib
        /Users/USER/Library/Application Support/AOL Desktop/Security/libnspr4.dylib
        /Users/USER/Library/Application Support/AOL Desktop/Security/libnssckbi.dylib
        /Users/USER/Library/Application Support/AOL Desktop/Security/libplc4.dylib
        /Users/USER/Library/Application Support/AOL Desktop/Security/libplds4.dylib
        /Users/USER/Library/Application Support/Firefox/Profiles/w5owlxqa.default/gmp-gmpopenh264/1.1/libgmpopenh264.dy lib
        /Users/USER/Library/Application Support/Google/Chrome/WidevineCDM/1.4.6.758/_platform_specific/mac_x64/libwidev inecdm.dylib
        /Users/USER/Library/Caches/com.apple.ScreenSaver.Engine/com.apple.vision/com.ap ple.vision.64FaceCoreCLKernel.dylib
        /mike's old computer/adobe applications/Adobe Version Cue/libpbodbc3.dylib
        /mike's old computer/adobe applications/Adobe Version Cue/libps-gcc2-v8_50.dylib
        /mike's old computer/adobe applications/Adobe Version Cue/libps-jni-gcc2-v8_50.dylib
        /mike's old computer/adobe applications/Adobe Version Cue/libps-pb-gcc2-v8_50.dylib
        /mike's old computer/adobe applications/Adobe Version Cue/libps-rw-gcc2-v8_50.dylib
        /mike's old computer/adobe applications/Adobe Version Cue/libps-util-gcc2-v8_50.dylib
        /mike's old computer/adobe applications/Adobe Version Cue/tomcat/webapps/ROOT/WEB-INF/components/com.adobe.bauhaus.nativecomm/res/VCF oundation.dylib
        /usr/lib/libgutenprint.2.0.3.dylib
        /usr/local/lib/libfreetype.6.3.16.dylib
        /usr/local/lib/libfreetype.6.dylib
        /usr/local/lib/libfreetype.dylib
        /usr/local/lib/libfuse.2.dylib
        /usr/local/lib/libfuse_ino64.2.dylib
    Installations
        Norton AntiVirus Application: 6/20/10, 10:21 PM
        Symantec Scheduler: 6/20/10, 10:21 PM
        Microsoft® Silverlight™ Browser Plug-In: 6/19/10, 8:25 PM
        Parallels Desktop 5 for Mac: 6/10/10, 6:02 AM
        MacFUSE Core: 6/10/10, 6:03 AM
    Elapsed time (sec): 317
    <Edited By Host>

  • Problem with JTextPane and StateInvariantError

    Hi. I am having a problem with JTextPanes and changing only certain text to bold. I am writing a chat program and would like to allow users to make certain text in their entries bold. The best way I can think of to do this is to add <b> and </b> tags to the beginning and end of any text that is to be bold. When the other client receives the message, the program will take out all of the <b> and </b> tags and display any text between them as bold (or italic with <i> and </i>). I've searched the forums a lot and figured out several ways to make the text bold, and several ways to determine which text is bold before sending the text, but none that work together. Currently, I add the bold tags with this code: (note: messageDoc is a StyledDocument and messageText is a JTextPane)
    public String getMessageText() {
              String text = null;
              boolean bold = false, italic = false;
              for (int i = 0; i < messageDoc.getLength(); i++) {
                   messageText.setCaretPosition(i);
                   if (StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && !bold) {
                        bold = true;
                        if (text != null) {
                             text = text + "<b>";
                        else {
                             text = "<b>";
                   else if (StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && bold) {
                        // Do nothing
                   else if (!StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && bold) {
                        bold = false;
                        if (text != null) {
                             text = text + "</b>";
                        else {
                             text = "</b>";
                   try {
                        if (text != null) {
                             text = text + messageDoc.getText(i,1);
                        else {
                             text = messageDoc.getText(i, 1);
                   catch (BadLocationException e) {
                        System.out.println("An error occurred while getting the text from the message document");
                        e.printStackTrace();
              return text;
         } // end getMessageText()When the message is sent to the other client, the program searches through the received message and changes the text between the bold tags to bold. This seems as if it should work, but as soon as I click on the bold button, I get a StateInvariantError. The code for my button is:
    public void actionPerformed(ActionEvent evt) {
              if (evt.getSource() == bold) {
                   MutableAttributeSet bold = new SimpleAttributeSet();
                   StyleConstants.setBold(bold, true);
                   messageText.getStyledDocument().setCharacterAttributes(messageText.getSelectionStart(), messageText.getSelectionStart() - messageText.getSelectionEnd() - 1, bold, false);
         } //end actionPerformed()Can anyone help me to figure out why this error is being thrown? I have searched for a while to figure out this way of doing what I'm trying to do and I've found out that a StateInvariantError has been reported as a bug in several different circumstances but not in relation to this. Or, if there is a better way to add and check the style of the text that would be great as well. Any help is much appreciated, thanks in advance.

    Swing related questions should be posted in the Swing forum.
    Can't tell from you code what the problem is because I don't know the context of how each method is invoked. But it would seem like you are trying to query the data in the Document while the Document is being updated. Try wrapping the getMessageText() method is a SwingUtilities.invokeLater().
    There is no need to write custom code for a Bold Action you can just use:
    JButton bold = new JButton( new StyledEditorKit.BoldAction() );Also your code to build the text String is not very efficient. You should not be using string concatenation to append text to the string. You should be using a StringBuffer or StringBuilder.

  • How to give styles to my HTMLDocument inside a JTextPane?

    I have a JTextPane with a HTMLDocument attached to it. How can I style the text which is typed in? For example I want to set a larger font. How can I do this in my example?
    Another problem is that when I hit the alignment buttons the text is actually aligned according to the hit button but the JEditorPane doesn't show the text correctly. It also doesn't enter a line feed when typing ENTER key.
    Can someone help me on this please?
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.IOException;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextPane;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.html.HTMLDocument;
    import javax.swing.text.html.HTMLEditorKit;
    public class AdditionalText extends JFrame implements ActionListener {
         private JButton leftAlign;
         private JButton centerAlign;
         private JButton rightAlign;
         private JTextPane editor;
         private JButton save;
         private JButton dump;
         public AdditionalText() {
              setTitle("Test Frame");
              JPanel topToolbar = new JPanel();
              leftAlign = new JButton("Left");
              centerAlign = new JButton("Center");
              rightAlign = new JButton("Right");
              ActionListener alignLeft = new HTMLEditorKit.AlignmentAction("alignLeft", 0);
              ActionListener alignCenter = new HTMLEditorKit.AlignmentAction("alignCenter", 1);
              ActionListener alignRight = new HTMLEditorKit.AlignmentAction("alignRight", 2);
              leftAlign.addActionListener(alignLeft);
              centerAlign.addActionListener(alignCenter);
              rightAlign.addActionListener(alignRight);
              topToolbar.add(leftAlign);
              topToolbar.add(centerAlign);
              topToolbar.add(rightAlign);
              editor = createEditor();
              JPanel bottomToolbar = new JPanel();
              save = new JButton("Save");
              save.addActionListener(this);
              dump = new JButton("Dump");
              dump.addActionListener(this);
              bottomToolbar.add(save);
              bottomToolbar.add(dump);
              getContentPane().add(BorderLayout.NORTH, topToolbar);
              getContentPane().add(BorderLayout.CENTER, editor);
              getContentPane().add(BorderLayout.SOUTH, bottomToolbar);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              setSize(new Dimension(640, 480));
              setLocation((screenSize.width - 640) / 2, (screenSize.height - 480) / 2);
         private JTextPane createEditor() {
              JTextPane textPane = new JTextPane() {
                   public void paintComponent(Graphics g) {
                        Graphics2D g2 = (Graphics2D) g;
                        g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
                        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                        g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
                        g2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
                        g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
                        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
                        g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
                        g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
                        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                        super.paintComponent(g2);
              textPane.setEditorKit(new HTMLEditorKit());
              return textPane;
         public void actionPerformed(ActionEvent e) {
              HTMLDocument htmlDocument = (HTMLDocument) editor.getDocument();
              if(e.getSource() == save) {
                   HTMLEditorKit kit = (HTMLEditorKit)editor.getEditorKitForContentType("text/html");
                   try {
                        kit.write(System.out, htmlDocument, 0, htmlDocument.getLength());
                   } catch (IOException ex) {
                        ex.printStackTrace();
                   } catch (BadLocationException ex) {
                        ex.printStackTrace();
              } else if(e.getSource() == dump) {
                   htmlDocument.dump(System.err);
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (ClassNotFoundException e) {
                   e.printStackTrace();
              } catch (InstantiationException e) {
                   e.printStackTrace();
              } catch (IllegalAccessException e) {
                   e.printStackTrace();
              } catch (UnsupportedLookAndFeelException e) {
                   e.printStackTrace();
              AdditionalText at = new AdditionalText();
              at.show();
    }

    I created a class that can be used to highlight Java source code. Most of the code is for handling multi line comments. If you just want it to highlight certain keywords then you can get rid of all that logic. In case your interested, the code can be downloaded from here:
    http://www.discoverteenergy.com/files/SyntaxDocument.java

  • It takes a long time to open up documents on my Imac. I get the multicolor circle for a long time. I have 27 In Mid 2010 3.2 ghz Intel core I3 with 16 gb memory.

    It takes a long time to open up documents on my Imac. I get the multicolor circle for a long time. I have 27 In Mid 2010 3.2 ghz Intel core I3 with 16 gb memory.

    There are file hidden all around in your system.
    Go to Phil Stokes' info page, for a gerat uninstall primer.

  • Multi-document Application using JTextPane - Issue

    Hi.
    I'm making a java IDE as a class assignment where the user opens a certain project and all associated files open (i.e. all files in the requested folder). Opening is not an issue but here's the real problem. When a file opens (in the JTextPane), the user should be able to edit it. Although my program enables this, what also happens is that if the user switches onto viewing another file (i.e. clicking a file name from a tree in the file pane) the previously open file obviously closes and nothing is saved. I don't want to save the users edits in the actual file until and unless the user themselves click save, but 'd like the application to store the intermediate state of documents until a save request or until the program is terminated. Is there any easy way of doing this?
    Thanks.

    {color:#000080}Cross posting.{color}
    http://forum.java.sun.com/thread.jspa?threadID=5217794&tstart=0
    {color:#000080}Cross posting is rude.
    db{color}

  • How to prevent JTextPane from inserting newline on setText(longLine)

    Hi all, I have seen some posts (referenced below) regarding
    JTextPane and turning off line wrap. I tried these but still
    have some unwanted behavior.
    If I insert long html content that has no CRs in it into a JTextPane,
    using setText(...)
    and then immediatly call getText()
    I get back my html content with CRs in it.
    how can I prevent this????
    In the code below, I insert a long line (html), then call getText()
    and JTextPane has inserted a CR after the ffff
    visually , in the gui, it did not put a line break there, which is great, but
    somewhere in the document model it was inserted
    I have code that would break if there are newlines in
    strange places like that.
    I DO want the html markup from the call to JTextPane.getText()
    but not with the additional newlines.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.text.html.*;
    import javax.swing.text.*;
    import javax.swing.border.*;
    import java.io.*;
    import java.awt.datatransfer.*;
    public class MyTextPane extends JTextPane implements MouseListener, ActionListener {
           static final long serialVersionUID = 1;
           private JPopupMenu popupMenu = null;
           private JMenuItem  cutMenuItem = null;
           private JMenuItem  copyMenuItem = null;
           private JMenuItem  pasteMenuItem = null;
           private JMenuItem  clearMenuItem = null;
           //private JMenuItem  selectAllMenuItem = null;
           private int startSelectionPosition = -1;
           private int endSelectionPosition = -1;
           private boolean bTopSeperatorInserted = false;
           private int topMenuItemInsertionIndex = 0;
           public MyTextPane() {
             super();
             init();
           private void init() {
             addMouseListener(this);
             java.awt.Font font = new java.awt.Font("Dialog", java.awt.Font.PLAIN, 14);
             setFont(font);
             createAndConfigurePopupMenu();
             startNewDocument();
             A FocusListener is also added to our editor. The two methods of this listener, focusGained() and
             focusLost(), will be invoked when the editor gains and loses the focus respectively. The purpose of
             this implementation is to save and restore the starting and end positions of the text selection.
             The reason? -> Swing supports only one text selection at any given time. This means
             that if the user selects some text in the editor component to modify it's attributes, and then goes
             off and makes a text selection in some other component, the original text selection will disappear.
             This can potentially be very annoying to the user. To fix this problem I'll save the selection before
             the editor component loses the focus. When the focus is gained we restore the previously saved selection.
             I'll distinguish between two possible situations: when the caret is located at the beginning of the
             selection and when it is located at the end of the selection. In the first case, position the
             caret at the end of the stored interval with the setCaretPosition() method, and then move the
             caret backward to the beginning of the stored interval with the moveCaretPosition() method.
             The second situation is easily handled using the select() method.
             FocusListener focusListener = new FocusListener() {
               public void focusGained(FocusEvent e) {
                 int len = getDocument().getLength();
                 if (startSelectionPosition>=0 &&
                     endSelectionPosition>=0 &&
                     startSelectionPosition<len &&
                     endSelectionPosition<len)
                   if (getCaretPosition() == startSelectionPosition) {
                     setCaretPosition(endSelectionPosition);
                     moveCaretPosition(startSelectionPosition);
                   else
                     select(startSelectionPosition, endSelectionPosition);
               public void focusLost(FocusEvent e) {
                 startSelectionPosition = getSelectionStart();
                 endSelectionPosition = getSelectionEnd();
             addFocusListener(focusListener);
             // CONTROL+ALT+S to view HTML source and change it
             Action viewSourceAction = new ViewSourceAction();
             getActionMap().put("viewSourceAction", viewSourceAction);
             InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
             KeyStroke keyStroke = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
                                                     InputEvent.CTRL_MASK+InputEvent.ALT_MASK);
             inputMap.put(keyStroke, "viewSourceAction");
           // if a merge tag is at the end of a long line, JTextPane
           // inserts CR/LF into the middle of the merge tag, like this
           // "this is a really long line and at the end is a merge tag <merge \r\n name="Case ID"/>"
           // We need to turn off line wrapping to prevent this.
           // see http://forum.java.sun.com/thread.jspa?forumID=57&threadID=326017
           // overriding setSize(..) and getScrollableTracksViewportWidth()
           public void setSize(Dimension d)
               if (d.width < getParent().getSize().width)
                   d.width = getParent().getSize().width;
               super.setSize(d);
           public boolean getScrollableTracksViewportWidth() { return false; }
           class ViewSourceAction extends AbstractAction
             public void actionPerformed(ActionEvent e)
               try {
                 HTMLEditorKit m_kit = (HTMLEditorKit)MyTextPane.this.getEditorKit();
                 HTMLDocument m_doc = (HTMLDocument)MyTextPane.this.getDocument();
                 StringWriter sw = new StringWriter();
                 m_kit.write(sw, m_doc, 0, m_doc.getLength());
                 sw.close();
                 HtmlSourceDlg dlg = new HtmlSourceDlg(null, sw.toString());
                 dlg.setVisible(true);
                 if (!dlg.succeeded())
                   return;
                 StringReader sr = new StringReader(dlg.getSource());
                 m_doc = createDocument();
                 m_kit.read(sr, m_doc, 0);
                 sr.close();
                 setDocument(m_doc);
               catch (Exception ex) {
                 ex.printStackTrace();
           private HTMLDocument createDocument() {
             HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
             StyleSheet styles = htmlEditorKit.getStyleSheet();
             StyleSheet ss = new StyleSheet();
             ss.addStyleSheet(styles);
             HTMLDocument doc = new HTMLDocument(ss);
             //doc.setParser(htmlEditorKit.getParser());
             //doc.setAsynchronousLoadPriority(4);
             //doc.setTokenThreshold(100);
             return doc;
           public Element getElementByTag(HTML.Tag tag) {
             HTMLDocument htmlDocument = (HTMLDocument)getDocument();
             Element root = htmlDocument.getDefaultRootElement();
             return getElementByTag(root, tag);
           public Element getElementByTag(Element parent, HTML.Tag tag) {
             if (parent == null || tag == null)
               return null;
             for (int k=0; k<parent.getElementCount(); k++) {
               Element child = parent.getElement(k);
               if (child.getAttributes().getAttribute(
                   StyleConstants.NameAttribute).equals(tag))
                 return child;
               Element e = getElementByTag(child, tag);
               if (e != null)
                 return e;
             return null;
           public void mouseClicked(MouseEvent e){}
           public void mouseEntered(MouseEvent e){}
           public void mouseExited(MouseEvent e){}
           public void mouseReleased(MouseEvent e){}
           public void mousePressed(MouseEvent e)
             if (e.getModifiers() == MouseEvent.BUTTON3_MASK)
               Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
               if (cb.getContents(this) == null || !isEditable() || !isEnabled()) {
                 pasteMenuItem.setEnabled(false);
               } else {
                 pasteMenuItem.setEnabled(true);
               if (getSelectedText() == null) {
                 copyMenuItem.setEnabled(false);
                 cutMenuItem.setEnabled(false);
               } else {
                 copyMenuItem.setEnabled(true);
                 if ((getBorder() == null) || !isEditable() || !isEnabled()) {
                   cutMenuItem.setEnabled(false);
                 } else {
                   cutMenuItem.setEnabled(true);
               popupMenu.show(this,e.getX(),e.getY());
           public JPopupMenu getPopupMenu() { return popupMenu; }
            * Creates the Popup menu with Cut,Copy,Paste
            * menu items if it hasn't already been created.
           private void createAndConfigurePopupMenu() {
             popupMenu = new JPopupMenu();
             clearMenuItem = new JMenuItem(new ClearAction());
             clearMenuItem.setText("Clear");
             //selectAllMenuItem = new JMenuItem(new SelectAllAction());
             //selectAllMenuItem.setText("Select All");
             cutMenuItem = new JMenuItem(new DefaultEditorKit.CutAction());
             cutMenuItem.setText("Cut");
             copyMenuItem = new JMenuItem(new DefaultEditorKit.CopyAction());
             copyMenuItem.setText("Copy");
             // when pasting, only paste the plain text (not any markup)
             PasteAction pasteAction = new PasteAction();
             pasteMenuItem = new JMenuItem(/*new DefaultEditorKit.PasteAction()*/);
             pasteMenuItem.addActionListener(pasteAction);
             pasteMenuItem.setText("Paste");
             popupMenu.add(cutMenuItem);
             popupMenu.add(copyMenuItem);
             popupMenu.add(pasteMenuItem);
             popupMenu.add(new JPopupMenu.Separator());
             popupMenu.add(clearMenuItem);
             //popupMenu.add(selectAllMenuItem);
             setKeyStrokes();
           private void doPasteAction()
               Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
               Transferable content = cb.getContents(this);
               try {
                   // when pasting, discard the markup
                   String s = (String)content.getTransferData(DataFlavor.stringFlavor);
                   HTMLDocument doc = (HTMLDocument)MyTextPane.this.getDocument();
                   HTMLEditorKit kit = (HTMLEditorKit)MyTextPane.this.getEditorKit();
                   doc.insertString(MyTextPane.this.getCaretPosition(),
                                    s,
                                    kit.getInputAttributes());
               catch (Throwable exc) {
                   exc.printStackTrace();
           class PasteAction implements ActionListener
               public void actionPerformed(ActionEvent e) {
                   doPasteAction();
            * Sets the short cut keys and actions for corresponding actions for keys.
           private void setKeyStrokes() {
               KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V,
                                                        KeyEvent.CTRL_MASK);
               /** Performs pasteAction when short-cut key paste action is performed */
               Action pasteAction = new AbstractAction() {
                    * Handles user clicked actions.
                    * @param actionEvent -
                    *            ActionEvent object.
                   public void actionPerformed(ActionEvent actionEvent) {
                       doPasteAction();
               InputMap inputMap = getInputMap(JTextPane.WHEN_FOCUSED);
               getActionMap().put(inputMap.get(paste), pasteAction);
           public void actionPerformed(ActionEvent e) {
              if(e.getActionCommand().equals("Select All"))
                selectAll();
              else if(e.getActionCommand().equals("Clear"))
                clear();
           public void append(String s) {
             super.setText( getText() + s );
           public void clear() {
             startNewDocument();
           public void startNewDocument() {
             HTMLEditorKit editorKit = new HTMLEditorKit();
             setContentType("text/html");
             setEditorKit(editorKit);
             HTMLDocument document = (HTMLDocument) editorKit.createDefaultDocument();
             setDocument(document);
             // to enable the copy and paste from ms word (and others) to the JTextPane, set
             // this client property. Sun Bug ID: 4765240
             document.putProperty("IgnoreCharsetDirective",Boolean.TRUE);
             document.setPreservesUnknownTags(false);
           class ClearAction extends AbstractAction{
             public void actionPerformed(ActionEvent e) {
               startNewDocument();
           class SelectAllAction extends AbstractAction{
             public void actionPerformed(ActionEvent e) {
               selectAll();
           class HtmlSourceDlg extends JDialog {
             protected boolean m_succeeded = false;
             protected JTextArea m_sourceTxt;
             public HtmlSourceDlg(JFrame parent, String source) {
               super(parent, "HTML Source", true);
               JPanel pp = new JPanel(new BorderLayout());
               pp.setBorder(new EmptyBorder(10, 10, 5, 10));
               m_sourceTxt = new JTextArea(source, 20, 60);
               m_sourceTxt.setFont(new Font("Courier", Font.PLAIN, 12));
               JScrollPane sp = new JScrollPane(m_sourceTxt);
               pp.add(sp, BorderLayout.CENTER);
               JPanel p = new JPanel(new FlowLayout());
               JPanel p1 = new JPanel(new GridLayout(1, 2, 10, 0));
               JButton bt = new JButton("Save");
               ActionListener lst = new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                   m_succeeded = true;
                   dispose();
               bt.addActionListener(lst);
               p1.add(bt);
               bt = new JButton("Cancel");
               lst = new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                   dispose();
               bt.addActionListener(lst);
               p1.add(bt);
               p.add(p1);
               pp.add(p, BorderLayout.SOUTH);
               getContentPane().add(pp, BorderLayout.CENTER);
               pack();
               setResizable(true);
               setLocationRelativeTo(parent);
             public boolean succeeded() {
               return m_succeeded;
             public String getSource() {
               return m_sourceTxt.getText();
           public void addToPopupMenuAboveEditItems(JMenuItem menuItem)
             if (!bTopSeperatorInserted) {
               popupMenu.insert(new JPopupMenu.Separator(), 0);
               bTopSeperatorInserted = true;
             popupMenu.insert(menuItem, topMenuItemInsertionIndex);
             ++topMenuItemInsertionIndex;
           public static void main(String args[])
             JFrame frame = new JFrame("MyTextPane");
             MyTextPane textPane = new MyTextPane();
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             JScrollPane scrollPane = new JScrollPane(textPane);        
             String s = "<p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj aaaaaaaaaaaaaaaaaaaaaaa</p>";        
             System.out.println("\nthe long string prior to calling JTextPane.setText(..) WITH NO NEWLINES\ns=" +s);
             textPane.setText(s);
             System.out.println("\n\nthe text returned from calling JTextPane.setText(..) -> it inserted CR & newline after the ffff\n");
             System.out.println("textPane.getText()=" +textPane.getText());
             frame.getContentPane().add(scrollPane,BorderLayout.CENTER);
             frame.setSize(500, 700);
             frame.setVisible(true);
         }http://forum.java.sun.com/thread.jspa?threadID=356749&messageID=3012080
    and
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=326017
    Edited by: henryhamster on Sep 13, 2007 8:59 PM

    ok, I found a somewhat work around. calling JTextPane.getText() eventually
    invokes HTMLEditorKit.write()
    which does code
    HTMLWriter w = new HTMLWriter(out, (HTMLDocument)doc, pos, len);
    w.write();the HTMLWriter() constructor above makes this call
    setLineLength(80);
    So If I extend some classes (JEditorKit and HTMLWriter) I can call invoke
    htmlWriter.setLineLength(1000); // ridiculous length to prevent insertion of CR/LF
    here is the hack, can someone please tell
    me there is an easier way. :-)
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.text.html.*;
    import javax.swing.text.*;
    import javax.swing.border.*;
    import java.io.*;
    import java.awt.datatransfer.*;
    public class MyTextPane extends JTextPane implements MouseListener,
              ActionListener {
         static final long serialVersionUID = 1;
         private JPopupMenu popupMenu = null;
         private JMenuItem cutMenuItem = null;
         private JMenuItem copyMenuItem = null;
         private JMenuItem pasteMenuItem = null;
         private JMenuItem clearMenuItem = null;
         // private JMenuItem selectAllMenuItem = null;
         private int startSelectionPosition = -1;
         private int endSelectionPosition = -1;
         private boolean bTopSeperatorInserted = false;
         private int topMenuItemInsertionIndex = 0;
         public MyTextPane() {
              super();
              init();
         private void init() {
              addMouseListener(this);
              java.awt.Font font = new java.awt.Font("Dialog", java.awt.Font.PLAIN,
                        14);
              setFont(font);
              createAndConfigurePopupMenu();
              startNewDocument();
               * A FocusListener is also added to our editor. The two methods of this
               * listener, focusGained() and focusLost(), will be invoked when the
               * editor gains and loses the focus respectively. The purpose of this
               * implementation is to save and restore the starting and end positions
               * of the text selection. The reason? -> Swing supports only one text
               * selection at any given time. This means that if the user selects some
               * text in the editor component to modify it's attributes, and then goes
               * off and makes a text selection in some other component, the original
               * text selection will disappear. This can potentially be very annoying
               * to the user. To fix this problem I'll save the selection before the
               * editor component loses the focus. When the focus is gained we restore
               * the previously saved selection. I'll distinguish between two possible
               * situations: when the caret is located at the beginning of the
               * selection and when it is located at the end of the selection. In the
               * first case, position the caret at the end of the stored interval with
               * the setCaretPosition() method, and then move the caret backward to
               * the beginning of the stored interval with the moveCaretPosition()
               * method. The second situation is easily handled using the select()
               * method.
              FocusListener focusListener = new FocusListener() {
                   public void focusGained(FocusEvent e) {
                        int len = getDocument().getLength();
                        if (startSelectionPosition >= 0 && endSelectionPosition >= 0
                                  && startSelectionPosition < len
                                  && endSelectionPosition < len) {
                             if (getCaretPosition() == startSelectionPosition) {
                                  setCaretPosition(endSelectionPosition);
                                  moveCaretPosition(startSelectionPosition);
                             } else
                                  select(startSelectionPosition, endSelectionPosition);
                   public void focusLost(FocusEvent e) {
                        startSelectionPosition = getSelectionStart();
                        endSelectionPosition = getSelectionEnd();
              addFocusListener(focusListener);
              // CONTROL+ALT+S to view HTML source and change it
              Action viewSourceAction = new ViewSourceAction();
              getActionMap().put("viewSourceAction", viewSourceAction);
              InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
              KeyStroke keyStroke = KeyStroke.getKeyStroke(
                        java.awt.event.KeyEvent.VK_S, InputEvent.CTRL_MASK
                                  + InputEvent.ALT_MASK);
              inputMap.put(keyStroke, "viewSourceAction");
         // if a merge tag is at the end of a long line, JTextPane
         // inserts CR/LF into the middle of the merge tag, like this
         // "this is a really long line and at the end is a merge tag <merge \r\n
         // name="Case ID"/>"
         // We need to turn off line wrapping to prevent this.
         // see http://forum.java.sun.com/thread.jspa?forumID=57&threadID=326017
         // overriding setSize(..) and getScrollableTracksViewportWidth()
         public void setSize(Dimension d) {
              if (d.width < getParent().getSize().width)
                   d.width = getParent().getSize().width;
              super.setSize(d);
         public boolean getScrollableTracksViewportWidth() {
              return false;
         class ViewSourceAction extends AbstractAction {
              public void actionPerformed(ActionEvent e) {
                   try {
                        HTMLEditorKit m_kit = (HTMLEditorKit) MyTextPane.this
                                  .getEditorKit();
                        HTMLDocument m_doc = (HTMLDocument) MyTextPane.this
                                  .getDocument();
                        StringWriter sw = new StringWriter();
                        m_kit.write(sw, m_doc, 0, m_doc.getLength());
                        sw.close();
                        HtmlSourceDlg dlg = new HtmlSourceDlg(null, sw.toString());
                        dlg.setVisible(true);
                        if (!dlg.succeeded())
                             return;
                        StringReader sr = new StringReader(dlg.getSource());
                        m_doc = createDocument();
                        m_kit.read(sr, m_doc, 0);
                        sr.close();
                        setDocument(m_doc);
                   } catch (Exception ex) {
                        ex.printStackTrace();
         private HTMLDocument createDocument() {
              HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
              StyleSheet styles = htmlEditorKit.getStyleSheet();
              StyleSheet ss = new StyleSheet();
              ss.addStyleSheet(styles);
              HTMLDocument doc = new HTMLDocument(ss);
              // doc.setParser(htmlEditorKit.getParser());
              // doc.setAsynchronousLoadPriority(4);
              // doc.setTokenThreshold(100);
              return doc;
         public Element getElementByTag(HTML.Tag tag) {
              HTMLDocument htmlDocument = (HTMLDocument) getDocument();
              Element root = htmlDocument.getDefaultRootElement();
              return getElementByTag(root, tag);
         public Element getElementByTag(Element parent, HTML.Tag tag) {
              if (parent == null || tag == null)
                   return null;
              for (int k = 0; k < parent.getElementCount(); k++) {
                   Element child = parent.getElement(k);
                   if (child.getAttributes()
                             .getAttribute(StyleConstants.NameAttribute).equals(tag))
                        return child;
                   Element e = getElementByTag(child, tag);
                   if (e != null)
                        return e;
              return null;
         public void mouseClicked(MouseEvent e) {
         public void mouseEntered(MouseEvent e) {
         public void mouseExited(MouseEvent e) {
         public void mouseReleased(MouseEvent e) {
         public void mousePressed(MouseEvent e) {
              if (e.getModifiers() == MouseEvent.BUTTON3_MASK) {
                   Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
                   if (cb.getContents(this) == null || !isEditable() || !isEnabled()) {
                        pasteMenuItem.setEnabled(false);
                   } else {
                        pasteMenuItem.setEnabled(true);
                   if (getSelectedText() == null) {
                        copyMenuItem.setEnabled(false);
                        cutMenuItem.setEnabled(false);
                   } else {
                        copyMenuItem.setEnabled(true);
                        if ((getBorder() == null) || !isEditable() || !isEnabled()) {
                             cutMenuItem.setEnabled(false);
                        } else {
                             cutMenuItem.setEnabled(true);
                   popupMenu.show(this, e.getX(), e.getY());
         public JPopupMenu getPopupMenu() {
              return popupMenu;
          * Creates the Popup menu with Cut,Copy,Paste menu items if it hasn't
          * already been created.
         private void createAndConfigurePopupMenu() {
              popupMenu = new JPopupMenu();
              clearMenuItem = new JMenuItem(new ClearAction());
              clearMenuItem.setText("Clear");
              // selectAllMenuItem = new JMenuItem(new SelectAllAction());
              // selectAllMenuItem.setText("Select All");
              cutMenuItem = new JMenuItem(new DefaultEditorKit.CutAction());
              cutMenuItem.setText("Cut");
              copyMenuItem = new JMenuItem(new DefaultEditorKit.CopyAction());
              copyMenuItem.setText("Copy");
              // when pasting, only paste the plain text (not any markup)
              PasteAction pasteAction = new PasteAction();
              pasteMenuItem = new JMenuItem(/* new DefaultEditorKit.PasteAction() */);
              pasteMenuItem.addActionListener(pasteAction);
              pasteMenuItem.setText("Paste");
              popupMenu.add(cutMenuItem);
              popupMenu.add(copyMenuItem);
              popupMenu.add(pasteMenuItem);
              popupMenu.add(new JPopupMenu.Separator());
              popupMenu.add(clearMenuItem);
              // popupMenu.add(selectAllMenuItem);
              setKeyStrokes();
         private void doPasteAction() {
              Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
              Transferable content = cb.getContents(this);
              try {
                   // when pasting, discard the markup
                   String s = (String) content
                             .getTransferData(DataFlavor.stringFlavor);
                   HTMLDocument doc = (HTMLDocument) MyTextPane.this.getDocument();
                   HTMLEditorKit kit = (HTMLEditorKit) MyTextPane.this.getEditorKit();
                   doc.insertString(MyTextPane.this.getCaretPosition(), s, kit
                             .getInputAttributes());
              } catch (Throwable exc) {
                   exc.printStackTrace();
         class PasteAction implements ActionListener {
              public void actionPerformed(ActionEvent e) {
                   doPasteAction();
          * Sets the short cut keys and actions for corresponding actions for keys.
         private void setKeyStrokes() {
              KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V,
                        KeyEvent.CTRL_MASK);
              /** Performs pasteAction when short-cut key paste action is performed */
              Action pasteAction = new AbstractAction() {
                    * Handles user clicked actions.
                    * @param actionEvent -
                    *            ActionEvent object.
                   public void actionPerformed(ActionEvent actionEvent) {
                        doPasteAction();
              InputMap inputMap = getInputMap(JTextPane.WHEN_FOCUSED);
              getActionMap().put(inputMap.get(paste), pasteAction);
         public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand().equals("Select All"))
                   selectAll();
              else if (e.getActionCommand().equals("Clear"))
                   clear();
         public void append(String s) {
              super.setText(getText() + s);
         public void clear() {
              startNewDocument();
         public void startNewDocument() {
              MyHTMLEditorKit editorKit = new MyHTMLEditorKit();
              setContentType("text/html");
              setEditorKit(editorKit);
              HTMLDocument document = (HTMLDocument) editorKit
                        .createDefaultDocument();
              setDocument(document);
              // to enable the copy and paste from ms word (and others) to the
              // JTextPane, set
              // this client property. Sun Bug ID: 4765240
              document.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
              document.setPreservesUnknownTags(false);
         class ClearAction extends AbstractAction {
              public void actionPerformed(ActionEvent e) {
                   startNewDocument();
         class SelectAllAction extends AbstractAction {
              public void actionPerformed(ActionEvent e) {
                   selectAll();
         class HtmlSourceDlg extends JDialog {
              protected boolean m_succeeded = false;
              protected JTextArea m_sourceTxt;
              public HtmlSourceDlg(JFrame parent, String source) {
                   super(parent, "HTML Source", true);
                   JPanel pp = new JPanel(new BorderLayout());
                   pp.setBorder(new EmptyBorder(10, 10, 5, 10));
                   m_sourceTxt = new JTextArea(source, 20, 60);
                   m_sourceTxt.setFont(new Font("Courier", Font.PLAIN, 12));
                   JScrollPane sp = new JScrollPane(m_sourceTxt);
                   pp.add(sp, BorderLayout.CENTER);
                   JPanel p = new JPanel(new FlowLayout());
                   JPanel p1 = new JPanel(new GridLayout(1, 2, 10, 0));
                   JButton bt = new JButton("Save");
                   ActionListener lst = new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             m_succeeded = true;
                             dispose();
                   bt.addActionListener(lst);
                   p1.add(bt);
                   bt = new JButton("Cancel");
                   lst = new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             dispose();
                   bt.addActionListener(lst);
                   p1.add(bt);
                   p.add(p1);
                   pp.add(p, BorderLayout.SOUTH);
                   getContentPane().add(pp, BorderLayout.CENTER);
                   pack();
                   setResizable(true);
                   setLocationRelativeTo(parent);
              public boolean succeeded() {
                   return m_succeeded;
              public String getSource() {
                   return m_sourceTxt.getText();
         public void addToPopupMenuAboveEditItems(JMenuItem menuItem) {
              if (!bTopSeperatorInserted) {
                   popupMenu.insert(new JPopupMenu.Separator(), 0);
                   bTopSeperatorInserted = true;
              popupMenu.insert(menuItem, topMenuItemInsertionIndex);
              ++topMenuItemInsertionIndex;
         public static void main(String args[]) {
              JFrame frame = new JFrame("MyTextPane");
              MyTextPane textPane = new MyTextPane();
              HTMLDocument doc = (HTMLDocument) textPane.getDocument();
              HTMLEditorKit kit = (HTMLEditorKit) textPane.getEditorKit();
              StringWriter buf = new StringWriter();
              // MyHTMLWriter w = new MyHTMLWriter(buf, (HTMLDocument) doc, 0,
              // doc.getLength());
              // w.setLineLength(150);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JScrollPane scrollPane = new JScrollPane(textPane);
              String s = "<p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj aaaaaaaaaaaaaaaaaaaaaaa</p>";
              System.out
                        .println("\nthe long string prior to calling JTextPane.setText(..) WITH NO NEWLINES\ns="
                                  + s);
              textPane.setText(s);
              String sOut = textPane.getText();
              System.out
                        .println("\n\nthe text returned from calling JTextPane.setText(..) -> it inserted CR & newline after the ffff\n");
              System.out.println("textPane.getText()=" + sOut);
              frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
              frame.setSize(500, 700);
              frame.setVisible(true);
    class MyHTMLWriter extends HTMLWriter {
         public MyHTMLWriter(Writer buf, HTMLDocument doc, int pos, int len) {
              super(buf, doc, pos, len);
         protected void setLineLength(int l) {
              super.setLineLength(l);
    class MyHTMLEditorKit extends HTMLEditorKit {
         public void write(Writer out, Document doc, int pos, int len)
                   throws IOException, BadLocationException {
              if (doc instanceof HTMLDocument) {
                   MyHTMLWriter w = new MyHTMLWriter(out, (HTMLDocument) doc, pos, len);
                   w.setLineLength(200);
                   w.write();
              } else if (doc instanceof StyledDocument) {
                   MinimalHTMLWriter w = new MinimalHTMLWriter(out,
                             (StyledDocument) doc, pos, len);
                   w.write();
              } else {
                   super.write(out, doc, pos, len);
    }and

  • How to get exact height of HTML line with SUB tag in JTextPane?

    Hi, this is my first post. I`ve been searching forum for an answer for a week, but didn`t find one.
    I have HTMLDocument inside JTextPane(exacty inside my class that extends it - MyTextPane). I want to do some custom painting in JTextPane so I need to be able to know exact pixel witdh for each line in the document. Easy except one thing, when I use SUB tag the width of the line cannot be simply calculated using FontMetrics, because I don`t know if the text inside SUB tag has lower font size and I don`t know its Y offset to normal line.
    I tried get these information from HTMLDocument using attributes from leafElements representing lines, but there seems to be a problem too.
    I pass this text:
    "(1) Line<SUB>jW</SUB><BR>(2) TextB"
    to setText method of MyTextPane, this method is overriden so it changes text Font
    public void setText(String s) {   
      super.setText(s);   
      setJTextPaneFont(this, new Font("Arial",Font.PLAIN,36), Color.black);
    }This is how the Element Structure looks like:
    Format is Element +": "+elementText+"|"+fontFamily+" "+fontSize
    BranchElement(html) 0,22: \n(1)?LinejW (2)?TextB\n|Monospaced 12
    ---BranchElement(head) 0,1: \n|Monospaced 12
    ------BranchElement(p-implied) 0,1: \n|Monospaced 12
    ---------LeafElement(content) 0,1: \n|Arial 36
    ---BranchElement(body) 1,22: (1) LinejW (2) TextB\n|Monospaced 12
    ------BranchElement(p-implied) 1,22: (1) LinejW (2) TextB\n|Monospaced 12
    ---------LeafElement(content) 1,9: (1) Line|Arial 36
    ---------LeafElement(content) 9,11: jW|Arial 36 <-----------THIS IS THE LOWER INDEX
    ---------LeafElement(content) 11,12: |Arial 36 <-----------THIS IS just space character '\u020'
    ---------LeafElement(content) 12,21: (2) TextB|Arial 36
    ---------LeafElement(content) 21,22: \n|Arial 36
    The height of Arial 36 is according to FontMetrics 43(and it really is), but height of the lowerIndex is just 40 pixels(on the screen), not 43 as I would expect. And I still dont have offset, where does the lower index starts paint itself.
    Is there any problem with my setText method, so that it changes font style for LOWER INDEX?
    I am using JTextPane as notEditable, with just one font style for entire document.
    Any suggestion?

    Is there any other way to get these information. I just found that I need that information before I put text it in the document.
    For example I am would like to generate lines:
    paragraph1 - text1
                             text2
    paragraph2 - text1
                             text2
                             text3
    paragraph3<SUB>some note</SUB> - text1
                                                                           text2
    normal text line
    I know what font line will be and I know its AttributeSet. I am trying to get appropriate number of spaces (or left indent) for text2,text3...lines. Then I will pass that string to setText method of JTextPane.
    I am unable to get appropriate width for "paragraph3<SUB>some note</SUB> - ", since text in SUB tag uses probably different font size.
    I am really sorry to bother again. I will think twice what I need before I posting.
    You`ve been very helpful so far Stas.
    Thanks.

  • Display image in JTextPane (JEditorPane)

    I'm writing an application with JTable and a JTextPane. When selecting a column in the JTable, I want to display the image associated with the selected row in the JTextPane.
    This wouldn't be a problem if the darn JTextPane would just display JUST AN IMAGE. But a JTextPane only displays an image if its embedded in an HTML file. Ugh. That would mean I'd have to create an html file for each picture. Ugh again.
    Is there any way around this?

    Nevermind, figured it out. Just have to use setText instead of setPage.
    htmlPane.setText("<IMG src='"+url+"'>");instead of:
    htmlPane.setPage(url);

  • Line Number in JTextPane

    Hi Experts;
    How do I add a caret listener on this code so that it will just add a number
    when the user goes to the next line.
    import java.awt.*;
    import javax.swing.*;
    public class LineNumber extends JComponent
         private final static Color DEFAULT_BACKGROUND = new Color(213, 213, 234);
         private final static Color DEFAULT_FOREGROUND = Color.white;
         private final static Font DEFAULT_FONT = new Font("arial", Font.PLAIN, 11);
         // LineNumber height (abends when I use MAX_VALUE)
         private final static int HEIGHT = Integer.MAX_VALUE - 1000000;
         // Set right/left margin
         private final static int MARGIN = 5;
         // Line height of this LineNumber component
         private int lineHeight;
         // Line height of this LineNumber component
         private int fontLineHeight;
         // With of the LineNumber component
         private int currentRowWidth;
         // Metrics of this LineNumber component
         private FontMetrics fontMetrics;
          * Convenience constructor for Text Components
         public LineNumber(JComponent component)
              if (component == null)
                   setBackground( DEFAULT_BACKGROUND );
                   setForeground( DEFAULT_FOREGROUND );
                   setFont( DEFAULT_FONT );
              else
                   setBackground( DEFAULT_BACKGROUND );
                   setForeground( DEFAULT_FOREGROUND );
                   setFont( component.getFont() );
              setPreferredSize( 99 );
         public void setPreferredSize(int row)
              int width = fontMetrics.stringWidth( String.valueOf(row) );
              if (currentRowWidth < width)
                   currentRowWidth = width;
                   setPreferredSize( new Dimension(2 * MARGIN + width, HEIGHT) );
         public void setFont(Font font)
              super.setFont(font);
              fontMetrics = getFontMetrics( getFont() );
              fontLineHeight = fontMetrics.getHeight();
          * The line height defaults to the line height of the font for this
          * component. The line height can be overridden by setting it to a
          * positive non-zero value.
         public int getLineHeight()
              if (lineHeight == 0)
                   return fontLineHeight;
              else
                   return lineHeight;
         public void setLineHeight(int lineHeight)
              if (lineHeight > 0)
                   this.lineHeight = lineHeight;
         public int getStartOffset()
              return 4;
         public void paintComponent(Graphics g)
               int lineHeight = getLineHeight();
               int startOffset = getStartOffset();
               Rectangle drawHere = g.getClipBounds();
               g.setColor( getBackground() );
               g.fillRect(drawHere.x, drawHere.y, drawHere.width, drawHere.height);
               g.setColor( getForeground() );
               int startLineNumber = (drawHere.y / lineHeight) + 1;
               int endLineNumber = startLineNumber + (drawHere.height / lineHeight);
               int start = (drawHere.y / lineHeight) * lineHeight + lineHeight - startOffset;
               for (int i = startLineNumber; i <= endLineNumber; i++)
               String lineNumber = String.valueOf(i);
               int width = fontMetrics.stringWidth( lineNumber );
               g.drawString(lineNumber, MARGIN + currentRowWidth - width, start);
               start += lineHeight;
               setPreferredSize( endLineNumber );
    } Thanks for your time . . .
    The_Developer

    Here's what I use. It behaves correctly WRT wrapped lines, and should work equally well with a JTextArea or a JTextPane.
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.FontMetrics;
    import java.awt.Graphics;
    import java.awt.Rectangle;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.BorderFactory;
    import javax.swing.JComponent;
    import javax.swing.SizeSequence;
    import javax.swing.UIManager;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Document;
    import javax.swing.text.Element;
    import javax.swing.text.JTextComponent;
    * LineNumberView is a simple line-number gutter that works correctly
    * even when lines are wrapped in the associated text component.  This
    * is meant to be used as the RowHeaderView in a JScrollPane that
    * contains the associated text component.  Example usage:
    *<pre>
    *   JTextArea ta = new JTextArea();
    *   ta.setLineWrap(true);
    *   ta.setWrapStyleWord(true);
    *   JScrollPane sp = new JScrollPane(ta);
    *   sp.setRowHeaderView(new LineNumberView(ta));
    *</pre>
    * @author Alan Moore
    public class LineNumberView extends JComponent
      // This is for the border to the right of the line numbers.
      // There's probably a UIDefaults value that could be used for this.
      private static final Color BORDER_COLOR = Color.GRAY;
      private static final int WIDTH_TEMPLATE = 99999;
      private static final int MARGIN = 5;
      private FontMetrics viewFontMetrics;
      private int maxNumberWidth;
      private int componentWidth;
      private int textTopInset;
      private int textFontAscent;
      private int textFontHeight;
      private JTextComponent text;
      private SizeSequence sizes;
      private int startLine = 0;
      private boolean structureChanged = true;
       * Construct a LineNumberView and attach it to the given text component.
       * The LineNumberView will listen for certain kinds of events from the
       * text component and update itself accordingly.
       * @param startLine the line that changed, if there's only one
       * @param structureChanged if <tt>true</tt>, ignore the line number and
       *     update all the line heights.
      public LineNumberView(JTextComponent text)
        if (text == null)
          throw new IllegalArgumentException("Text component cannot be null");
        this.text = text;
        updateCachedMetrics();
        UpdateHandler handler = new UpdateHandler();
        text.getDocument().addDocumentListener(handler);
        text.addPropertyChangeListener(handler);
        text.addComponentListener(handler);
        setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, BORDER_COLOR));
       * Schedule a repaint because one or more line heights may have changed.
       * @param startLine the line that changed, if there's only one
       * @param structureChanged if <tt>true</tt>, ignore the line number and
       *     update all the line heights.
      private void viewChanged(int startLine, boolean structureChanged)
        this.startLine = startLine;
        this.structureChanged = structureChanged;
        revalidate();
        repaint();
      /** Update the line heights as needed. */
      private void updateSizes()
        if (startLine < 0)
          return;
        if (structureChanged)
          int count = getAdjustedLineCount();
          sizes = new SizeSequence(count);
          for (int i = 0; i < count; i++)
            sizes.setSize(i, getLineHeight(i));
          structureChanged = false;
        else
          sizes.setSize(startLine, getLineHeight(startLine));
        startLine = -1;
      /* Copied from javax.swing.text.PlainDocument */
      private int getAdjustedLineCount()
        // There is an implicit break being modeled at the end of the
        // document to deal with boundary conditions at the end.  This
        // is not desired in the line count, so we detect it and remove
        // its effect if throwing off the count.
        Element map = text.getDocument().getDefaultRootElement();
        int n = map.getElementCount();
        Element lastLine = map.getElement(n - 1);
        if ((lastLine.getEndOffset() - lastLine.getStartOffset()) > 1)
          return n;
        return n - 1;
       * Get the height of a line from the JTextComponent.
       * @param index the line number
       * @param the height, in pixels
      private int getLineHeight(int index)
        int lastPos = sizes.getPosition(index) + textTopInset;
        int height = textFontHeight;
        try
          Element map = text.getDocument().getDefaultRootElement();
          int lastChar = map.getElement(index).getEndOffset() - 1;
          Rectangle r = text.modelToView(lastChar);
          height = (r.y - lastPos) + r.height;
        catch (BadLocationException ex)
          ex.printStackTrace();
        return height;
       * Cache some values that are used a lot in painting or size
       * calculations. Also ensures that the line-number font is not
       * larger than the text component's font (by point-size, anyway).
      private void updateCachedMetrics()
        Font textFont = text.getFont();
        FontMetrics fm = getFontMetrics(textFont);
        textFontHeight = fm.getHeight();
        textFontAscent = fm.getAscent();
        textTopInset = text.getInsets().top;
        Font viewFont = getFont();
        boolean changed = false;
        if (viewFont == null)
          viewFont = UIManager.getFont("Label.font");
          changed = true;
        if (viewFont.getSize() > textFont.getSize())
          viewFont = viewFont.deriveFont(textFont.getSize2D());
          changed = true;
        viewFontMetrics = getFontMetrics(viewFont);
        maxNumberWidth = viewFontMetrics.stringWidth(String.valueOf(WIDTH_TEMPLATE));
        componentWidth = 2 * MARGIN + maxNumberWidth;
        if (changed)
          super.setFont(viewFont);
      public Dimension getPreferredSize()
        return new Dimension(componentWidth, text.getHeight());
      public void setFont(Font font)
        super.setFont(font);
        updateCachedMetrics();
      public void paintComponent(Graphics g)
        updateSizes();
        Rectangle clip = g.getClipBounds();
        g.setColor(getBackground());
        g.fillRect(clip.x, clip.y, clip.width, clip.height);
        g.setColor(getForeground());
        int base = clip.y - textTopInset;
        int first = sizes.getIndex(base);
        int last = sizes.getIndex(base + clip.height);
        String text = "";
        for (int i = first; i <= last; i++)
          text = String.valueOf(i+1);
          int x = MARGIN + maxNumberWidth - viewFontMetrics.stringWidth(text);
          int y = sizes.getPosition(i) + textFontAscent + textTopInset;
          g.drawString(text, x, y);
      class UpdateHandler extends ComponentAdapter
          implements PropertyChangeListener, DocumentListener
         * The text component was resized. 'Nuff said.
        public void componentResized(ComponentEvent evt)
          viewChanged(0, true);
         * A bound property was changed on the text component. Properties
         * like the font, border, and tab size affect the layout of the
         * whole document, so we invalidate all the line heights here.
        public void propertyChange(PropertyChangeEvent evt)
          Object oldValue = evt.getOldValue();
          Object newValue = evt.getNewValue();
          String propertyName = evt.getPropertyName();
          if ("document".equals(propertyName))
            if (oldValue != null && oldValue instanceof Document)
              ((Document)oldValue).removeDocumentListener(this);
            if (newValue != null && newValue instanceof Document)
              ((Document)newValue).addDocumentListener(this);
          updateCachedMetrics();
          viewChanged(0, true);
         * Text was inserted into the document.
        public void insertUpdate(DocumentEvent evt)
          update(evt);
         * Text was removed from the document.
        public void removeUpdate(DocumentEvent evt)
          update(evt);
         * Text attributes were changed.  In a source-code editor based on
         * StyledDocument, attribute changes should be applied automatically
         * in response to inserts and removals.  Since we're already
         * listening for those, this method should be redundant, but YMMV.
        public void changedUpdate(DocumentEvent evt)
    //      update(evt);
         * If the edit was confined to a single line, invalidate that
         * line's height.  Otherwise, invalidate them all.
        private void update(DocumentEvent evt)
          Element map = text.getDocument().getDefaultRootElement();
          int line = map.getElementIndex(evt.getOffset());
          DocumentEvent.ElementChange ec = evt.getChange(map);
          viewChanged(line, ec != null);
    }

  • Bug in JTextArea/JTextPane ??

    Hi,
    I am facing huge memory leak problems with JTextArea/JTextPane. After considerable investigation, I found out that the Document associated with the component is not being GC'ed properly. I ran OptimizeIt and found out that the memory is being consumed by the JTextPane.setText() method. I have implmented a HTML viewer to display large amounts of HTML data and it is leaking memory like crazy on each successive execution. Any thoughts ??
    JDK1.4.2_01, WinXP
    Here is the code fragment:
    public class ReportViewer extends BaseFrame implements FontChange_int
         private     String          cReport;          
         private boolean          testMode = false;     
         // Graphical components
         private     BorderLayout     cMainLayout;
         private     JButton          cClose;
         private     JTextPane     cRptPane;
         private     Button          cClose2;
         private ViewUpdater cViewUpdater = null;
         // Constants
         final     static     int     startupXSize = 650;
         final     static     int     startupYSize = 500;
         // Methods
         public ReportViewer(String report, ReportMain main)
              // BaseFrame extends JFrame
              super("Reports Viewer", true, startupXSize, startupYSize);
              testMode = false;
              cReport = report;
              cViewUpdater = new ViewUpdater();
              initialize();
         public void initialize()
              // Create main layout manager
              cMainLayout = new BorderLayout();
              getContentPane().setLayout(cMainLayout);
              // Quick button bar - print, export, save as
              JToolBar     topPanel = new JToolBar();
              topPanel.setBorder(new BevelBorder(BevelBorder.RAISED) );
              java.net.URL     url;
              topPanel.add(Box.createHorizontalStrut(10));
              url = Scm.class.getResource("images/Exit.gif");
              cClose = new Button(new ImageIcon(url), true);
              cClose.setToolTipText("Close Window");
              topPanel.add(cClose);
              getContentPane().add(topPanel, BorderLayout.NORTH);
              // Main view window - HTML
              cRptPane = new JTextPane();
              cRptPane.setContentType("text/html");
              cRptPane.setEditable(false);
              JScrollPane sp = new JScrollPane(cRptPane);
              getContentPane().add(sp, BorderLayout.CENTER);
              // Main button - Close
              JPanel     bottomPanel = new JPanel();
              url = Scm.class.getResource("images/Exit.gif");
              cClose2 = new Button(new ImageIcon(url), "Close");
              bottomPanel.add(cClose2);
              getContentPane().add(bottomPanel, BorderLayout.SOUTH);
              cClose.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        closeWindow();
              cClose2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        closeWindow();
              show();
              cViewUpdater.setText(cReport);
              SwingUtilities.invokeLater(cViewUpdater);
         protected void
         closeWindow()
              super.closeWindow();
              // If I add the following lines, the GC reclaims
    // part of the memory but does not flush out the text
    // component as a whole
              /*Document doc = cRptPane.getDocument();
              try
                   doc.remove(0,doc.getLength());
              catch(Exception e) {;}
              doc=null; */
              cRptPane=null;
              cReport = null;
              cViewUpdater = null;
              dispose();
         private class ViewUpdater implements Runnable
              private String cText = null;
              public ViewUpdater() {;}
              public void
              setText(String text) {
                   cText = text;
              public void
              run() {
                   cRptPane.setText(cText);
                   cRptPane.setCaretPosition(0);
                   cText = null;
         // Local main - for testing
         public static void main(String args[])
              //new ReportViewer(str,comp);
    Sudarshan
    www.spectrumscm.com

    Hi,
    I am facing huge memory leak problems with JTextArea/JTextPane. After considerable investigation, I found out that the Document associated with the component is not being GC'ed properly. I ran OptimizeIt and found out that the memory is being consumed by the JTextPane.setText() method. I have implmented a HTML viewer to display large amounts of HTML data and it is leaking memory like crazy on each successive execution. Any thoughts ??
    JDK1.4.2_01, WinXP
    Here is the code fragment:
    public class ReportViewer extends BaseFrame implements FontChange_int
         private     String          cReport;          
         private boolean          testMode = false;     
         // Graphical components
         private     BorderLayout     cMainLayout;
         private     JButton          cClose;
         private     JTextPane     cRptPane;
         private     Button          cClose2;
         private ViewUpdater cViewUpdater = null;
         // Constants
         final     static     int     startupXSize = 650;
         final     static     int     startupYSize = 500;
         // Methods
         public ReportViewer(String report, ReportMain main)
              // BaseFrame extends JFrame
              super("Reports Viewer", true, startupXSize, startupYSize);
              testMode = false;
              cReport = report;
              cViewUpdater = new ViewUpdater();
              initialize();
         public void initialize()
              // Create main layout manager
              cMainLayout = new BorderLayout();
              getContentPane().setLayout(cMainLayout);
              // Quick button bar - print, export, save as
              JToolBar     topPanel = new JToolBar();
              topPanel.setBorder(new BevelBorder(BevelBorder.RAISED) );
              java.net.URL     url;
              topPanel.add(Box.createHorizontalStrut(10));
              url = Scm.class.getResource("images/Exit.gif");
              cClose = new Button(new ImageIcon(url), true);
              cClose.setToolTipText("Close Window");
              topPanel.add(cClose);
              getContentPane().add(topPanel, BorderLayout.NORTH);
              // Main view window - HTML
              cRptPane = new JTextPane();
              cRptPane.setContentType("text/html");
              cRptPane.setEditable(false);
              JScrollPane sp = new JScrollPane(cRptPane);
              getContentPane().add(sp, BorderLayout.CENTER);
              // Main button - Close
              JPanel     bottomPanel = new JPanel();
              url = Scm.class.getResource("images/Exit.gif");
              cClose2 = new Button(new ImageIcon(url), "Close");
              bottomPanel.add(cClose2);
              getContentPane().add(bottomPanel, BorderLayout.SOUTH);
              cClose.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        closeWindow();
              cClose2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        closeWindow();
              show();
              cViewUpdater.setText(cReport);
              SwingUtilities.invokeLater(cViewUpdater);
         protected void
         closeWindow()
              super.closeWindow();
              // If I add the following lines, the GC reclaims
    // part of the memory but does not flush out the text
    // component as a whole
              /*Document doc = cRptPane.getDocument();
              try
                   doc.remove(0,doc.getLength());
              catch(Exception e) {;}
              doc=null; */
              cRptPane=null;
              cReport = null;
              cViewUpdater = null;
              dispose();
         private class ViewUpdater implements Runnable
              private String cText = null;
              public ViewUpdater() {;}
              public void
              setText(String text) {
                   cText = text;
              public void
              run() {
                   cRptPane.setText(cText);
                   cRptPane.setCaretPosition(0);
                   cText = null;
         // Local main - for testing
         public static void main(String args[])
              //new ReportViewer(str,comp);
    Sudarshan
    www.spectrumscm.com

  • How Do I Make Text Colored in a JTextPane

    I currently have a program that uses a JTextArea to display text that the user has typed into a Text Field. This is working and i now want to be able to make parts of this text different colors. I was looking in the tutorials and it looks like i need to use a JTextPane but i am not sure how to do this, does anyone have any advice? Thanks in advance.

    going86 wrote:
    The tutorial does not explain hot to do it very well, it is hard to understand.Then give it your best shot, and come back with your code and your specific points of misunderstanding. The onus of effort here must be on you.

  • View the Text in JTextPane when we r inserting another text

    Hi,
    I have created GUI in swing where i have taken JTextPane.I am seaching some keyword which r given by the client if i found so i am creating the pdf file for that data and in JTextPane i am showing the pdf file name .....if i am getting that keyword in the database then i am showing some different color string that " keyword not found with that keyword" .........while this process takes too much time to create pdf....till that time JTextPane is not showing any text.........in this case i want that the text should show in the JTextPane once the single Pdf file get created and so on to create 100 PDF file...plase sugget me somthing ......thanx

    Hi,
    Thanks a lot for ur support..Now i am getting updated JTextPane..
    Can u provide me a link with the help of which i can use multiple threads
    1.to get information from the database.......to collect data from database.
    2.to search the keyword in that database.
    3.to print the search condition in the JTextPane
    4.Final is to create PDF.
    So i have to do above 4 steps out of which last step(4th) that is to create PDF is time consuming...So give me guidence with the help of which i can make maximum use of threads for faster execution.....thanx

  • How to print JTextPane containing JTextFields, JLabels and JButtons?

    Hi!
    I want to print a JTextPane that contains components like JTextFields, JLabels and JButtons but I do not know how to do this. I use the print-method that is available for JTextComponent since Java 1.6. My problem is that the text of JTextPane is printed but not the components.
    I wrote this small programm to demonstrate my problem:
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.print.PrinterException;
    public class TextPaneTest2 extends JFrame {
         private void insertStringInTextPane(String text,
                   StyledDocument doc) {
              try {
                   doc.insertString(doc.getLength(), text, new SimpleAttributeSet());
              catch (BadLocationException x) {
                   x.printStackTrace();
         private void insertTextFieldInTextPane(String text,
                   JTextPane tp) {
              JTextField tf = new JTextField(text);
              tp.setCaretPosition(tp.getDocument().getLength());
              tp.insertComponent(tf);
         private void insertButtonInTextPane(String text,
                   JTextPane tp) {
              JButton button = new JButton(text) {
                   public Dimension getMaximumSize() {
                        return this.getPreferredSize();
              tp.setCaretPosition(tp.getDocument().getLength());
              tp.insertComponent(button);
         private void insertLabelInTextPane(String text,
                   JTextPane tp) {
              JLabel label = new JLabel(text) {
                   public Dimension getMaximumSize() {
                        return this.getPreferredSize();
              tp.setCaretPosition(tp.getDocument().getLength());
              tp.insertComponent(label);
         public TextPaneTest2() {
              StyledDocument doc = new DefaultStyledDocument();
              StyledDocument printDoc = new DefaultStyledDocument();
              JTextPane tp = new JTextPane(doc);
              JTextPane printTp = new JTextPane(printDoc);
              this.insertStringInTextPane("Text ", doc);
              this.insertStringInTextPane("Text ", printDoc);
              this.insertTextFieldInTextPane("Field", tp);
              this.insertTextFieldInTextPane("Field", printTp);
              this.insertStringInTextPane(" Text ", doc);
              this.insertStringInTextPane(" Text ", printDoc);
              this.insertButtonInTextPane("Button", tp);
              this.insertButtonInTextPane("Button", printTp);
              this.insertStringInTextPane(" Text ", doc);
              this.insertStringInTextPane(" Text ", printDoc);
              this.insertLabelInTextPane("Label", tp);
              this.insertLabelInTextPane("Label", printTp);
              this.insertStringInTextPane(" Text Text", doc);
              this.insertStringInTextPane(" Text Text", printDoc);
              tp.setEditable(false);
              printTp.setEditable(false);
              this.getContentPane().add(tp);
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setSize(400,400);
              this.setVisible(true);
              JOptionPane.showMessageDialog(tp, "Start printing");
              try {
                   tp.print();
              } catch (PrinterException e) {
                   e.printStackTrace();
              try {
                   printTp.print();
              } catch (PrinterException e) {
                   e.printStackTrace();
         public static void main(String[] args) {
              new TextPaneTest2();
    }First the components are shown correctly in JTextPane, but when printing is started they vanish. So I created another textPane just for printing. But this does not work either. The components are not printed. Does anybody know how to solve this?
    Thanks!

    I do not know how I should try printComponent. From the API-Doc of JComponent of printComponent: This is invoked during a printing operation. This is implemented to invoke paintComponent on the component. Override this if you wish to add special painting behavior when printing. The method print() in JTextComponent is completely different, it starts the print-job. I do not understand how to try printComponent. It won't start a print-job.

Maybe you are looking for

  • Message 069 - Output could not be displayed (it may not be complete)

    Hi Gurus, KIndly help me please. Upon trying to print a billing document in VF31, the message Message 069 - Output could not be displayed (it may not be complete) appears and as a result I cannot print preview the document. However, I tried doing the

  • Arch fails to print over CUPS

    Hello community, I'm using a Raspi running Raspbian and CUPS 1.5.3 and a Brother HL-2030 printer hanging on the Raspi. Several clients are connected through the local network and should be able to use the printer. The machines are running Xubuntu, Ma

  • External drive unmountable & invisible after sleep (osx 10.8.1)

    Hello, yesterday evening, the lid of my mbp (retina, medio 2012) was closed while it was displaying the screensaver, with an external USB disk plugged in. After I opened the lid and logged back in, I saw a dialog mentioning that the disk was removed

  • IPhoto automatically imported EVENT and its photos?

    I imported some photos into iPhoto on my MacBook Air this weekend while away. This morning (I'm back home), I started the MacBook Air with the intent of copying the imported photos to my iMac and eventually into the iPhoto library. So the Air is runn

  • H.264 with widescreen

    I shot a movie in MiniDV in squeeze format. I imported the footage in FinalCut in anamorphic, and I edited in anamorphic. I am exporting now a Quicktime movie to print on a Music CD, but the version I get is not in anamorphic, the images are squeezed