Getting Scroll bar to Return to Top.

This is my first time messing with Swing (always thought the GUI guys didn't know how to program) anyway, it's kinda fun to add a nice interface to the rest of my code. I send a command to something and get a return vector back, however, when I reprint all the data the scroll bar ends up at the bottom instead of the top where the new information is. Here's my code. The last method is the one that does the Text Area updating.
package com.ibm.SvcCliSimulator.RMI;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class RMIUI extends JFrame {
     JPanel contentPane;
     JPanel jPanel1 = new JPanel();
     JLabel inputLabel = new JLabel();
     JTextField textField = new JTextField();
     JButton jButton1 = new JButton();
     JScrollPane jScrollPane1 = new JScrollPane();
     static JTextArea returnInfo = new JTextArea();
     GridBagLayout gridBagLayout1 = new GridBagLayout();
     RMIInterface cmdSender;
     Vector aReturnVec = new Vector();
     public RMIUI(RMIInterface cmdSdr) {
          enableEvents(AWTEvent.WINDOW_EVENT_MASK);
          try {
               jbInit();
               cmdSender = cmdSdr;
          catch(Exception e) {
               e.printStackTrace();
     private void jbInit() throws Exception  {
          //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
          contentPane = (JPanel) this.getContentPane();
          contentPane.setLayout(gridBagLayout1);
          this.setSize(new Dimension(550, 450));
          this.setTitle("Frame Title");
          jPanel1.setOpaque(false);
          jPanel1.setLayout(null);
          inputLabel.setOpaque(true);
          inputLabel.setText("Enter Command:");
          inputLabel.setBounds(new Rectangle(6, 12, 100, 26));
          textField.setText("svinfo -x list -o");
          textField.setBounds(new Rectangle(106, 11, 271, 28));
          jScrollPane1.setBounds(new Rectangle(8, 64, 532, 374));
          jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
          returnInfo.setBackground(new Color(224, 208, 204));
          returnInfo.setEditable(false);
          jButton1.setText("Send Command");
          jButton1.setBounds(new Rectangle(388, 11, 150, 30));
          jButton1.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    String cmd = textField.getText();
                    try {
                         aReturnVec = cmdSender.sendCommand("11.111.11.1", cmd);
                         printVector(aReturnVec, cmd);
                    catch (Exception ex){
                         System.out.println(ex);
          textField.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    String cmd = textField.getText();
                    try {
                         aReturnVec = cmdSender.sendCommand("11.111.11.1", cmd);
                         printVector(aReturnVec, cmd);
                    catch (Exception ex){
                         System.out.println(ex);
          jPanel1.add(inputLabel, null);
          jPanel1.add(textField, null);
          jPanel1.add(jScrollPane1, null);
          jScrollPane1.getViewport().add(returnInfo, null);
          contentPane.add(jPanel1,  new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
                    ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 2, 3, 3), 544, 440));
          jPanel1.add(jButton1, null);
     protected void processWindowEvent(WindowEvent e) {
          super.processWindowEvent(e);
          if (e.getID() == WindowEvent.WINDOW_CLOSING) {
                 System.exit(0);
     public static void printVector(Vector v, String cmd){
          String old = returnInfo.getText();
          String s = cmd + "\n";
          for (int i=0; i<v.size(); i++)
               s += (v.elementAt(i) + "\n");
          s += "\n\n" + old;
          returnInfo.setText(s);
}

Thanks a bunch....
returnInfo.setCaretPosition(0);
worked just fine. As I said, it's my first outting into this Swing deal.

Similar Messages

  • [svn:fx-trunk] 11697: Get scroll bars back.

    Revision: 11697
    Author:   [email protected]
    Date:     2009-11-12 08:15:17 -0800 (Thu, 12 Nov 2009)
    Log Message:
    Get scroll bars back.  Yesterday's rev 11652 which added an invalidateSize() call to the damageHandler interacts badly with a hack in measure() for the scroller to help it deal with resizes that sets _contentWidth and _contentHeight to 0.  It is possible that there will be a remeasure, but nothing needs to be composed so _contentWidth and _contentHeight are not updated and the scroller thinks scroll bars are needed.
    Remove the code which set _contentWidth and _contentHeight to 0 added for SDK-22469. Much has changed in both RET and the scoller since this code was done.  I retested SDK-22469 and it looks good with the code removed and we have scroll bars back when they are needed.
    QE notes: could retest SDK-22469 if you desire, need a mustella test for the absence of scroll bars when they should be there
    Doc notes:
    Bugs:
    Reviewer: will be Gordon
    Tests run: checkintests, TextArea
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-22469
        http://bugs.adobe.com/jira/browse/SDK-22469
        http://bugs.adobe.com/jira/browse/SDK-22469
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/RichEditableText.as

    Thats good news.

  • Can I get scroll bars in lion?

    can I get scroll bars in lion?

    Ninja-neko wrote:
    can I get scroll bars in lion?
    System Preferences > General > Show Scroll Bars
    Pete

  • Cant Get Scroll Bars to Show in iMac

    In one of my user account, I can't get the scroll bars to show!!!
    I want in preference-general and select ''Always'' under Show Scroll Bars, but I can't see them in Safari, Mail...
    When I close Preference, my ''Always'' selection is gone and it return to '' Automatically based on input device''
    Can you help?

    Do preferences in other programs run in this account stick? That is if you change a Safari preference or Finder preference in this account does the new settings remain?
    If in System Preferences you change Restore windows when quitting and re-opening apps does it stick?
    Try this:
    restart you machine holding down the option key while the machine reboots. You will be presented disk icons which allow you to choose which drive to boot off, select the Recovery HD.
    Once the system comes up in Recovery mode go past the language select screen and the select the Utilities menu item at the top of the screen. Select Terminal.
    In the open terminal window type resetpassword and press return. The Reset Password window will open. Select the root HD, then select the user account that is having the problem. Then at the bottom of the window select Reset Home Folder Permissions and ACLs
    Then quit Reset Password, quit Terminal then quit Mac OS X Utilities. The restart the machine.
    Try the System Preferences report back if that didn;t fix the problem.
    good luck

  • How do I get scroll bars to work

    I get a vertical scroll bar where I don't want one.  The horizontal one (see attachment) is needed as the form gets quite wide when it is in Spanish.  But despite turning off verticalScrollPolicy everywhere, one of them still appears.
    <mx:AddChild relativeTo="{bodyFormHolder}" position="firstChild">
    <mx:VBox id="resultsPageBox"
    backgroundColor="#dedacf"
    width="100%"
    height="100%"
    verticalScrollPolicy="off" horizontalScrollPolicy="off">
    <mx:HBox id="rAccessHBox"
        minWidth="640" width="100%"
        x="0" y="0">
    </mx:HBox>
    <!-- across top *********************************************** -->
    <!-- ********************************************************** -->
    <mx:VBox id="topResultBox"
        verticalScrollPolicy="off" horizontalScrollPolicy="off"
        width="100%"
        styleName="backColor" >
    </mx:VBox>
    <mx:HBox id="bothSides"
        verticalScrollPolicy="off"
        width="100%"
        height="100%">
        <!-- first column ***************************************** -->
        <!-- ****************************************************** -->
        <mx:VBox id="leftSideCanvas"
            verticalScrollPolicy="off"
            width="50%"
            height="100%"
            focusEnabled="false"
            styleName="backColor">
        </mx:VBox>
        <!-- second column **************************************** -->
        <!-- ****************************************************** -->
        <mx:VBox id="rightSideCanvas"
            verticalScrollPolicy="off"
            backgroundColor="#dedacf"
            y="0"
            width="50%"
            height="100%">
        </mx:VBox>

    A bigger question is how to get the scroll bars to work from the keyboard.  The problem is to be accessible, the application must be available to blind or physically handicapped people that can't use a mouse.
    To get the entire form read requires horizonal scrolling in some cases such as when it is in Spanish or the font size it increased a lot.  Now, a horizontal scroll bar appears and is easily movable via the mouse, but we have to have it move without a mouse.
    I found the vertical bar came from the form object and I eliminated that, but the bigger issue still remains.

  • Table Grid resizing,How to avoid getting scroll bar in the browser

    Hi All,
    Requirement is to enable Grid Resizing feature in the Table UI element. The table will have  approx 12-30 columns
    For providing this feature on the table UI element, we have set the following properties
    'ScrollableColCount' Property of table UI is set to -1.
    'Resizable' property of each column is set to true.
    This will remove the scrollbar at table level and all the columns will be shown on the screen at one time.
    Problem encountered:
    1. Horizontal  scroll bar will be introduced on the screen.We tried giving width in pixels  to individual column grid but unable to eliminate this scroll bar in the screen.   
    2. Also the resizing properties modified for a table grid will be applied on the similar task screen having table UI element.
       For Example: In GP Workflow,if USer1 holds 2 task(Task A and B) of an application. If he resizes the column of the table in A task then these changes will be reflected in the B task table UI also.
    Please provide pointers on this.
    Thanks and Regards,
    Pradeep

    Hi,
    In table set tablecellEditor wrapping property to true,by default its false.
    By this you can get value in many rows(per row size is depend on whatever u have given for column width).
    this way you can avoid scroll bar.
    Regards
    Trilochan

  • Scroll bar only scrolls the top ~300 pixels

    The latest update of Nightly is unusable. The scroll bar only changes the top 300 pixels or so of the page. Then the links do not work in the bottom portion, and you can't see the entire page.
    Troubleshooting info:
    "application": {
    "name": "Firefox",
    "version": "36.0a1",
    "userAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0",
    "supportURL": "https://support.mozilla.org/1/firefox/36.0a1/WINNT/en-US/",
    "numTotalWindows": 2,
    "numRemoteWindows": 0
    "crashes": {
    "submitted": [],
    "pending": 0
    "modifiedPreferences": {
    "browser.cache.disk.capacity": 358400,
    "browser.cache.disk.smart_size.first_run": false,
    "browser.cache.frecency_experiment": 1,
    "browser.places.smartBookmarksVersion": 7,
    "browser.sessionstore.upgradeBackup.latestBuildID": "20141022030202",
    "browser.startup.homepage_override.mstone": "36.0a1",
    "browser.startup.homepage_override.buildID": "20141022030202",
    "dom.mozApps.used": true,
    "extensions.lastAppVersion": "36.0a1",
    "media.gmp-gmpopenh264.lastUpdate": 1414067969,
    "media.gmp-gmpopenh264.version": "1.1",
    "media.gmp-manager.lastCheck": 1414067968,
    "network.cookie.prefsMigrated": true,
    "places.history.expiration.transient_current_max_pages": 104858,
    "plugin.disable_full_page_plugin_for_types": "application/pdf",
    "privacy.sanitize.migrateFx3Prefs": true
    "lockedPreferences": {},
    "graphics": {
    "numTotalWindows": 2,
    "numAcceleratedWindows": 0,
    "windowLayerManagerType": "Basic",
    "windowLayerManagerRemote": true,
    "numAcceleratedWindowsMessage": [
    "blockedGfxCard"
    "adapterDescription": "RDPDD Chained DD",
    "adapterVendorID": "0x0000",
    "adapterDeviceID": "0x0000",
    "adapterSubsysID": "00000000",
    "adapterRAM": "Unknown",
    "adapterDrivers": "RDPDD",
    "driverVersion": "",
    "driverDate": "",
    "adapterDescription2": "",
    "adapterVendorID2": "",
    "adapterDeviceID2": "",
    "adapterSubsysID2": "",
    "adapterRAM2": "",
    "adapterDrivers2": "",
    "driverVersion2": "",
    "driverDate2": "",
    "isGPU2Active": false,
    "direct2DEnabled": false,
    "directWriteEnabled": false,
    "directWriteVersion": "6.1.7601.17563",
    "direct2DEnabledMessage": [
    "blockedGfxCard"
    "webglRendererMessage": [
    "blockedGfxCard"
    "info": {
    "AzureCanvasBackend": "skia",
    "AzureSkiaAccelerated": 0,
    "AzureFallbackCanvasBackend": "cairo",
    "AzureContentBackend": "cairo"
    "javaScript": {
    "incrementalGCEnabled": true
    "accessibility": {
    "isActive": false,
    "forceDisabled": 0
    "libraryVersions": {
    "NSPR": {
    "minVersion": "4.10.7",
    "version": "4.10.7"
    "NSS": {
    "minVersion": "3.17.2 Basic ECC",
    "version": "3.17.2 Basic ECC"
    "NSSUTIL": {
    "minVersion": "3.17.2",
    "version": "3.17.2"
    "NSSSSL": {
    "minVersion": "3.17.2 Basic ECC",
    "version": "3.17.2 Basic ECC"
    "NSSSMIME": {
    "minVersion": "3.17.2 Basic ECC",
    "version": "3.17.2 Basic ECC"
    "userJS": {
    "exists": false
    "extensions": [
    "name": "McAfee Security Scan Plus",
    "version": "1.0",
    "isActive": false,
    "id": "{e4f94d1e-2f53-401e-8885-681602c0ddd8}"
    "experiments": []
    }

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to get rid of scroll bars on an edge animation in a fluid grid page

    I'm playing with a page that will contain an edge animation (basically just a panorama view sliding across the stage from right to left).  My thought was that when the page was displayed on a tablet or phone the user would just see less and less of the animation--i.e., as if the panorama was sliding across a smaller stage.  In my css I've specified overflow: hidden for the div that contains the animation, and in the animation itself I've specified overflow: hidden for the stage.   This works fine in Live view, but when I preview the page in a browser (chrome, safari, IE) I get scroll bars.  The animation also behaves as I want it to when I preview it in a browser by itself--i.e., not as a part of a fluid grid page.  I could live with a horizontal scroll bar, and there might even be an argument in its favor, but the vertical bar is a definite problem.  I've tried refining my css to overflow-y : hidden, but that doesn't have any effect either
    Any help would be great.
    Thanks,
    Peter

    I found an work around, albeit an inelegant one, so the link I posted to Nancy's reply now works.  What I found is that the edge animation produces an html document with a body style.  If I plug my overflow style there, voila, alls good.  Of course it will be overwritten if I regenerate the animation, but at least it's progress.
    p

  • I can no longer click to have my scroll options appear for scrolling.. there is no top or bottom option anymore.. help!

    when i was using internet explorer i was able to click on the scroll bar and move from top to bottom of page and other things.. there is no longer this option with foxfire.. i must now click individually to move!! what a pain.. please help me..

    You can try http://kb.mozillazine.org/middlemouse.scrollbarPosition
    See also http://kb.mozillazine.org/about%3Aconfig

  • How do i get that bar to appear on the screen for http and web pages?

    How do i get that bar to appear on top of the screen for http and web pages?

    Yes im using safari version  5.1.2 (6534.52.7)  I have tried clicking show toolbar  from the view menu but i still can't see it.  It's the bar where you type in a website link or http:// that I can find - any other suggestions much appreciated

  • ADF Calendar : scroll bar in specific date

    Dear all,
    By default, the ADF calendar component displays many events found in a specif day as "+2 more", "+3 more" or "+X more" . . . . and as we click on the link, we view them in the day view.
    Is there any way to display all the events under the same day and view them by using a scroll-bar found inside the day square space? I need to view all events without going to the day view
    I need to view all events found on a specific day to be able to drag and drop it to any day directly on the Month view
    Thanks in advance

    Hi,
    You could use the following to get scroll bars around your table. It may not be ideal as the scroll bar is for the entire table, so when you scroll your headers will also scroll.
    You will need to hard code your height, and set some margin for vertical scroll bar in IE (thats why the 98% width!). But atleast its better than nothing..
    <af:table width="98%" id="xx" ...
    inlineStyle="overflow-x: hidden; overflow-y: auto;height: 450px;"
    rows="15">
    </af:table>
    HTH
    Jaimon

  • When I open gmail, I cannot use the vertical scroll bar.

    When I use the gmail website on firefox, the vertical scroll bar. As there is no horizontal scroll bar on the website, the vertical scroll bar layers over the top of the page resizer and makes the arrow button for the scroll unusable.
    Please advise.

    you may be connected to the wireless network but the question is the internet working properly on the wireless network...
    what i mean is that i can make a wireless network without the internet so i can save and share files and have other devices connected to the same network access them... but you have to make sure that your internet it running properly... may have to reconfigure the router is your using PPPOE or if it was working prior to your post then try to restart your modem... that usually resolves most issues.

  • ADF - scroll bar in table.

    Hi
    I am using jdevloper 10.1.3.3
    I have to make scrollbar in table region.not in page level.please let me know.how to do that.
    please help me

    Hi,
    You could use the following to get scroll bars around your table. It may not be ideal as the scroll bar is for the entire table, so when you scroll your headers will also scroll.
    You will need to hard code your height, and set some margin for vertical scroll bar in IE (thats why the 98% width!). But atleast its better than nothing..
    <af:table width="98%" id="xx" ...
    inlineStyle="overflow-x: hidden; overflow-y: auto;height: 450px;"
    rows="15">
    </af:table>
    HTH
    Jaimon

  • Vertical Scrolling  bar

    Hi All,
    I am using table control to display some data which is in two internal tables, but if the range of values in any one internal is more than 31 then its not showing the rest 9. before the scrollable bar was not coming then i tried assigning some value to TABLE1-LINES  and now its coming , but when i am trying to scroll its going back to input selection screen.
    Can anyone please help me out ASAP.
    Regards
    Siddhartha Sengupta

    Hi,
      You use this code to get scroll bar.
    TABLE1-CURRENT_LINE = 1.
      DESCRIBE TABLE ITAB_ITEM LINES TABCOUNTER.
      IF TABCOUNTER = 0.
        TABLE1-LINES = 100.
      ELSE.
        TABLE1-LINES = TABCOUNTER + 1.
      ENDIF.
    TABLE1- Table controll name.
    ITAB_ITEM- Internal table name.
    IF USEFULL REWARD

  • Add scroll bars to TextArea - how?

    I have an application which reads user input to a text file and then on click of JButDisplay reads the contents of the file to a TextArea.
    Problem is I can't seem to get scroll bars onto the TextArea, I tried using JScrollPane,
    but had no luck (I'm using gridBagLayout)
    Could someone please advise me how to add scrollbars to this component?
    TADisplay2 = new JTextArea(10,20);     
                   c.ipadx = 12;
                   c.ipady = 12;
                        c.gridx = 2;
                        c.gridy=18;
                        c.gridwidth = 2;   //2 columns wide
                        c.gridheight = 4;
                             gridbag.setConstraints(TADisplay2, c);
                             contentPane.add(TADisplay2);

    1) Create scrollPanel
    2) Make it fill your content pane (or whatever area you wish to cover)
    3) Add your textArea to the scrollpanel

Maybe you are looking for