Newsfeed: keep the first lines visible on previous/next 72/17772/2
Clément DAVID [Fri, 5 Feb 2016 13:56:40 +0000 (14:56 +0100)]
Tip: moving the caret to from the end to the beginning will move the
viewport as the caret position is always visible.

Change-Id: If8d3cfb7a5a4587ce03dedd1a1777a468f673704

scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/newsfeed/NewsFeedWidget.java

index c643267..538645c 100644 (file)
@@ -32,6 +32,7 @@ import javax.swing.UIManager;
 \r
 import java.awt.BorderLayout;\r
 import java.awt.Font;\r
+import java.awt.Point;\r
 import java.awt.event.ActionEvent;\r
 import java.io.File;\r
 import java.text.SimpleDateFormat;\r
@@ -101,8 +102,6 @@ public class NewsFeedWidget extends JPanel implements NewsFeedEventListener, Hyp
         }), BorderLayout.EAST);\r
 \r
         scrollPane = new JScrollPane(editorPane);\r
-        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);\r
-        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);\r
 \r
         setLayout(new BorderLayout());\r
         add(headerPane, BorderLayout.NORTH);\r
@@ -200,13 +199,12 @@ public class NewsFeedWidget extends JPanel implements NewsFeedEventListener, Hyp
         try    {\r
             SwingUtilities.invokeLater(new Runnable() {\r
                 public void run() {\r
-                    scrollPane.getHorizontalScrollBar().setValue(0);\r
-                    scrollPane.getVerticalScrollBar().setValue(0);\r
-\r
                     headerButton.setAction(titleAction);\r
                     headerButton.setToolTipText(titleAction.getValue(Action.NAME).toString());\r
 \r
                     editorPane.setText(htmlContent);\r
+                    // reset position to the upper left\r
+                    editorPane.setCaretPosition(0);\r
                 }\r
             });\r
         } catch (Exception e) {\r