Results 1 to 16 of 16

Thread: Try it again

  1. #1
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default Try it again

    Hello,
    I posted this question a few days ago but have not received any responses. So, I though I would try it again, reworded. I'm trying to use some form of Swing text editor (EditorPane, TextPane, TextField) to print out lines where every other line is a different color. From what I read, jTextFields cant do this but the other two can by editing their style sheets (CSS). I've looked at several examples but nothing seems to work. Can anyone provide an example of how to do this?

    Thanks
    jason

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You may have better luck if you:

    1) change your threat title to something more informative, say "Colored lines in Swing text component", and
    2) show your code attempt first and describe any specific problem's you're having with it.

    Much luck!

  3. #3
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default set jEditorPane css problem

    well, this is what i posted last time. No one responded then but I hope that changes this time:

    hello,
    I'm trying to change the font color of text in a jEditorPane in a desktop application. bellow is the code i'm using:
    Java Code:
    try{
        System.out.print("test");    
        jEditorPane1.setContentType("text/html");
        HTMLEditorKit kit = new HTMLEditorKit();
        jEditorPane1.setEditorKit(kit);
        StyleSheet styleSheet = kit.getStyleSheet();
        styleSheet.addRule("<style type=\"text/css\"> p { color:red;}</style>");
    }
    catch (Exception e){
        jEditorPane1.setText(e.toString());
    }
    the error was:

    Exception in thread "Thread-4" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2882)
    at java.lang.AbstractStringBuilder.expandCapacity(Abs tractStringBuilder.java:100)
    at java.lang.AbstractStringBuilder.append(AbstractStr ingBuilder.java:515)
    at java.lang.StringBuffer.append(StringBuffer.java:30 6)
    at java.io.StringWriter.write(StringWriter.java:77)
    at javax.swing.text.AbstractWriter.output(AbstractWri ter.java:679)
    at javax.swing.text.html.HTMLWriter.output(HTMLWriter .java:1172)
    at javax.swing.text.AbstractWriter.write(AbstractWrit er.java:547)
    at javax.swing.text.AbstractWriter.write(AbstractWrit er.java:497)
    at javax.swing.text.html.HTMLWriter.writeComment(HTML Writer.java:626)
    at javax.swing.text.html.HTMLWriter.writeAdditionalCo mments(HTMLWriter.java:646)
    at javax.swing.text.html.HTMLWriter.write(HTMLWriter. java:217)
    at javax.swing.text.html.HTMLEditorKit.write(HTMLEdit orKit.java:292)
    at javax.swing.text.JTextComponent.write(JTextCompone nt.java:1616)
    at javax.swing.JEditorPane.getText(JEditorPane.java:1 522)
    at webagent.WebAgentView.AppendJText(WebAgentView.jav a:518)
    at webagent.ReadURL.run(ReadURL.java:57)
    at java.lang.Thread.run(Thread.java:662)

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    The code you've posted is not causing the error you're seeing, and we're not going to be able to help you unless you post the offending code, preferably an SSCCE which would allow us to run your code, modify it and help correct it. Something like so (but showing your error):

    Java Code:
    import java.awt.Dimension;
    
    import javax.swing.*;
    import javax.swing.text.html.HTMLEditorKit;
    import javax.swing.text.html.StyleSheet;
    
    public class JEditorPaneTest {
        private static final Dimension VP_SIZE = new Dimension(400, 300);
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createGui();
                }
            });
        }
    
        private static void createGui() {
            final JEditorPane jEditorPane1 = new JEditorPane();
            JScrollPane editorScroll = new JScrollPane(jEditorPane1);
            editorScroll.getViewport().setPreferredSize(VP_SIZE);
            try{
                System.out.print("test");    
                jEditorPane1.setContentType("text/html");
                HTMLEditorKit kit = new HTMLEditorKit();
                jEditorPane1.setEditorKit(kit);
                StyleSheet styleSheet = kit.getStyleSheet();
                styleSheet.addRule("<style type=\"text/css\"> p { color:red;}</style>");
            }
            catch (Exception e){
                jEditorPane1.setText(e.toString());
            }
    
            
            JFrame frame = new JFrame("App");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(editorScroll);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    }

  5. #5
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    My code is a bit longer so, I will only display the code I think might be causing the problem. if you would like the full code, let me know. The main thread is where the jTextPane resides. I have a secondary thread that runs, when called, to a URL. The secondary thread relays the gotten information back to the main thread, via an interface, which then updates the jTextPane. Everything seems to work just fine, except for when I attempt to change the font color. my code is as follows:

    Main thread:
    Java Code:
        private void ReadFileActionPerformed(java.awt.event.ActionEvent evt) {                                         
    ....
    Thread t = new Thread(new ReadURL(this));
                t.start();
    }
    
    ...
      public void setMyColor(Color myColor){
             // jEditorPane1.setForeground(myColor);
    try{
        System.out.print("test");    
        jEditorPane1.setContentType("text/html");
        HTMLEditorKit kit = new HTMLEditorKit();
        jEditorPane1.setEditorKit(kit);
        StyleSheet styleSheet = kit.getStyleSheet();
        styleSheet.addRule("<style type=\"text/css\"> p { color:red;}</style>");
    }
    catch (Exception e){
        jEditorPane1.setText(e.toString());
    }

    ReadURl.java:

    Java Code:
    import java.awt.Color;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.util.ArrayList;
    
    public class ReadURL implements Runnable{
        MyInterface callingFrame;
        int MaxLength=0;
        int MinLength = 0;
        ArrayList<String> URLs = new ArrayList<String>();
       
    
    
    public  ReadURL(MyInterface ins){
        callingFrame = ins;
    }
    
    
        public void run() {
            MaxLength = callingFrame.getURLLength();
            MinLength=0;
            callingFrame.setUpProgressBar(MinLength, MaxLength, true);
            callingFrame.SetJ("");
    
    
            String myUrl = callingFrame.getURL();
    
            URLs.removeAll(URLs);
    
            String inputString =myUrl;
            String tokens[] = inputString.split(",");
            int numTokens = tokens.length;
            for (int i = 0; i < numTokens; i++) {
                URLs.add(tokens[i]);
            }
    
            for (int i = 0; i < URLs.size(); i++) {
                try{
                    callingFrame.setMyColor(Color.red);
                }
                catch(Exception e){
                    callingFrame.SetJ(e.toString());
                }
                
                callingFrame.AppendJText("---------------------------------------------------------------");
    
                callingFrame.AppendJText("File Name: " + URLs.get(i));
    
                callingFrame.AppendJText("---------------------------------------------------------------");
                 callingFrame.setMyColor(Color.black);
                try {
                URL theURL = new URL(URLs.get(i));
                if (myUrl !="") callingFrame.setReadType("url");
                else  callingFrame.setReadType("none");
                BufferedReader in = new BufferedReader(new InputStreamReader(theURL.openStream()));
                String inputLine;
                while ((inputLine = in.readLine()) != null){
                   
                        callingFrame.AppendJText(inputLine);
                       inputLine = in.readLine();
                }
                in.close();
               // callingFrame.setColor(Color.red);
    	}
    	catch (Exception exc) {
                
                    callingFrame.SetJ("");
    		callingFrame.AppendJText("Page was not found\n");
    		callingFrame.AppendJText("Error is:\n" + exc.toString());
    		return;
            }
                   
            }
    
    
    
    
    
    
        }
    }
    when i run the program, it starts to lag quite a bit. after a few minutes, the error occurs on the NetBeans output window. The program, its self, continues to run but does not display any errors or text on the jEditorPane.
    If i remove the call to setMyColor, it runs fine. if you need any more info, please let me know. I'm not sure i can cut my code down and still have it run properly. It is a Java Desktop application and has a lot of self created code that will not allow me to remove and run. I can provide the whole code set, though, if you want.

    thanks
    jason

  6. #6
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    nothing, huh

  7. #7
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I am most familiar with using JTextPanes and rtf editor kit. The basic way to do it was to get an attribute set and set the font color in the attribute set. Here is a basic example.

    Java Code:
    JTextPane text = new JTextPane(); //other textpane setup stuff
    MutableAttributeSet att = text.getInputAttributes();
    StyleConstants.setForegroung(att, Color.RED);
    text.setCharacterAttributes(args);
    This is the basics and it will definitely take some work to get it to work exactly as you want.

    I am working on a text editor now and it uses rtf editor kit, and a default styled document.

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by jasonwucinski View Post
    nothing, huh
    I'm waiting to see if you post an SSCCE as per my previous post and example program. If you do that, your chances of getting a solution will likely go up.

  9. #9
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    im not sure what more i can do to shorten the code. Because I'm using NetBeans Desktop Application, I cant remove a bulk of the code as the IDE prevents any editing. As i said in my last post, I could provide the entire code if you want.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Not sure about the others, but I won't have time to look through a large code base given the responsibilities of my job, family, etc.

    So create a simple small GUI, like the one I created above, but just give it the code that causes your problem. Yes it will take effort for you to isolate the problem, but it is effort well spent.

  11. #11
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default re

    ok, I've created a shorter version. I'm still getting an error with this but it's a different error. not sure why. my original code is a Desktop Application. This one is just an application. You will need to create a txt file in your C directory for this program to read. there are three parts:

    Main.java:
    Java Code:
    package shortapp2;
    
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.TextArea;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import javax.swing.JButton;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JTextPane;
    import javax.swing.text.MutableAttributeSet;
    import javax.swing.text.StyleConstants;
    import javax.swing.text.html.HTMLEditorKit;
    import javax.swing.text.html.StyleSheet;
    
    
    public class Main extends JFrame implements   MyInterface , ActionListener {
        JTextPane jta = new JTextPane();
    
        public static void main(String[] args) {
            new Main();
        }
    
        public Main() {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setLayout(new BorderLayout());
            JButton b = new JButton("Run thread");
            b.addActionListener(this);
            add("Center", jta);
            add("South", b);
            setSize(640,480);
            setVisible(true);
        }
    
        public void actionPerformed(ActionEvent e) {
           Thread t = new Thread(new ReadMe(this));
           t.start();
        }
    
        public void SetJ(String getIt) {
            jta.setText(getIt);
        }
    
        public void AppendJText(String getIt){
            jta.setText(  jta.getText()  + getIt);
        }
    
        public void setMyColor(Color myColor){
            try{
                jta.setContentType("text/html");
                HTMLEditorKit kit = new HTMLEditorKit();
                jta.setEditorKit(kit);
                StyleSheet styleSheet = kit.getStyleSheet();
                styleSheet.addRule("<style type=\"text/css\"> p { color:red;}</style>");
            }
            catch (Exception e){
                jta.setText(e.toString());
            }
        }
    }
    readMe.java:
    Java Code:
    package shortapp2;
    
    import java.awt.Color;
    import java.io.BufferedInputStream;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    
    public class ReadMe implements Runnable{
        MyInterface callingFrame;
    
    public  ReadMe(MyInterface ins){
        callingFrame = ins;
    }
    
    
        public void run() {
           callingFrame.SetJ("");
           String getFileName="";
           getFileName = "c:/text.txt";
           callingFrame.setMyColor(Color.black);
           callingFrame.AppendJText("---------------------------------------------------------------");
           callingFrame.AppendJText("File Name: " + getFileName);
           callingFrame.AppendJText("---------------------------------------------------------------");
    
           try {
                BufferedReader in = new BufferedReader(new FileReader(getFileName));
                String s = in.readLine();
                    while (s != null) {
                        callingFrame.setMyColor(Color.yellow);
                        callingFrame.AppendJText(s);
                        s = in.readLine();
                    }
                
                }
                catch (Exception exc) {
                    callingFrame.AppendJText(getFileName + " was not found\n");
    		callingFrame.AppendJText("Error is:\n" + exc.getMessage());
    		return;
                }
            }
        }
    MyInterface.java:
    Java Code:
    package shortapp2;
    
    
    import java.awt.*;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.io.File;
    import javax.swing.*;
    /**
     *
     * @author Delerium
     */
    interface MyInterface {
        public void SetJ(String string);
        public void AppendJText(String string);   
        public void setMyColor(Color myColor);
    }
    the error I'm getting now is:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException


    Thanks for the help

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    The stack trace tells you which line threw the Exception. Don't make us guess.

    db

  13. #13
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    the error is in
    public void setMyColor(Color myColor){
    try{
    jta.setContentType("text/html");
    HTMLEditorKit kit = new HTMLEditorKit();
    jta.setEditorKit(kit);
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("<style type=\"text/css\"> p { color:red;}</style>");
    }
    catch (Exception e){
    jta.setText(e.toString());
    }

    at jta.setEditorKit(kit); in Main.java

  14. #14
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Impossible.

    The only thing that can be null on that line is jta. If it was null then a NPE would have been thrown 2 lines earlier. Copy and paste the EXACT and FULL error message.

  15. #15
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    when i comment it out, the error does not occur. This thread has continued because I was asked to create a SSCCE version of my code, which I did. It should be easy to run. here is the full error:

    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
            at javax.swing.JComponent.paintComponent(JComponent.java:752)
            at javax.swing.JComponent.paint(JComponent.java:1029)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
            at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
            at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

  16. #16
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    Quote Originally Posted by jasonwucinski View Post
    when i comment it out, the error does not occur. This thread has continued because I was asked to create a SSCCE version of my code, which I did.
    Code that contains a bunch of unused imports and needs to be pasted to 3 separate files does NOT constitute a SSCCE.

    Your problem probably arises out of neglecting Swing's single threaded rule.
    http://java.sun.com/products/jfc/tsc.../threads1.html
    http://java.sun.com/products/jfc/tsc.../threads3.html
    Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    When you have that sorted out, you're going to discover that append(...) doesn't work that way in html. Neither does \n. But that will be the subject of a new topic thread.

    db

    edit And the String argument to addRule(...) is incorrect.
    Last edited by DarrylBurke; 04-20-2011 at 09:08 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •