JTextPane's Question

If someone use the Ms word's macro before, you should have the experience with the Document object. But in java. Even the JTextPane is a greatful object. but to it's text, it just have a String to handle all the text. If I want to find a paragraph, It's hard to do it. Do I miss some method or it's really need get it from the string?

No, I don't need to break down the whole string. And I don't think it's good to use the tokennizer.
what I need is change some Mnemonic tag into another tag. And add some new tag after a paragraphs. so I need some way to get the para. of cause, I can get it by seach for the "\n".

Similar Messages

  • Custom HTML tags in JTextPane

    Hi all,
    I have seen this topic broached before but, in spite of many hours searching, haven't found the answer I'm looking for...
    I jave a JTextPane containing an HTMLDocument and want to render elements within my own custom tag 'Custom' outlined in red.
    I have subclassed HTMLEditorKit as follows:import javax.swing.text.ViewFactory;
    import javax.swing.text.html.HTMLEditorKit;
    public class HTMLEditorKitForCustom extends HTMLEditorKit{
         public ViewFactory getViewFactory(){
              return htmlFactoryForCustom;
        private static final ViewFactory htmlFactoryForCustom = new HTMLFactoryForCustom();
    }I have subclassed HTMLEditorKit.HTMLFactory as follows:import javax.swing.text.View;
    import javax.swing.text.Element;
    import javax.swing.text.html.HTMLEditorKit;
    import javax.swing.text.StyleConstants;
    public class HTMLFactoryForCustom extends HTMLEditorKit.HTMLFactory{
         public View create(Element element){
              Object object = element.getAttributes().getAttribute(StyleConstants.NameAttribute);
              if(CustomView.CUSTOM_KEY_TAG.equals(object)){
                   return new CustomView(element);
              return super.create(element);
    }And, I have subclassed LabelView as follows:public class CustomView extends LabelView{
         public CustomView(Element element){
              super(element);
         public void paint(Graphics g, Shape a){
              super.paint(g, a);
              Rectangle rectangle = a instanceof Rectangle ? (Rectangle)a : a.getBounds();
              Graphics2D g2d = (Graphics2D)g;
              g.setColor(Color.RED);
              g.drawRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
         public static final String CUSTOM_KEY_TAG = "Custom";
         public static final String CUSTOM_TYPE_TAG = "ccVarType";
         public static final String CUSTOM_NUMERIC_TYPE_TAG_VALUE = "Numeric";
    }The JTextPane in question has its EditorKit set to my HTMLEditorKitForCustom throughtextPane.setEditorKit(new HTMLEditorKitForCustom();In combination, these classes ensure that when a <Custom>...</Custom> set of tags is encountered, the text between is rendered with a red outline.
    This works fine when the custom tags and text are inserted but, as soon as a change is made that affects the paragraph containing the custom tags (for example, change alignment, font size, etc.), the content disappears. However, the underlying HTML still shows the <Custom> tag, but with no closing tag and without the text the tags once contained.
    E.g. <Custom>Fred</Custom> becomes simply <Custom>.
    Any help in solving this problem will be greatly appreciated!
    Chris.

    Stas, thanks for your response!
    I did try registering the tag, and associating it with a SpecialAction then with a CharacterAction (I want the user to be able to change the font style, etc. of these Custom items).
    I did this by creating HTMLDocumentForCustom (original name, huh!), subclassing HTMLDocument and inner HTMLReaderForCustom:// (Within HTMLDocumentForCustom)
    public class HTMLReaderForCustom extends HTMLReader{
      public HTMLReaderForCustom(int pos){
        super(pos, 0, 0, null);
        registerTag(new HTML.UnknownTag(CustomView.CUSTOM_KEY_TAG), new SpecialAction());
    }Then I created a new HTMLDocumentForCustom and did textPane.setDocument(document). Now, when I inserted the text between Custom tags, I got this exception:javax.swing.text.BadLocationException: Invalid insert;
         at javax.swing.text.GapContent.insertString(GapContent.java:109);
         at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:722);I was using the following code to insert the text:SimpleAttributeSet attributes = new SimpleAttributeSet();
    attributes.addAttribute(StyleConstants.NameAttribute, CustomView.CUSTOM_KEY_TAG);
    try{
      document.insertString(1, "Custom Here!", attributes);
    catch(BadLocationException ble){
      ble.printStackTrace();
    }Inserting at position 1 was working fine before trying to subclass HTMLDocument and HTMLReader, and there's already text in the document before trying the insert -- in fact it didn't matter what the insert location was set to, the exception kept occurring.
    Can you see anything obvious I've missed or am I barking totally up the wrong tree?
    Chris.

  • Question on inner classes

    I have a class that has 3 inner classes, on class read the colors and font settings, how can I pass this class to the 2 other inner classes
    Here is a watered down version of code:
    class MainClass{
           public MainClass(){
                 // do some stuff
                 innerClass3  ic = new innerClass3();// I need to pass this to the other inner classes
                 layeredPane.add( new innerClass1( some Variable), 1);
                 layeredPane.add( new innerClass2( anotherVariable), 2 );
    class innerClass1 extends JTextPane{
         public innerClass1( String s ){
    // instead of doing this
              innerClass3 ic = new innerClass3();
              setBackground(ic.getBackground() );
    class innerClass2 extends JPanel{
            public innerClass2( String[] z){
             // and this again
                innerClass3 ic = new innerClass3();
                setForeground(ic.getFontClor());
    class innerClass3{
    Color background;
    Color foreground;
        public innerClass(){
         setColors();
    public void setColors(){
       background = Color.blue;
       foreground = Color.red;
    public Color getBackground(){
       return background;
    public Color getFontColor(){
    return foreground;
          

    Thanks for the reply
    Works well for first screen, but I recall the innerClasses(1 and 2) from an actionPerformed in innerClass2 and I keep getting nullPointerError when referring to innerClass3. Each screen will have different fonts and colors, so I need it to update after each button click.
    // this is inside innerClass2( it's panel with buttons )
    // the next screens graphics will depend on which button is selected
    public void mouseReleased(final java.awt.event.MouseEvent e) {
             layeredPane.removeAll();
              currentQuestionNumber++; 
              question = questionText[currentQuestionNumber] ;  
    // adds a JTextPane with question         
              layeredPane.add(new innerClass1(question, ic), 1 );
    // adds a JPanel with buttons
              layeredPane.add(new innerClass2( currentQuestionNumber, ic ), 3 );Will be tearing hair out soon
    Jim

  • More JTextPane Questions

    Hi Guys
    I posted this question on the Java Ranch forums yesterday evening, but I haven't received a response yet, so I figured that I'd try these forums as well. You can view the other thread here; http://www.coderanch.com/t/554155/GUI/java/JTextPane-Questions.
    We're trying to build a simple WYSIWYG HTML editor using a JTextPane. I've used Charles Bell's example, available here; http://www.artima.com/forums/flat.jsp?forum=1&thread=1276 as a reference. My biggest gripe with it at the moment is that bullets aren't working as I would expect them to. If I highlight text and click the "Bullet" button, I want a bullet to be placed immediately before the highlighted text, on the same line. If I try to do this, my code is creating bullets, but it moves the selected text one line down. I've gone through the Oracle tutorial on text components, but I couldn't find anything that helped me with this particular issue.
    Also, if I copy and paste text into my JTextPane, the pasted text always appears on a new line (a new paragraph tag in the actual HTML). Is there a way to prevent the JTextPane from creating new paragraphs?
    Lastly, I'm flabbergasted as to why my buttons actually work. I can't see anything that explicitly links my buttons to my HTMLEditorKit or my JTextPane. Short of a little voodoo man living under my keyboard, how on earth do my buttons/actions know that they should update the JTextPane?
    The code is as follows;
    package myhtmleditor;
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Action;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.SwingUtilities;
    import javax.swing.text.StyledEditorKit;
    import javax.swing.text.html.HTML;
    import javax.swing.text.html.HTMLDocument;
    import javax.swing.text.html.HTMLEditorKit;
    public class Main {
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("My HTML Editor");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setSize(500, 500);
                    frame.setLayout(new BorderLayout());
                    JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
                    HTMLDocument document = new HTMLDocument();
                    final JTextPane htmlEditorPane = new JTextPane(document);
                    Action bold = new StyledEditorKit.BoldAction();
                    Action italic = new StyledEditorKit.ItalicAction();
                    Action underline = new StyledEditorKit.UnderlineAction();
                    JButton boldButton = new JButton(bold);
                    boldButton.setText("Bold");
                    buttonsPanel.add(boldButton);
                    JButton italicButton = new JButton(italic);
                    italicButton.setText("Italic");
                    buttonsPanel.add(italicButton);
                    JButton underlineButton = new JButton(underline);
                    underlineButton.setText("Underline");
                    buttonsPanel.add(underlineButton);
                    HTMLEditorKit.InsertHTMLTextAction bulletAction = new HTMLEditorKit.InsertHTMLTextAction("Bullet", "<ul><li> </li></ul>", HTML.Tag.BODY, HTML.Tag.UL);
                    JButton bulletButton = new JButton(bulletAction);
                    bulletButton.setText("Bullet");
                    buttonsPanel.add(bulletButton);
                    JButton printButton = new JButton("Print to Console");
                    printButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            System.out.println(htmlEditorPane.getText());
                    buttonsPanel.add(printButton);
                    htmlEditorPane.setContentType("text/html");
                    HTMLEditorKit editorKit = new HTMLEditorKit();
                    htmlEditorPane.setEditorKit(editorKit);
                    frame.add(buttonsPanel, BorderLayout.NORTH);
                    frame.add(new JScrollPane(htmlEditorPane), BorderLayout.CENTER);
                    frame.setVisible(true);
    }Thank you for your input.
    Cheers,
    rfnel

    See how the bullet action changes HTML (compare getText() result before and after the bullet applying. It seems you need more smart way of adding bullets.
    Answer some questions if user selects whole paragraph should the <p> tag be removed and replaced with <li>? If user selects just one word in the paragraph and pressed bullet should the whole paragraph be bulleted?
    When you copy something you clipboard contains something like this "<html><body> content</body></html>". Try to override read() method of your kit (or Reader) to skip the main tags.
    For components see ObjectView class source.
    In fact when HTMLDocument is created from String components classes are created and stored in attributes of Elements. Then during rendering ComponentView extension (ObjectView) creates components.

  • JTextPane questions

    I have put JTextPane in JFrame with GridBagLayout.
    Questions:
    1) When I type text into JTextPane then the JTextPane control starts to expand size horizontaly. Why is this happening and how to make JTextPane not to change size when I type text in it?
    2) How to set margin in JTextPane? I have tried setMargin() but nothing
    happens.
    3) How to change attributes of some text already in JTextPane?

    I don't understand your first message at all
    abillconsl.
    As for my 1) question I have found a solution with
    setPrefferedSize and using JScrollPane.
    Can someone help on 2) and 3) question?My first post was code that, if you were to run it,
    you'd see that the JTextPane does not expand with
    your keying in.
    My second post was adding additional information and
    attempting to explain that I could not code anything
    closer than that to what you need because you did not
    give enough detail; and any other threads you might
    have made that seem to have been alluded to in this
    thread I have no knowledge of.
    At any rate, I made an attempt to help you out, and
    you could say thank you ... that would be nice. Ditto
    for puckstopper31
    ~BillI really appreciate your help, I didn't mean to say anything bad.
    Thanks!
    Message was edited by:
    BobMil

  • A question about the Font in JTextPane

    I added a JTextPane in a frame. When input letters in the text pane, the width of them is different. For example, a "H" is wider than "i". How can I make them have same width?
    package test;
    import java.awt.Color;
    import javax.swing.JFrame;
    import javax.swing.JTextPane;
    import javax.swing.text.AttributeSet;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.SimpleAttributeSet;
    import javax.swing.text.StyleConstants;
    public class TestFont {
         * @param args
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            JFrame frame = new JFrame();
            JTextPane textPane = new JTextPane();
            AttributeSet as1 = new SimpleAttributeSet();
            try{
                textPane.getDocument().insertString(0, "abcabc",as1);
                textPane.getDocument().insertString(textPane.getDocument().getLength(), "\nEEE", as1);
                frame.add(textPane);
                frame.setSize(100,100);
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }catch(BadLocationException ex){
                ex.printStackTrace();
    }

    Use a monospaced font:
    textPane.setFont( new Font("monospaced", Font.PLAIN, 12) );

  • JTextpane question

    HI everybody,
    In my project i have to set some thing in JTextpane.
    What my problem is
    User enter the characters in textpane after press the enter button
    the contents of the textpane is paste in another textpane and first textpane will be clear .
    In this process is going good but after pressing the enter, JTextpane go to the next line.
    I dont want to go next line after pressing the enter button. just clear the text in JTextpane and set cursor in the starting point of the JTextpane This is i want.
    So can any body help this problem.
    awaiting for your reply,

    Ashwini.Kumar.Kulshrestha wrote:
    you must have implemented the key listener for the textPane to trap the Enter key.
    public void keyPressed(KeyEvent e){
    if(e.getKeyCode()==VK_ENTER)
    // pass the text to the other TextPane
    textPane.setCursorPosition(0);
    textPane.setText("");
    e.consume();
    }this should solve the purpose.This is not the recommended way to handle such things. This should be handled with InputMap and ActionMap.
    [http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]
    Here's an example:
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.KeyStroke;
    import javax.swing.text.BadLocationException;
    public class TextPaneActionTest {
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setLayout(new GridLayout(2,0));
            final JTextPane tpOne = new JTextPane();
            final JTextPane tpTwo = new JTextPane();
            KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0);
            KeyStroke ctrlEnterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.ALT_DOWN_MASK);
            Object enterActionKey = tpOne.getInputMap().get(enterStroke);
            Action enterAction = tpOne.getActionMap().get(enterActionKey);
            tpOne.getInputMap().put(ctrlEnterStroke, enterActionKey);
            Action myEnterAction = new AbstractAction() {
                public void actionPerformed(ActionEvent ae) {
                    String text = tpOne.getText();
                    tpOne.setText("");
                    try {
                        tpTwo.getDocument().insertString(tpTwo.getDocument().getLength(), text + "\n", null);
                    } catch (BadLocationException ble) {
                        ble.printStackTrace();
            tpOne.getInputMap().put(enterStroke, myEnterAction);
            f.add(tpOne);
            f.add(new JScrollPane(tpTwo));
            f.setSize(400,300);
            f.setVisible(true);
    }

  • Help, a question about jtextpane.

    i want to known of something abouut jtextpane.
    when i use a jtextpane in a jscrollpane in a jpanel, i can not use jtextpane by the horizonalbar in jscrollpane.
    can you tell me why/
    thanks!
    if i want to display multi_format character and scroll horizonal bar, how can i do in java.
    [email protected]

    These might help hope they do
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
              scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

  • A Simple Question... inserting image into JTextPane...

    Well my problem is very simple (but not for me). Before I explain it, please take a look at a simple class...
    public class Window extends JTextPane {
        Window() {
            super();
        }// Window
        public void appendText(String s,Color col) throws BadLocationException {
            StyledDocument sd = getStyledDocument();
            SimpleAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setForeground(attr,col);
            sd.insertString(sd.getLength(),s,attr);
          *     THE POINT - what should I write here, please consult description followed by the class.
        } //appendText
    } //classThe appendText method simply appends the text in text pane with desired color. Now I want to know what should I write at point THE POINT so that at end of appended string an icon (suppose end.gif) is added and is displayed in text pane. Simple?
    Stay happy,
    fadee

    Dear Fadee,
    here is a small programe for inserting images into JTextPane;
    find this comment and start
    /*All Code In this Button Action*/if you need any thing feel free to tell me,
    i'm with you brother, i'll do my best :O)
    -Best regards
    mnmmm
    * Fadee.java
    * Created on June 7, 2002, 1:13 AM
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.color.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    * @author  Brother Mohammad, Cairo, Egypt.
    * @version
    public class Fadee extends javax.swing.JFrame {
        JTextPane   tp;
        JButton     b;
        StyledDocument sd;
        SimpleAttributeSet attr;
        public Fadee() throws BadLocationException {
            b = new JButton("Press");
            tp = new JTextPane();
            b.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    /*All Code In this Button Action*/
                    try {
                        sd = tp.getStyledDocument();
                        attr = new SimpleAttributeSet();
                        /*get default style*/
                        Style def = StyleContext.getDefaultStyleContext().
                                            getStyle(StyleContext.DEFAULT_STYLE);
                        /*add style for text default style*/
                        Style regular = tp.addStyle("regular", def);
                        StyleConstants.setFontFamily(def, "SansSerif");
                        StyleConstants.setAlignment(def, StyleConstants.ALIGN_CENTER);
                        StyleConstants.setForeground(def, Color.RED);
                        /*add style for icon create as many as icons you have
                         and don't forget to resize the photo at small size
                         to fit with font size*/
                        Style s = tp.addStyle("icon", regular);
                        StyleConstants.setAlignment(s, StyleConstants.ALIGN_JUSTIFIED);
                        StyleConstants.setIcon(s, new ImageIcon("d:\\My Photo.GIF"));
                        /*here is what user will see*/
                        sd.insertString(sd.getLength(), "Allah Akbar ", tp.getStyle("regular"));
                        sd.insertString(sd.getLength(), " ", tp.getStyle("icon"));
                    } catch (BadLocationException x) {
                        x.printStackTrace();
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(b, BorderLayout.NORTH);
            getContentPane().add(tp, BorderLayout.CENTER);
            setSize(500, 500);
            setVisible(true);
        public static void main(String args[]) {
            try {
                Fadee f = new Fadee();
            } catch (BadLocationException x) {
                x.printStackTrace();
    }

  • A JTextPane question (5 Duke Dollars)

    Hi, I'm doing a large project in java and have ran into several issues. Most have already been answered, but this one keeps nagging on:
    1. How would I make certain words certain colours/formats? I have set up a text box like this:
    static JTextPane luacode = new JTextPane();
    then in the code this happens:
         sbrText = new JScrollPane(textbox);
         textbox.addKeyListener(new MyKeyListener());
         //scrollpane
         sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
         //scrollbar
         sbrText.setPreferredSize(new Dimension(685, 370));
    but does anyone have any idea about formatting this, e.g. if apple is said make it green and bold, if the letters // are typed then anything else on that line is green and font system etc...
    Thank you
    Alex
    null

    You might want to consider this strategy.
    Use a JTextEditor.
    Set the editor kit to be HTMLEditorKit.
    now you can use html to alter the apearance / formating of your document.
    want to make apple bold. just add <b> apple </b>
    The screen will update in real time.
    The user never needs to know they are working in html. this can just be the background implementation.
    if you need source to reference just let me know.. i might be able to provide you with a quick example.
    Message was edited by:
    jmguillemette
    example code..
    package com.wirednorth.examples.editor;
    import java.awt.Dimension;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.text.html.HTMLEditorKit;
    public class MyEditor extends JFrame{
         private JEditorPane editorPnl = new JEditorPane();
         private JScrollPane scrollPnl = new JScrollPane(editorPnl);
         public MyEditor(){
              setSize(800,600);
              setTitle("Editor example");
              editorPnl.setEditorKit(new HTMLEditorKit());
              editorPnl.setPreferredSize(new Dimension(400,400));
              getContentPane().add(scrollPnl);
              editorPnl.setText(
                                       "<html>" +
                                            " my apple is <font color='green'>Green</font>" +
                                       "</html>"
         public static void main(String[] args) {
              MyEditor editor = new MyEditor();
              editor.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              editor.setVisible(true);
    }

  • Duke will  reward if u answer my question about JTEXTPAne

    Anyone can tell me is the JTEXTPANE can add JCheckbox insided the pane iitself?I wanna do a system where user can select objective answer in a CHeckbox inside the TextPAne!! PLs tell me if anyone know the answer..THAnks alll who try to answer

    Here is the sample .
    import javax.swing.*;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    class InsertCheck extends JFrame implements java.awt.event.ActionListener
        private JTextPane text;
        private JButton butt;
        private Dimension dim;
        InsertCheck()
            text=new JTextPane();
            dim=new Dimension(100,22);
            butt=new JButton("Insert Check Box");
            butt.addActionListener(this);
            this.getContentPane().add(text,BorderLayout.CENTER);
            this.getContentPane().add(butt,BorderLayout.SOUTH);
            this.setSize(600,500);
            this.setVisible(true);
        public void actionPerformed(java.awt.event.ActionEvent p1) {
            JCheckBox check=new JCheckBox("just check it");
            check.setPreferredSize(dim);
            check.setMinimumSize(dim);
            text.insertComponent(check);
        public static void main(String[] s)
            new InsertCheck();
    }   

  • JTextPane and preferredSize question

    I have a textPane that will display different length stings with the click of a button, I want the the textPane to resize it's hieght according to the size of the string.
    The first question the pane sizes it's height to 6 which doesn't show the text, from there on out it sizes fine(35, 60, and so on ). I'm stumped.
    here's snippet of code
    layeredPane.removeAll();
    String question = questionText[currentQuestionNumber];
            questionPane.setText(question);       
            q = questionPane.getPreferredSize();
            layeredPane.add( questionPane, questionPaneLayer );
            layeredPane.add( buttonPanel, buttonLayer );
            questionPane.setBounds( 0,0,screenW,q.height );
            buttonPanel.setBounds(0,q.height,screenW/6,screenH );
            jPanel1.add(layeredPane, BorderLayout.CENTER);
            validate();
            repaint();Jim

    I thought that when you added the text, the preferred size kicks in and sets it, but apperently I'm misunderstanding something here.
    anyone?

  • Question about JTextPane, JEditorPane in JApplet?

    Hello,
    I was hoping to display the results of a small piece of html code in a JApplet, I know in the jdk we can use a JTextPane or JEditorPane to display the results of html. But can we use the JTextPane or JEditorPane in a JApplet.
    Thanks

    That really depends on:
    1) whether the HTML is well formed. JEditorPane has problems with any html that is not well formed. For example, <b><p>test</b></p> is not well formed.
    2) whether you want to write your own html viewer
    3) whether you can ensure that users will have a JVM version recent enough to use the JEditorPane - 1.3 is probably the first version it was introduced.

  • JTextPane question. Please help!

    I want messages to roll line by line in a JTextPane:
    StringBuffer sb = new StringBuffer();
    int i = 0;
    while(i<100) {
      sb.append(i);
      sb.append("\n");
      jTextPane.setText(sb.toString());
      i++;
    }But this code does not work. No message is shown in jTextPane.
    How should I fix it?

    Thanks. But I just realized it was stupid to use JTextPane. Should use JTextArea :)

  • JTextPane and StyledDocument question

    I was just wondering if it is necessary to have a StyledDocument that is added to the JTextPane, or if it is acceptable to have all the components (JLabels in my case) added to the JTextPane rather than a StyledDocument?
    Right now I basically have a JTextPane with a few JLabels in it that is added to a JPanel. This works fine, but I think I might run into a problem if I need to add any text other than JLabels. Any help is appreciated... sorry if this doesn't make much sense.
    dub

    but I think I might run into a problem if I need to add any text other than JLabelsWhy are you adding only labels to a JTextPane. That is what a JPanel is for.

Maybe you are looking for

  • My Macbook pro is running slow and it is starting to freeze up - attached are my ETRE results

    My Macbook Pro has been running slow...I inherited it from another coworker (we are contractors so we are responsible for them not the company)...the spinning colorful ball icon seems to run on and off on different screens every day....any ideas of w

  • Can't sync Zoom audio with the one of the videocamera...!

    HI! I have filmed a theatre performance with a Sony NEXVG10E. I have also recorded the audio directly from the stage on a ZOOM H4n. I have put both the A/V from the camera and the audio from the zoom (a WAVE 44.1 stereo) on a sequence in FCP6. Then I

  • An EFFECTIVE development directory structure for J2EE platform?

    Hi, here we r talking about deployment environment more than development environment. Have u ever think about designing an EFFECTIVE development directory structure for J2EE platform( e.g. weblogic )? u r not using the deployment directories for codi

  • HT204053 iCloud document sync being strange

    I'm having an issue with icloud documents.  I have 10.8.2 mac software, the iphone 5, and an ipad 2 (both of which are on the latest ios).  They're all synced to the same @me.com account, so the documents should be showing up correctly in Pages.  Wha

  • How to import mailbox files in Outlook 2013??

    How do I import Mozilla Thunderbird archived mailboxes in Microsoft Outlook 2013? I used Mozilla Thundebird in Mac book pro earlier, from some time I have been using Windows pc and for some reason I needed to access my older mails that I had archived