How wrap words in JScrollPane

I have a JScrollPane which has been created with this code:
JTextArea textArea = new JTextArea(htmlRepairSupport);
JScrollPane scrollPane = new JScrollPane(textArea);
htmlRepairSupport is a very long String. When this scroll pane is displayed in a dialog box, I want there to only be a vertical scroll, and for the text to wrap when it hits the right edge of the scroll pane. Does anyone know how to do this?
Thanks!

javax.swing.JTextArea.setLineWrap(boolean);
javax.swing.JTextArea.setWrapStyleWord(boolean);

Similar Messages

  • After installing lion and updating to pages 4.1 cannot view my document content after I open the document.  Shows how many pages I have and how many words in word count, but no words...

    after installing lion and updating to pages 4.1 cannot view my document content after I open the document.  Shows how many pages I have and how many words in word count, but no words...

    Same problem. Tried reinstalling Pages. Didn't help. The behavior is like I am typing with a white font on a white background, but I am not.

  • How to make a JScrollPane not getting Focus?

    How to make a JScrollPane not getting Focus?
    When i tab out from a textfield inside a scroll pane focus is going to ScrollPane .And if i press tab once more then only focus is going to other textField which is outside the scrollpane.
    For me when i press tab from a text field inside a scrollPane ,i should go to textfield out side the scroll pane.
    satish

    Hi,
    I've the same problem, that I have to double click on tab
    to step from a textfield with a scrollpane to the next textfield in my panel.
    I tried to implement a FocusListener on my JScrollPane, but without success.
    Can you tell me in detail how to implement this listener ?
    Kind regards
    Andy Kanzlers

  • Where do you see how many words you've typed?

    I am writing a paper for school and its only supposed to be 500 words long, where do i see how many words i've typed?

    Go to the Document inspector & click the Info tab or Edit > Writing Tools > Show Statistics.
    If you get Pages '09, the word count is in the bottom left of each document.

  • How select word with keyboard

    How select word in text without a mouse?

    Welcome to Apple Discussions         
    Arrow (left, right, up or down) in front of the first character of the word. While holding down the shift key right arrow to the last character (or you could go from last character right arrow to the first) release the shift and arrow key(s). The word is now selected.

  • How wrap Flash into JSF Component?

    I need to make Flash which will be wrapped by JSF component. Flash component will be placed on the page and it presents some data by the user request. Page will not be reloaded, all transfering will be between Flash and Server. What architectural solutions I may use?
    Well be thankfulness for any infomation about it.
    Edited by: JavaKirill on Dec 12, 2008 7:31 AM

    You normally represent a flash object using HTML <object> tag.
    JSF components normally just renders HTML.
    I don´t see how wrapping it in a JSF component would be impossible.

  • How to word wrap within text field

    I've created a form with a text field but when filling the form out, the words don't word wrap, but merely go in a single line across the text box field. 
    When can I format the text box to word wrap?
    tks

    I have set my text fields to multi line and the text wraps but it only starts about halfway down the text box.  Please help, this is getting frustrating...

  • How to  word wrap the Print from JEditorPane correctly to a print page?

    Hi,
    I'm trying to print text from the JEditorPane. However the printout does not word wrap and some gets cutoff. Is there a way to set the word wrap when printing?
    Thanks for you help.

    Some of my Hotmail emails are not word wrapping properly. Partial word wrapping is done,but each sentence requires the use of the scroll bar to reach the end.
    Other emails are normal.I opened Hotmail in IE9,and the same email wraps normally.I have FF 9.0.1 running on Win7 Home Premium.

  • How to word wrap, keep font size constant

    The zoom feature on the screen is constantly changing the size, in hotmail (windows live). I can zoom it back, but shouldn't have to do it constantly. Also, is there a way to set settings so email messages will word wrap, to keep from having to scroll back and forth to read them. I have a 14" screen on my laptop, but it stays too big.

    Some of my Hotmail emails are not word wrapping properly. Partial word wrapping is done,but each sentence requires the use of the scroll bar to reach the end.
    Other emails are normal.I opened Hotmail in IE9,and the same email wraps normally.I have FF 9.0.1 running on Win7 Home Premium.

  • On iphone when creating emails, how to word wrap the text

    I have several people, ncluding myself, when creating or responding to emails the text runs on and on and does not wrap to the next  line. Can you help?

    Come on apple... There are so many complaints about this going back years.  The text wraps when looking at the sent email.  Please fix the problem in the composition window!

  • How to add a JScrollPane in a JPanel

    I have a JPanel (layout = null, size = 200*400).
    I would like to add a JScrollPane, that sizes 100*100 and that contains an other JPanel, at the location 0,200 in the first JPanel. I would like too that the JScrollBar is always visible.
    How is it possible ?

    The scrollbars will appear automatically when the preferred size of the panel is greater than the size of the scroll pane. So you probably need to add:
    panel.setPreferredSize(...);
    Of course if you use LayoutManagers, instead of a null layout, then this is done automatically for you.
    If you want the scroll bars to appear all the time then read the JScrollPane API.

  • How can I add JScrollpane to one of the panels of a JFrame????

    I want to generate a screen with one JFrame and two JPanels.one panel to the left of the Frame and another to the right.
    I want to add a Jscrollpane to left panel,to which i am adding images so that they can be scrolled.How can I achieve this ???????????
    please reply me.............
    this is Basic Frame class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    public class BasicFrame
    private JFrame frame = null;
    private JPanel CanvasPanel = new JPanel();
    private JPanel libraryPanel = null;
    public static void main(String args[])
    new BasicFrame();
    public BasicFrame()
    frame = new JFrame( "Java3d Demo of VRML Loading ");
    frame.setSize( 800, 600 );
    frame.setLayout(new BorderLayout());
         frame.add(CanvasPanel,BorderLayout.EAST);
    frame.add(new LibraryPanel(),BorderLayout.WEST);
         frame.setMenuBar(createMenuBar());
    frame.setVisible( true );
         // kill the window on close
         frame.addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent winEvent)
         System.exit(0);
    public MenuBar createMenuBar()
    MenuBar menubar = new MenuBar();
         Menu menu;
    Menu subMenu;
    MenuItem menuItem;
    menu = new Menu("File");
    menuItem = new MenuItem("New");
    menu.add(menuItem);
    //menuItem.addActionListener(this);
    menuItem = new MenuItem("Load");
    menu.add(menuItem);
    //menuItem.addActionListener(this);
    subMenu = new Menu("Save");
    menu.add(subMenu);
    menuItem = new MenuItem("VRML97");
    subMenu.add(menuItem);
    //menuItem.addActionListener(this);
    menuItem = new MenuItem("X3D");
    subMenu.add(menuItem);
    //menuItem.addActionListener(this);
    subMenu = new Menu("Print");
    menu.add(subMenu);
    menuItem = new MenuItem("VRML97");
    subMenu.add(menuItem);
    //menuItem.addActionListener(this);
    menuItem = new MenuItem("X3D");
    subMenu.add(menuItem);
    //menuItem.addActionListener(this);
    menuItem = new MenuItem("Quit");
    menu.add(menuItem);
    //menuItem.addActionListener(this);
    menubar.add(menu);
    menu = new Menu("View");
    menuItem = new MenuItem("Reset");
    menu.add(menuItem);
    menuItem.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    menubar.add(menu);
    return menubar;
    this is Library panel class.To this,I want to add Jscrollpane to scroll the images displayed in this panel.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    public class LibraryPanel extends JPanel
    private ArrayList<String> imageList = new ArrayList<String>();
    private ImageIcon imageIcon;
    private JLabel imageLabel[] = new JLabel[100];
    private String path = "small images";
    private JList list;
    LibraryPanel()
    setSize(400, 600);
    setBorder(BorderFactory.createLineBorder(Color.black));
    setLayout(new FlowLayout());
    JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
    indexFiles();
    for(int imageNo=0;imageNo<imageList.size();imageNo++)
    try
    imageIcon = new ImageIcon(path + "/" + imageList.get(imageNo));
    imageLabel[imageNo] = new JLabel(imageIcon);
    //scrollPane.getViewport().
              add(imageLabel[imageNo]);
    catch (IllegalArgumentException illegalArgEx)
    illegalArgEx.printStackTrace();
         add(comboBox(),FlowLayout.CENTER);
    add(vbar,FlowLayout.CENTER);
    public JComboBox comboBox()
    String[] comboTypes = { "Sachin", "YuvRaj", "Ganguly", "Dravid", "Sehwag", "Dhoni" };
         // Create the combo box, and set 2nd item as Default
         JComboBox comboTypesList = new JComboBox(comboTypes);
         comboTypesList.setSelectedIndex(0);
         return comboTypesList;
    public void indexFiles()
    File dir = new File(path);
    String[] children = dir.list();
    if (children == null)
    System.err.println("Error: The directory doesn't exists!");
    System.exit(1);
    else
    imageList.ensureCapacity(children.length);
    for (int i = 0; i < children.length; i++)
    if(children.endsWith(".jpg"))
    imageList.add(children[i]);
    please reply me

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    public class BasicFrame
        private JFrame frame = null;
        private JPanel CanvasPanel = new JPanel();
        private JPanel libraryPanel = null;
        public static void main(String args[])
            new BasicFrame(); 
        public BasicFrame()
            frame = new JFrame( "Java3d Demo of VRML Loading ");
            frame.setSize( 800, 600 );
            frame.setLayout(new BorderLayout());
         frame.add(CanvasPanel,BorderLayout.EAST);
            frame.add(new LibraryPanel(),BorderLayout.WEST);
         frame.setMenuBar(createMenuBar());
            frame.setVisible( true );
         // kill the window on close
         frame.addWindowListener(new WindowAdapter()
             public void windowClosing(WindowEvent winEvent)
                 System.exit(0);
        public MenuBar createMenuBar()
            MenuBar menubar = new MenuBar();
         Menu menu;
            Menu subMenu;
            MenuItem menuItem;
            menu = new Menu("File");
            menuItem = new MenuItem("New");
            menu.add(menuItem);
            //menuItem.addActionListener(this);
            menuItem = new MenuItem("Load");
            menu.add(menuItem);
            //menuItem.addActionListener(this);
            subMenu = new Menu("Save");
            menu.add(subMenu);
            menuItem = new MenuItem("VRML97");
            subMenu.add(menuItem);
            //menuItem.addActionListener(this);
            menuItem = new MenuItem("X3D");
            subMenu.add(menuItem);
            //menuItem.addActionListener(this);
            subMenu = new Menu("Print");
            menu.add(subMenu);
            menuItem = new MenuItem("VRML97");
            subMenu.add(menuItem);
            //menuItem.addActionListener(this);
            menuItem = new MenuItem("X3D");
            subMenu.add(menuItem);
            //menuItem.addActionListener(this);
            menuItem = new MenuItem("Quit");
            menu.add(menuItem);
            //menuItem.addActionListener(this);
            menubar.add(menu);
            menu = new Menu("View");
            menuItem = new MenuItem("Reset");
            menu.add(menuItem);
            menuItem.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
            menubar.add(menu);
            return menubar;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    public class LibraryPanel extends JPanel
        private ArrayList<String> imageList = new ArrayList<String>();
        private ImageIcon imageIcon;
        private JLabel imageLabel[] = new JLabel[100];
        private String path = "small images";
        private JList list;
        LibraryPanel()
            setSize(400, 600);
            setBorder(BorderFactory.createLineBorder(Color.black));
            setLayout(new FlowLayout());
            JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
            indexFiles();
            for(int imageNo=0;imageNo<imageList.size();imageNo++)
                try
                    imageIcon = new ImageIcon(path + "/" + imageList.get(imageNo));
                    imageLabel[imageNo] = new JLabel(imageIcon);
                    //scrollPane.getViewport().
              add(imageLabel[imageNo]);
                catch (IllegalArgumentException illegalArgEx)
                    illegalArgEx.printStackTrace();
         add(comboBox(),FlowLayout.CENTER);
            add(vbar,FlowLayout.CENTER);
        public JComboBox comboBox()
            String[] comboTypes = { "Sachin", "YuvRaj", "Ganguly", "Dravid", "Sehwag", "Dhoni" };
         // Create the combo box, and set 2nd item as Default
         JComboBox comboTypesList = new JComboBox(comboTypes);
         comboTypesList.setSelectedIndex(0);    
         return comboTypesList;
        public void indexFiles()
            File dir = new File(path);
            String[] children = dir.list();
            if (children == null)
                System.err.println("Error: The directory doesn't exists!");
                System.exit(1);
            else
                imageList.ensureCapacity(children.length);
                for (int i = 0; i < children.length; i++)
                    if(children.endsWith(".jpg"))
    imageList.add(children[i]);

  • How do I cause JScrollPane to try and get it's contents to resize narrower?

    I have a JScrollPane that contains a JPanel (GridBagLayout) that contains a dynamically added set of panels.
    I've noticed that when I make the app window wider, all the panels get wider (as expected) and properly re-layout their contents to the new width.
    The problem is when I make the app window narrower, all the child panels stay the same width, and the JScrollPane horizontal scrollbar is activated so you can scroll back and forth in them.
    Setting the Hscrollbar policy to Never doesn't help.
    I'd LIKE to have the system attempt to re-layout the member panels to the narrower width, as long as it's not less than their min width. As far as I can tell, it doesn't even try.
    Any suggestions on how to get the contents to attempt to get narrower?
    (And yes, I do need the scrollpane, as we are almost always going to need to scroll vertically, and there are occasionally panels that are just too wide.)

    The scroll pane does not contain a subclass of JTextComponent, but rather a JPanel(GridLayout(0, 1)) containing many JPanels.Check out all your other postings where you've been asked for a SSCCE.
    it isn't, then I've done something wrong and an SSCCExxyqzz is appropriateExactly, when you ask a question you don't know it if is or isn't normal behaviour. So you post your simple SSCCE so we can make sure you aren't doing something silly and to prove that you are doing something "normal". If it is normal behavour then we can try to suggest a solution. If it isn't normal behavour then we don't have to waste time asking for a SSCCE and then waiting hours for you to create the SSCCE. We all only have a limited amount of time to answer questions. The more complete the question, the faster you get an answer.
    Since I've wasted my time explaing this again and again, I don't have any time left to answer the question.

  • How number words to keep them together on the same line!

    How can I keep words together? As Example:
    I have words "EN-ISO 2020" now is my text not together.
    EN-ISO on the end iff the line and 2020 on a new line.
    It should be alway's together on the next line.
    Please help this problem!

    Put a "nonbreaking space" between EN-ISO and 2020.  The shortcut is
    Ctrl+space or Esc space h  ("h" is for hard space). You may also need a
    "nonbreaking hyphen" between EN and ISO. The shortcut for that is Esc
    hyphen h.

  • Centering text & wrapping words on lines

    Hi all,
    I need to have a JLabel that centers the text in it, and allows for multiple lines, where if a line is too long, it wraps onto the next line.
    I started off with a JTextArea, setting "setLineWrap" and "setWrapStyleWord", and this works fine for long lines of text. But, I need to have the text centered as well. Is there any way of doing this? I know JTextPane can do it, but I can't see how to do it in JTextArea.
    any help much appreciated,
    Justin

    Use a JLabel, with HTML text content and set the preferred size of the label as well. This will do auto line wrap;
    ie. ew JLabel("<html><center>The long text</center></html>");ICE

Maybe you are looking for