Those darn Scroll Bars!!

Ive looked at and tried many different tuts for adding a scroll bar to a JTextArea in my JFrames but they never seem to work... can someone please write me a small sample code for it? Heres a skeleton code for you to use if you want to help me...
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class thoseDarnScrollBars extends JFrame
     JTextArea textBox;
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
public static void main(String[] args)
          thoseDarnScrollBars frame = new thoseDarnScrollBars();
          frame.setVisible(true);
public thoseDarnScrollBars()
          Container c = getContentPane();
          setTitle("SCROLL BAR!");
          setSize(400, 300);
          setLocation(((int)screenSize.getWidth()/2)-(getWidth()/2), ((int)screenSize.getHeight()/2)-(getHeight()/2)); // center the box into the middle of the screen
          c.setLayout(null);
          textBox = new JTextArea("");
          textBox.setSize(390, 290);
          textBox.setLocation(5,5);
          c.add(textBox);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
}if someone could just take this code from me and add a working scroll bar i would be VERY thankful to you!

oh... well i like it and im gunna use it for the time being (I never publish my programs, im not skilled enough to, I still just write programs to keep myself learning to gain knowledge of the Java language before I start moving onto the proper coding methods (And I know, its always best to start of with good habits so that you dont stick with the bad ones). Ill start working with BorderLayout later on)
But ive figured out how to make it work with null as the layout:
textBox = new JTextArea();
JScrollPane scroll = new JScrollPane(textBox);
scroll.setSize(390, 290);; //set parameters for scroll as if it were for the text box in the way you would if scroll wasnt involved
scroll..setLocation(5,5);;//set parameters for scroll as if it were for the text box in the way you would if scroll wasnt involved
textBox.setBackground(Color.BLUE);//background and foreground parameters must be set to the textBox and not scroll
mainWindow.add(scroll);---EDIT---
NullLayout should never be used.And technically its not "NullLayout", its just "null" =)
Im just bein a... jerk?
Message was edited by:
HDL_CinC_Dragon

Similar Messages

  • Scroll Bar problem - BI Iview

    Hi,
    I've created a BW iView and added it to a Page which is attached to a Role.  When I execute the page on the portal , I get get a 2 vertical scroll bars one for the ivew and one for the external page. But the Horizontal scroll bar is hidden below. I have to scroll down to the bottom of the table to see the horizontal scroll bar.
    I would like to have the Horizontal scroll bar visible always ... How to do this..?
    Thanks

    You need to make sure that the iview containing the BI web app is tall enough to hold the entire app.  The first thing I would try is to increase the actual and maximum height of the BW iview.  Getting rid of those multiple scroll bars can be tricky.

  • [Desktop][Other] Scroll bars need to be brighter

    Hi - like others I'm not sure about the new shade of green, but I think the one real improvement needed is to lighten those grey scroll bars...the poor contrast against the dark background makes them very difficult to see particularly the right of screen one - white (or even the green!) would help... must be seriously awkward for any user who has a visual impairment... Cheers WRSpot the scroll!

    Updated: 2015-07-14Hello and thanks for the feedback!
    Any news regarding this request will be announced in the original idea topic here:
    https://community.spotify.com/t5/Live-Ideas/Desktop-Make-the-scrollbar-more-visible/idi-p/739199
    Please add your kudos and comments there, if you haven't already. ;)

  • Horizontal Scroll Bar (Possible Bug)

    Hello,
    I am working on a site, and I have encountered a strange bug that is adding a horizontal scroll bar to my page, and I have no idea why. While there are elements that are lying outside of the page, the scroll bar shows up way before they are close to the edge of the browser window. This happens in Chrome, Safari, and Firefox.
    What is very strange is that while trying to solve the issue, I removed several elements from my muse layout file, and I did find what was causing the issue. I have blue bars that act as headings for each section, and they are not 100% width (and I do not want them to be), and they were not off the page. However, once I removed those, the scroll bar stopped showing up so early when shrinking the browser window. I added the bars back in, one by one, and found out that depending on where I place the bar vertically will affect the horizontal scroll bar. This seems to happen whenever my bar is played below y: 1030. I have added screenshots to show this, and I can email my Muse file to Adobe support.
    Some of you may notice that I do have an element that hangs off the page, and while this is true, I do not believe that it affects the issue I am having. When I remove the blue rectangles as described in the paragraph above, the website behaves as expected, even with my ribbon hanging off the page. With the blue rectangles, the scroll bar appears much before the browser window encounters the blue ribbon.
    I have spent a lot of time searching for a solution, and playing with both the elements on my site and the page properties, and I cannot solve the issue. I just want there to be no scroll bar until the window is actually smaller than the page.
    Screenshots:

    Thank you for the great repro case. It was exceptionally helpful.
    You've exposed a bug that's probably been there forever which required just the right combination of objects both on the page and off the left of the page in order to be triggered. We'll write up a bug to be investigated for a future release. Unfortunately the next major release is due out very soon, so this bug won't be fixed in time for that release.  https://creativecloud.adobeevents.com/ccnext
    A workaround (that no doubt seems arbitrary but should work in every case) is to group the blue box with any other object. Sorry for the confusion and inconvenience.

  • How to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area

    how to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area
    ananya

    Hey Ananya,
    I believe what you want to do is possible, but it will not be
    easy.  If you want to add a scroll bar that will scroll the graph
    back and forth but keep the axis set, you would want to add a
    horizontal or vertical scrollbar.  Then you would create an event
    handler for the scroll event.  You would have to manually plot
    different data within this scroll event.  Unfortunately, there is
    not really a built in way to do this with the Measurement Studio plot
    control.
    Thanks,
    Pat P.
    Software Engineer
    National Instruments

  • The status bar is pushed up at about 3/4 of the screen, so I can view onlu firefox at about 1/4, good thing there is a scroll bar, but below the status bar is white display? can u please help me, I want to drag down the status bar so I can have a full vi

    The status bar is pushed up at about 3/4 of the screen, so I can view only Firefox at about 1/4, good thing there is a scroll bar, but below the status bar is white display? can u please help me, I want to drag down the status bar so I can have a full view
    == This happened ==
    Every time Firefox opened

    Your code is absolutely unreadable - even if someone was willing to
    help, it's simply impossible. I do give you a few tips, though: If you
    understand your code (i.e. if it really is YOUR code), you should be
    able to realize that your minimum and maximum never get set (thus they
    are both 0) and your exam 3 is set with the wrong value. SEE where
    those should get set and figure out why they're not. Chances are you
    are doing something to them that makes one 'if' fail or you just
    erroneously assign a wrong variable!

  • Scroll bars in Lion

    How do I adjust the scroll bars in Lion?  I want the scroll bars to be visible always, and wide (like they were in previous operating systems).
    In Lion, when I open a file, the scroll bar is invisible.  To get the scroll bar to appear, I have to stab blindly for the thing, until I get lucky and hit it.  Then, when the scroll bar does appear, it is excruciatingly narrow, and I have to really focus all of my mental powers in order to hit the darn thing.

    Thanks!
    I found the setting for "Show Scroll Bars."  However, I can't find the setting for the scroll-bar width.  How do I adjust scroll-bar width?

  • ITunes 7.3 update fixes fuzzy coverflow scroll bar!

    Good news, it seems the latest update has fixed the unsightly fuzzy/blurry/pixellated scroll bar! Before you had to resize the iTunes window to get it to return to its sleek smooth appearance but since installing the update this morning my Coverflow is beautiful again!
    Some people had mentioned this might be something to do with the graphics driver/card in the MacBook as this problem was not occurring on MacBook Pro's or iMac's etc...
    Hopefully everyone else is seeing the same?

    While I'm waiting a bit before I get an iPhone, I did want to get 7.3 installed. And when I did, my Cover Art also began to disappear, and those disappearing were definitely non-iTunes purchased tracks. Moreover, I could not re-paste Album Covers back into those same tracks. So 7.3 does have a bug regarding Cover Art.
    As an aside and since Cover Flow, for me, will be an important aesthetic to enjoying iTunes on an iPhone, I will not get an iPhone until 7.3 is sorted out. ...I don't want to hassle with my iTunes Cover Art and an iPhone through some software updates. So, I prefer to wait until this software bug is eliminated. (I hope Apple is aware of this bug, by now.)
    I was able to revert back to iTunes 7.2 (from a backup) and all my Cover Art was reintroduced back into my viewing of the non-iTunes purchased tracks. So, 7.3 does not delete those Album covers, but for some reason will not show or allow paste. Once reversion back to 7.2 was completed, my iTunes Cover Flow was just as it had been prior to installing 7.3.
    I'm now looking for 7.3.x.
    PB 17 1.33GHz   Mac OS X (10.4.10)   1GB Ram

  • The right side scroll bar on firefox no longer has an up and down arrow after my last update. I have to fix this! Please help!

    After my last update with Firefox, my right-hand scroll bar no longer has up and down arrows. I really need to get them back. I'm using a Mac laptop.

    So the whole button is missing. I have no idea how to fix the default theme, since it is inside omni.ja, which is not accessible from just any archive handler, and I have not found any way to open it. My problems were with third party themes, and I managed to fix those by editing parts of the themes.
    Maybe you could set up scrollbars yourself by using a userChrome.css file plus images. You could get some tips by opening third party themes and looking at their scrollbars.css files.
    * http://kb.mozillazine.org/UserChrome.css

  • Image Gallery & Scroll Bar

    Just exploring flash as a beginner, still.
    I've come across this website:
    http://www.jeremiahshoaf.com/
    I'm a fan of the scrolling portfolio idea the designer has used in the centre of the website's front page.
    Any ideas how this is produced?
    My presumption would be a MovieClip with images various other MovieClips inside (holding images etc) and then a scrollbar controlling how far across the screen the images are shown with actionscript?
    Knowing me I'm wrong, but any ideas would help me out to explore and learn further.
    Thanks for your great advice, as always.
    .. Also, I wondered if this could be produced, and as well as the scrollbar, the ability to add scrolling with the keyboard, left and right keys? Again, only a presumption, but I was thinking this might be simple with actionscript? Simply a piece of code to tell the scrollbar to move to the next MovieClip, if my initial presumption was correct.
    The above is only a small side note for those who feel they can assist - but thanks again for any help you can provide!
    This forum has been a huge help to me, in learning Flash so far.
    Thanks a lot.

    Well first you need a really long MovieClip with some graphics inside on it. That should be simple enough to do. Then you need a scrollbar. Just a rectangle should do for now. On this MovieClip give it a MOUSE_DOWN event listener and on that event use the "startDrag" function to add dragging functionality. Add a MOUSE_UP event listener to the stage and when that happens call "stopDrag" on the scroll bar clip. Then you can have an ENTER_FRAME event that actually updates the scrolling. On this event, check the scrollbar's x position and do some math to figure out the percentage you have scrolled. It might look like this:
    var percent:Number = scrollbar.x / (stage.width - scrollbar.width);
    Then update the main image container by the percent:
    var minPosition:Number = -500;
    bigImage.x = percent * minPosition;
    Hopefully that should be enough info to get you started.

  • How do I lock the scroll bar on, keeping valid HTML5?

    I have a site that was originally created in FrontPage some years ago, and I have now redone it using Muse (not before time, I hear you say!)
    There were several pages on the site where the content was not large enough to need to be scrolled on most displays, and some browsers removed the scroll bar from the right of the page when those pages were visited. This resulted in a shift to the right on those pages, which made all the fixed elements move on the screen when going between pages, which I found very annoying.
    I fixed it by adding this code to the pages in question -
    <style type="text/css">
    /* Force Right Scrollbar */
    html { overflow-y : scroll; }
    </style>
    This worked fine and locked the scroll bar on, and I wanted to do the same with the Muse version of the site.
    I have added the same code using the add HTML feature, and it still works fine.
    However, if I run any of the pages concerned through a validator, I get the error -
    Validation Output: 1 Error
    Line 23, Column 28: Element style is missing required attribute scoped.
         <style type="text/css">
    I tried to find out why this was, but all I found was a lot of standards documents which were mostly way over my head!
    So, is there any modification I can do to that code to get it through the validator, or do I need to look at a different method of locking the scroll bar on on my web pages?
    Thanks for any and all suggestions!
    Dave.

    Thanks very much jgrummel and Vikas.Sharma!
    Sorry for the delay in responding.
    I have now added "scoped="scoped"" to the code, and the validater (http://validator.w3.org) is now showing just a warning rather than an error.
    "Line 23, Column 44: The scoped attribute on the style element is not supported by browsers yet. It would probably be better to wait for implementations.
         <style type="text/css" scoped="scoped">"
    I'm not too worrid about that, as it is still passing it!
    The code is inserted on the master page of my site, so it presumably propagates through to all the pages, including those that don't need it, but this doesn't seem to cause any problem.
    The site is here - http://www.thedraculasociety.org.uk

  • Scroll Bars in Table Control

    Hi,
    How do I remove the vertical and horizontal scroll bars in the table control? I would like to use the Pg Up/Down buttons instead.
    Thanks,
    Mounika.

    Mounika,
    You can add or remove the scroll bar in the table control by switching off horizontal and vertical scrolling in the properties of the table control. The properties can be accessed from the screen painter by double clicking on the table control. Regarding the page up and page down functions, I believe you add those buttons in the screen layout and code for them. You can use the standard function code for the page up and page down functions.
    Regarding the Page up Page down...You need to add some extra code in your program to activvate that. Check the following program for example.
    DEMO_DYNPRO_TABCONT_LOOP_AT
    or try something like this
    try something like:
    CASE sy-ucomm.
    WHEN 'P+' OR
    'P++' OR
    'P-' OR
    'P--'
    CALL FUNCTION 'SCROLLING_IN_TABLE'
    EXPORTING
    entry_act = tc-top_line
    entry_to = tc-lines
    last_page_full = 'X'
    loops = loops
    ok_code = sy-ucomm
    overlapping = 'X'
    IMPORTING
    entry_new = tc-top_line
    EXCEPTIONS
    no_entry_or_page_act = 1
    no_entry_to = 2
    no_ok_code_or_page_go = 3
    OTHERS = 4
    ENDCASE   .
    Hope this helps
    Vinodh Balakrishnan

  • Remove vertical scroll bar from table control

    hi,
    i had used table control in my application. i want remove vertical scroll bar from table control.
    At initial time in table control there is no vertical scroll bar. In my table control lines are dependent on internal table which i was used to fill it.
    i was used these code for to set table control lines.
    DESCRIBE TABLE IT_RISK_ZINRISEXC LINES EXC_LINE.
    TC_RISK_EX-LINES =   EXC_LINE .
    Initially there is no data in internal table so there is no vertical scroll bar. After getting value i am filling internal table. and there is scroll bar in my table control. but i does not want that.
    i was not selected RESIZING-VERTICAL OR -HORIZONTAL.

    Hi,
    From Scroll Bars in Table Control
    You can remove the scroll bar in the table control by switching off horizontal and vertical scrolling in the properties of the table control. The properties can be accessed from the screen painter by double clicking on the table control. Regarding the page up and page down functions, I believe you add those buttons in the screen layout and code for them. You can use the standard function code for the page up and page down functions.
    or
    You can get rid of the vertical scroll bars by not setting table control lines. This way the user can only see the visible lines of the table control. As for the horizontal scrollbar, just make sure that your table control doesn't contain too many fields.
    Regards,
    Raj.

  • [SOLVED] Giving Firefox an infinite vertical scroll bar

    I recently reinstalled Arch after having a really difficult time with the move of binaries to /usr/bin
    There's one nagging issue after reinstalling, and I can't seem to find anything about it here. In Firefox, the vertical scrollbar on the right hand side of the screen doesn't meet the edge of the screen like it did before. What I mean is that I have to back up my cursor a pixel or two from the edge of the screen to hit the scroll bar. This behavior is frustrating, because it's so much easier to be able to just throw your cursor to the edge and click.
    I thought that this behavior might be controlled by GTK2 theme, but I haven't been able to find any themes that behave this way. Does anybody have an idea of what's going on here? My window manager is Openbox.
    Last edited by fatjake (2013-06-18 01:19:33)

    I was able to resolve this issue by switching Firefox to the "Littlefox complete theme". Thanks dag!
    https://addons.mozilla.org/en-US/firefo … or-firefox
    So this problem seems to have something to do with the default Firefox theme. This whole issue is one of those things that many people might not outright notice, but once you're aware of it drives you mad. Such a little thing but such a huge effect on usability. Here's another discussion about it if anybody finds it interesting
    https://bugs.launchpad.net/ubuntu/+sour … bug/125734
    Marked as resolved

  • Focus vertical scroll bar in report div

    Hi everyone,
    I just want to know if the issue has been resolved by someone :
    I have a report within a div and a vertical scrolling bar to scroll the rows. When I click on a row of the report the row is highlighted. Now, if the clicked row is at the end of the report, the scrolling bar goes up, and the user has to scroll down to see the selected row. So how to focus this scrolling bar once the user clicks on the row ?
    I guess I have to compute the id of the selected row times the row height and send this value to the css parameter of the scroll bar (but AFAIK there's no such parameter in css for positioning a scroll bar) ... Someone has came up with a solution ?
    Best regards,
    Othman.

    Thanks a lot Andy,
    I didnt' know about the scrollTop attribute. So for those how are interested : Each time I click on a row, I store the scrollTop position in a Hidden field. On each body onload, I call a javascript function to position the scroll bar of the div like this :
    getElementById.("mydiv").scollTop = html_GetElement('P1_SCROLL_ID').value;
    Regards,
    Othman

Maybe you are looking for

  • DSN connection not available in connection manager

    Hi -- I am having problems connecting to an ODBC data source with SSIS. I am trying to connect to a mysql database.  The connection is set up in "Administrative Tools" as a System DSN, and I can sucessfully connect using "Test" from there. But the co

  • How do I create a DVD of photos from I photo

    HI, I have an OS X 10.4.11 and am trying to move over 700 photos to burn on a DVD. This is all really new to me so I will write what I have been doing and hopefully someone will steer me in the right direction. Went to Finder clicked on file and made

  • Rich text editor Issues in Experience Manager

    Hi,      We are extensively using rich text cartridges for most static pages. We usually copy entire html content into the rich text cartridge source. It was seen that after saving the content, the editor formats the HTML tags. For example: <a href="

  • Java 1.4 Logging API

    I am having some problem with the Formatter. I have a ConsoleHandler. I set its formatter to my custom formatter. My custom formatter simply extends Formatter class and implement formate(LogRecord) method. when I run my program, the ConsoleHandler no

  • How to move or migrate whole directories between ASM disk groups?

    Hello everyone! I'm playing around with Oracle ASM and Oracle Database (11g R1), I'm a student. This is just for testing purposes. Computer specifications are: Processor: Intel Pentium 4 HT 3.00 Ghz. RAM Memory: 2 GB. Hard Disk: 250 GB O.S.: Windows