Scrolling textpane..??

how can i scroll a JTextPane on a click of a button.... can JViewPort help me in that... if so then how...??

or you can also try ..
  private void jTextPane1_mouseClicked(MouseEvent e)
    this.jScrollPane1.getVerticalScrollBar().setValue(jScrollPane1.getVerticalScrollBar().getValue()+50);
  }this way you can provide a unit increment (e.g. 50 here) on each click instead of moving to the end..
Cheers!
Asim

Similar Messages

  • Word wrap on scrolling textPane

    Hi,
    How do I turn the word wrap off on a textPane so I can have a scrollable continuous string?
    Thanks
    Andy

    Having read different posts on this forum I have determined that there are two ways to turn line wrapping off:
    1) add the JTextPane to the center of a JPanel using the BorderLayout
    2) override the getScrollableTracksViewportWidth() method ot JTextPane. (after testing I determined it was sometimes necessary to also override the setSize() method as well. )
    Here is my sample program showing the two approaches.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TestNoWrap extends JFrame
         JTextPane textPane;
         JScrollPane scrollPane;
         public TestNoWrap()
              JPanel panel = new JPanel();
              panel.setLayout( new BorderLayout() );
              setContentPane( panel );
              // no wrap by adding a text pane to a panel first
              textPane = new JTextPane();
              textPane.setText("1234567890 1234567890 1234567890");
              JPanel noWrapPanel = new JPanel();
              noWrapPanel.setLayout( new BorderLayout() );
              noWrapPanel.add( textPane );
              scrollPane = new JScrollPane( noWrapPanel );
              scrollPane.setPreferredSize( new Dimension( 200, 100 ) );
              panel.add( scrollPane, BorderLayout.NORTH );
              // no wrap by overriding text pane methods
              textPane = new JTextPane()
                   public void setSize(Dimension d)
                        if (d.width < getParent().getSize().width)
                             d.width = getParent().getSize().width;
                        super.setSize(d);
                   public boolean getScrollableTracksViewportWidth()
                        return false;
              textPane.setText("1234567890 1234567890 1234567890");
              scrollPane = new JScrollPane( textPane );
              scrollPane.setPreferredSize( new Dimension( 200, 100 ) );
              panel.add( scrollPane );
         public static void main(String[] args)
              TestNoWrap frame = new TestNoWrap();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);

  • TextPane always scroll to the bottom when append text

    How to avoid TextPane (inside scroll pane) to go to the bottom after append or set text. The current way I do is to scroll up again. This causes a noticable blink which I don't like very much. Could someone please point out if there is a setting I can do to say don't scroll?

    int pos = myTextArea.getCaretPosition();
    ...append text...
    myTextArea.setCaretPosition(pos);

  • Scrolling a textpane with pgup key.

    Well, i want to add so that the user can scroll up 1 page in a jtextpane lying in a jscrollpane by pressing the page up key.
    Been looking around how to do this, but havent found anything so far...
    Can anyone give some suggestions?

    Not sure I understand this question. This is the default behaviour of the text pane when it has focus.
    Well, I have never tried this but the JViewport has a couple of methods for scrolling:
    1) scrollRectToVisible(...)
    2) setViewPosition(...)
    There is also a method getViewSize(). The getViewSize returns a Rectangle which contains the x,y and width height values.
    So, you could just add/subtract the height of the current position to get a new view position and then uses of the above methods to do the scrolling.
    Or, JTextPane implements the Scrollable interface which contains a method, getScrollableBlockIncrement(...) which could be used to calculate a new position.
    Or, JScrollBar has a getBlockIncrement(...) method. It also has getValue(), setValue(...) methods. So maybe something like:
    JScrollBar bar = scrollpane.getVerticalScrollBar();
    bar.setValue( bar.getValue() + bar.getBlockIncrement(...) );

  • JScrollPane, JTextPane, Weird scrolling happening

    The code below shows the problem I am having: In short, I have a textPane in a scrollPane but when I try to getViewPort.setViewPosition(0,0); then the scroll pane briefly flashes to position 0,0 then re positions itself to display the bottom of the text pane. It is driving me wild! If I removed the InsertString function call used on the Document of the textPane, then it works as I thought it should (apart from an initial glitch where the slider bar is placed near the top...- see example)
    in the example I have a 'tall' JTextPane (ie, lot's of linefeeds) with a red panel all in a JPanel which inturn lies in a JScrollPane. Click on the 'Force Update' button to force the Text pane to be updated (in my real java class, there is other stuff to change the values of the textpane) and to set the display position to 0,0. Notice how the slider button flashes to the top of the vertical bar then returns to the bottom. If you cick on the 'toggle InsetString Active' button, then the code to Insert the String to the textArea is by-passed. Now clicking on the 'Force Update' button (after the initial glitch) does send the view to the top of the Jpanel(which now contains an empty textarea and a red panel).
    Can anyone give any clues as to what is causing the Scroll pane to redraw to the bottom of the panel? (and what is causing the glitch after the toggle InsertString button is pressed?)
    I have tried it on JDK 1.3.1 and 1.4 and scoured the groups for similar problems but found none. Lots have people had prblems getting the JScrollpane to the bottom of the textpane but I can't seem to stop it going down!
    I'd appreciate any help as I'm quickly going bald....
    Marc
    code begins....
    -------------------------cut here--------------------------
    import javax.swing.*;
    import java.awt.*; //for layout managers
    import java.awt.event.*; //for action and window events
    import javax.swing.text.*;
    public class WierdScroll extends JFrame
    ScrollPane scrollPane = null;
    JButton button = null;
    JButton b2 = null;
    JPanel screen = null;
    // below is the style to be associated with the textpane
    static private SimpleAttributeSet normalStyle = new SimpleAttributeSet(StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE));
    static
    StyleConstants.setFontFamily(normalStyle, "Courier");
    StyleConstants.setFontSize(normalStyle, 12);
    public WierdScroll()
    super("Wierd Scrolling \'feature\'");
    // create and setup the components
    screen = new JPanel();
    scrollPane = new ScrollPane();
    scrollPane.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(250, 155));
    scrollPane.setMinimumSize(new Dimension(10, 10));
    scrollPane.updateConstraintView();
    button = new JButton("Force update");
    button.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(ActionEvent e)
    scrollPane.updateConstraintView();
    b2 = new JButton("toggle InsertString Active");
    b2.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(ActionEvent e)
    JButton b = (JButton) e.getSource();
    scrollPane.allowInsertString = !scrollPane.allowInsertString;
    scrollPane.updateConstraintView();
    // add the component to the frame
    screen.add(scrollPane);
    screen.add(button);
    screen.add(b2);
    getContentPane().add(screen);
    public static void main(String[] args) {
    JFrame frame = new WierdScroll();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    frame.pack();
    frame.setVisible(true);
    // this extended class is the scrollpane. The problem occurrs when the doc.insertString function is called;
    // When insertString is called, the scroll pane flicks to the bottom of the scroll view but when insertString
    // is not called then the setViewPostion works OK....
    public class ScrollPane extends JScrollPane
    public JPanel panel;
    public JTextPane margin;
    public boolean allowInsertString = true;
    /** Creates a new instance of ConstraintView */
    public ScrollPane()
    // create the pane
    margin = new JTextPane();
    // create the label
    JPanel jp = new JPanel();
    jp.setBackground(Color.red);
    jp.setPreferredSize(new Dimension(500,500));
    panel = new JPanel();
    panel.setBackground(Color.white);
    // add the label and pane to the panel
    panel.add(margin);
    panel.add(jp);
    // set the scroll voew to be the panel
    setViewportView(panel);
    public void updateConstraintView()
    // if doc has stuff in it, then clear contents
    Document doc = margin.getDocument();
    if (doc.getLength() > 0)
    try
    doc.remove(0, doc.getLength());
    catch (BadLocationException ble) {}
    // the allowInsertString is toggled via button on screen to stop insertString call
    if (allowInsertString)
    try {
    doc.insertString(0, "1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n", normalStyle);
    catch (BadLocationException ble) {}
    // set viewport so that it scrolls to top
    getViewport().setViewPosition(new Point(0,0));

    Cheers!
    using the setCaretPosition() of the JTextPane instead of the getViewport().setViewPosition(new Point(0,0)) method of the JScrollPane works a treat.
    But I would have thought that the scroll pane should have 'complete' control (unless specified by programmer) of what it displays. It seems strange to have a component of a scrollpane dictate to the scrollpane what it should show...
    Thanks for your assistance.
    On a different note, has anyone noticed that the word 'c l a s s' has become cl***?? Is this a victim of sun's new swear filter to go with the new site look?

  • JTextPane: scroll with wheel when using addMouseWheelListener()

    Hello! I have JTextPane with code (code editor) with busy mouseWheelListener() which is used to increase/decrease font size when Ctrl key is hold. I think I overwrite default wheelListener behavior, so it is impossible to scroll text with a wheel. How can I do that?
    My code is below:
    JTextPane editor = new JTextPane();
    editor.addMouseWheelListener(new MouseWheelListener() {
                public void mouseWheelMoved(MouseWheelEvent e) {
                    if (e.getModifiers() == InputEvent.CTRL_MASK) {
                        int notches = e.getWheelRotation();
                        Component originator = e.getComponent();
                        float prevFontSize = originator.getFont().getSize();
                        if (notches < 0) {   //if UP then descrease font size
                            if (prevFontSize > 12.0f)
                            originator.setFont(originator.getFont().deriveFont(prevFontSize - 2));
                        else {  //if DOWN increase
                            originator.setFont(originator.getFont().deriveFont(prevFontSize + 2));
    JScrollPane editorWithScrolls = new JScrollPane(editor);
    //...nothing happens when I scroll mouse wheel...
    How can I scroll text with mouse wheel in my case?
    P.S. May be anybody knows how to scroll and set caret to given line(word)?
    Thank you.

    the textpane processes the event before it gets to the scrollpane.
    you need to "pass it on"
                        else {  //if DOWN increase
                            p.setFont(originator.getFont().deriveFont(prevFontSize + 2));
                    [scrollpane].dispatchEvent(e);//<--------------------------
            });

  • Scrolling to a given line or offset  in a JTextPane   *Please Help*

    I have looked on the web and do not see a solution to this problem. Maybee I am missing somthing very easy here.
    I am using a JTextPane to display text of multiple colours.
    The JTextPane is contained within a JScrollPane.
    I am using a highlighter to highlight individual lines of text within this JTextPane.
    However, the highlighted text may be outside of the viewport of the scrollPane and not be visible.
    How do I scroll so that the highlighted line of code is visible????
    I know you can scrollToVisibleRect. However how do I get the rectangle coordinates from a line of code, or from the highlighter.
    Is it possibile and easy to scroll to make an offset or line number visible.????
    So far I have tried:
    setCaretPosition();
    However this causes problems with highlighting.
    Cheers
    Andrew.

    In the future, Swing related questions should be posted in the Swing forum.
    So far I have tried:
    setCaretPosition();
    However this causes problems with highlighting.Makes no sense, setting the caret position has nothing to do with highlighting. Sounds like you have some other bug. Setting the caret position should work.
    I know you can scrollToVisibleRect. However how do I get the
    rectangle coordinates from a line of code, or from the highlighterAssuming you know the offset of the text you can use
    textPane.modelToView(...)
    to get the location of the text.

  • Horizontal scroll bar on JTextPane

    Hey everyone! I need to know how I can add a horizontal scroll bar to a jTextPane. I can NOT use a jTextArea though because I need to be using a StyledDocument. Right now, when I add it to a jScrollPane, it only scrolls vertically, but it wordwraps. Thanks for reading!

    Override getScrollableTracksViewportHeight() method to return false and at the same time, override setSize() method to adjust size of text pane. Following example shows this:
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    * TextPane without wrap.
    * @author mrityunjoy_saha
    * @version 1.0
    * @since Apex 1.2
    public class NoWrapTextPaneTest {
        private JTextPane editor;
        public NoWrapTextPaneTest() {
            JFrame frame = new JFrame("NoWrapTextPaneTest");
            frame.setSize(new Dimension(300, 400));
            //frame.setResizable(false);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.editor = new JTextPane() {
                @Override
                public boolean getScrollableTracksViewportWidth() {
                    return false;
                @Override
                public void setSize(Dimension d) {
                    Dimension pSize = getParent().getSize();
                    if (d.width < pSize.width) {
                        super.setSize(pSize.width, d.height);
                    } else {
                        super.setSize(d);
            frame.getContentPane().add(new JScrollPane(editor,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
            frame.setVisible(true);
        public static void main(String[] args) {
            NoWrapTextPaneTest textPaneTest = new NoWrapTextPaneTest();
    } Thanks,
    Mrityunjoy

  • JScrollPane Scroll Position

    Tried posting this in the newbie section with no luck....
    I created a class extending a JScrollPane that encompasses a JTextPane. The method below appends some text to the current JTextPane with a certain color (this part works fine). What I am also trying to do is force the JScrollPane to keep focus at the bottom after the append if it was there before the append. Now I am running into trouble.
    The code can determine fine if the scroll pane is at the end, but after the append, it sometimes prematurely puts the pane at the end again; i.e. the method is telling the scroll pane to go to the end before the text pane and/or scroll pane have finished updating their size. Thus, the scroll pane is moved to the bottom, then the text and scroll panes resize, and the scroll pane is no longer at the bottom.
    It seems that this problem occurs when the text appended is multiple lines, in which case it appears that the panes are resized multiple times- the scroll bar is positioned correctly after the first resize, but subsequent resizings sometimes occur after I reposition the scroll bar to the current "end" (which then changes).
    I've tried validating both panes to force them to update before repositioning the scroll bar, but this does not seem to stop the problem (although it may help).
    Does anyone know how to correct this problem? I'm still guessing that something (perhaps the doc?) is not fully updated by the time I reposition the scroll bar. If this is the problem, any suggestions on how to force the document to be updated before playing with these GUI panes? If possible, I prefer not to use a timer or sleep a thread to wait for this updating.
    Of course, if you know of existing methods/settings that help with this, please tell. I didn't manage to find anything in the API's that gave me what I want, but I've been known to overlook things from time to time ;)
    Again, this is a method in a class extending JScrollPane.
    textPane is the JTextPane embedded in the scroll pane.
    doc is the JTextPane document.
    public synchronized void append(String appendString, Color textColor)
         JScrollBar scrollBar;
         BoundedRangeModel rangeModel;
         boolean isMaxed;
         scrollBar = this.getVerticalScrollBar();
         rangeModel = scrollBar.getModel();
         isMaxed = ((rangeModel.getValue() + rangeModel.getExtent())
                             == rangeModel.getMaximum());
              // check if the scroll bar is at the bottom
         SimpleAttributeSet textAttributes = new SimpleAttributeSet();
         StyleConstants.setForeground(textAttributes, textColor);
         try
              doc.insertString(doc.getLength(), appendString, textAttributes);
              // append the formatted string to the document
         catch(BadLocationException ex)
              System.out.println("Error writing to the text pane");
         if (isMaxed)
              textPane.validate();     //force the text pane to validate
              this.validate();    //force the scroll pane to update
              scrollBar.setValue(rangeModel.getMaximum() - rangeModel.getExtent());
              // The above line is sometimes called before the text and scroll panes
              // have finished updating.  The maximum and extent of the scroll bar
              // depend on the size of the document.

    You are correct in your observation that the size of the JScrollPane is incorrectly reflected for the size of your newly appended document. I spent some time on this bug and eventually came up with the following solution:
    textPane.addComponentListener( new ComponentListener(){
    public void componentHidden(ComponentEvent e)
    public void componentMoved(ComponentEvent e)
    public void componentResized(ComponentEvent e)
    JViewport vp = scrollPane.getViewport();
    incoming.revalidate();
    Rectangle visRect = vp.getViewRect();
    Dimension viewDim = vp.getViewSize();
    Rectangle rect = new Rectangle( 0, (int)(viewDim.getHeight() - visRect.getHeight()),
    (int)visRect.getWidth(), (int)visRect.getHeight() );
    vp.scrollRectToVisible( rect );
    public void componentShown(ComponentEvent e )
    This solution also has the side benefit of scrolling to the bottom when the JTextPane is resized by the user.

  • Scrolling to the bootom of document

    Hi,
    It is a loing time.
    i find some thing very interesting concerning the scrollinpane problem with document. y code is this
    document = new DefaultStyledDocument();
    textArea = new JTextPane(document);
    textArea.setFont(new Font("Serif", Font.PLAIN, 13));
    textArea.setEditable(true);
    JScrollPane areaScrollPanea = new JScrollPane(textArea);
    i made a chat so i expect that the last post should be at the bottom of the scrollpane.
    I find that it is not amway the case. If i insert line like
    document.insertString(document.getLength(), toto+"\n", attrs);
    inise a thread the scroll lost the last line and stop moving donw.
    But i find out that if you clik with the mouse inside the document wich is inside the scrollpane "of course you need to set textArea.setEditable(true);"
    everything start again normally.
    but i do not know how to do it automaticly.
    i just want to put the last line visible.
    regards
    Herve

    thank you it is fine with this
    document.insertString(....)
    textPane.setCaretPosition( textPane.getDocument().getLength() );

  • Scrolling a JViewport

    Hello,
    I am using a JScrollPane to display a JTextPane with a StyledDocument containing a bunch of text. I am successfully using DefaultHighlighter to highlight a word in the JTextPane.
    I would like to get the JViewPort to scroll down so that the top line is on the same line that contains the highlighted word (similar to the "find" function in a text editor).
    Any ideas on how to do this?

    textPane.scrollRectToVisible(textPane.modelToView(int));

  • JScrollPane- Scrolling makes the contents of the Pane garbled

    I have a JTextPane inserted into a JScrollPane and the JSrcollPane is Inserted into the bottom part of the JSplitPane..
      private JTextPane ResultTextPane = new JTextPane();
      ResultScrollPane.getViewport().add(ResultTextPane, BorderLayout.CENTER)
      ResultSplitPane.add(ResultScrollPane, JSplitPane.BOTTOM);Now, When i try scrolling the scrollpane, the text is garbled. (A part of text seems be to dragged when the scroll bar is moved..).If i resize the window, the text is displayed fine and if I start scrolling, the text gets garbled again..
    I am not sure what the problem is? Am I suppose to use a scrollinglistener(AdjustChangeListener) and repaint the contents of the textpane or is it suppose to be happen automatically.

    The easiest way to use a JScrollPane is:
    JScrollPane scrollPane = new JScrollPane( textPane );
    If you need to reset the component in the scrollPane then you would use:
    scrollPane.getViewport().setView( textPane );
    Dont use the add(..) method of the viewport.

  • JTextPane settext scrolling bahaviour

    Hi
    I have a JTextPane in a scrollpane to show HTML text with some hyperlinks and images. What i want to do is update some parts of it, and keep the viewport at the same position. The new content in the textpane has the same size, i just change the background of some cells in a HTML table. The code looks something like this:
    JTextPane infoPane = new ...
    JScrollPane infoScroll = new JScrollPane(infoPane);
    // Save the current view
    Rectangle rect = infoScroll.getViewport().getViewRect();
    // Set the new content
    infoPane.setText(".....");
    // Restore the old view
    infoPane.scrollRectToVisible(rect);
    // Make sure the rectangle has relevant data for debugging
    System.out.println(rect);The problem is: settext() seems to force the scrollpane to scroll to the end of the document a while after the text is set. So, the position is right some milliseconds after i call settext and scrollrecttovisible, and then it scrolls to the end. An ugly workaround i found was creating a timer and calling infoPane.scrollRectToVisible(rect) 500 ms or so after i set the text.
    It looks like settext has some listeners (or something else) that perform the scrolling a while after it is called, but i just cant find a way to prevent it. I have spent many hours looking on google without success, so help is much appreciated.
    Thanks in advice.

    Thank you so much!!
    After i read that i fixed the problem in 2 minutes, and before i spent many hours on it without success. Everything i needed to do was adding:
    DefaultCaret caret = (DefaultCaret)infoPane.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);to the beginning of my code, and now i dont need to save any rectangle at all. It just works the way i hoped it would.

  • Prevent JScrollpane from scrolling... + JTextPane

    hello,
    i've a JScrollPane(JTextPane) which displays html-code provided by the setText()-method. but i'd like the JScrollPane NOT to scroll automatically to the bottom when the programm inserts new html-code with setText(). setting the JScrollBar-Value doesn't work. I need something to prevent the JScrollBar from scrolling....
    by the way, does anyone know a way to append text to a JTextPane (line by line)... JTextPane provides only a setText()-method which overwrites the old content with the new text... i'd like to append it....
    thanks,
    andi

    This has taken me over a year to figure out. I spent lots of time trying to set the viewport back to the top or moving the scroll bar back to the top. I even tried inserting text at the very begining. None of this works. What does work is setting the cursor (caret) to the begining of the text pane after you add the text. Something like this:
    document.insertString(document.getLength(),"...lots of text...",attr);
    textPane.getCaret().setDot(0); << the big secret
    Pretty easy huh?

  • A Scrolling Problem

    Hi all I have a little problem I wana get fixed...its a little bit long problem so better help me out with this:
    A swing application that has four textfield which accepts pure string and saves it to a database..theres a button when clicked will show the first record in the database and displays exactly the record in the four textfield...now here goes my question:
    How do you scroll 1 record at a time thru the database and display record 2,3,4,5 and so on until the last record and display it to the textfield assuming we have button labelled next? and how will you reverse the process assuming you have button labelled previous which when clicked will display 1 record at a time in the textfield until it reaches the first record? I can display the first and the last record but scrolling one record at a time, that i cant do...hope you can help me with this or maybe give me some thread to get some idea with this...thanks and God bless to all...

    The other way of doing this, which may be easier, is the follwing
    pane.getVerticalScrollBar().setValue(pane.getVerticalScrollBar().getMaximum());where pane is the scrollPane. This will scroll to the bottom of the text pane.
    One other point, you may find it more efficient on memory if you added the new message using the document instead of creating a new string from the old text and the new text to add. E.g
    instead of
    textPane.add(textPane.getText() + "\n" + newMessage);use
    Document doc =  textPane.getDoument();
    doc.insertString(doc.getLength(), "\n" + newMessage, null);Hope that helps
    wwe8

Maybe you are looking for

  • When is Firefox Mobile getting mp3 and aac html5 support?

    I want to be able to use Firefox for Android to listen to music through Grooveshark's html5 website. From what information I've been able to gather Firefox for Android must still only have ogg hmtl5 support and I don't want to have to use Chrome or t

  • Keeping Validations in a user exit

    Hi folks,          I am trying to keep some validations for attachments in ME51N Tcode. Before saving the document, system will check for the attachment.If it is empty it will prompt a error message saying its mandatory.After seeing the message when

  • SSCC Generation

    Hello All, I am implementing HUM with SSCC generation during shipping. I am maintaining the following settings: SU number range : 00000000400000000000 - 00000000999999999999 (12 Digits) HU Number Range : 00000000400000000000 - 00000000999999999999 (1

  • TS1424 Error when signing into apple id through itunes

    Cannot purchase a song, when trying to sign in with apple id.

  • ConfigMgr 2012 Released versions

    Hello all. I want to replace sccm 2007 sp2 r3. i know there are sccm 2012 different versions . "sccm 2012 r2 cu2" and "sccm 2012 sp1 cu5". what are the differences ? to what version should i replcae to ?