How can I put a scroll bar on a frame?

Hello,
I have a class that extends JFrame, and I need the Frame have a scroll bar. How can I do so?

JFrame frame = new JFrame() ;
JScrollPane scrollpane = new JScrollPane() ;
JPanel panel=new JPanel();
JLabel label=new JLabel("Hello!");
label.setPreferredSize(new Dimension(2000,2000));
panel.add(label);
scrollpane.add(panel);
frame.setContentPane(scrollpane);
Does that work for you?
PS:scroll bar as needed is the default setting, so you don't actually need them. And yeah, your panel must be big enough to let the scroll bars show themselves.

Similar Messages

  • How do i put a scroll bar on a  JEditorPane ?

    How do i put a scroll bar on a JEditorPane ?
    Can somebody point me to some sample
    code that works?
    thanks in advance
    Owen

    You should use a JScrollPane and add the JEditorPane to it...

  • How can I hide the scroll bar in TextArea?

    How can I hide the scroll bar in TextArea?

    Hi. To remove the horizontal scrollbar you can do this:
    textArea.setWrapText(true);
    To remove the vertical scrollbar you can do this:
    ScrollBar scrollBarv = (ScrollBar)ta.lookup(".scroll-bar:vertical");
    scrollBarv.setDisable(true);  and set the opacity to 0 in the css file:
    //css file
    .text-area .scroll-bar:vertical:disabled {
        -fx-opacity: 0;
    }Here is an example:
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ContextMenu;
    import javafx.scene.control.MenuItem;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.control.TextArea;
    import javafx.scene.input.ContextMenuEvent;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    public class TextAreaSample extends Application {
        @Override
        public void start(Stage primaryStage) {
        final TextArea textArea = new TextArea();
            textArea.setWrapText(true);
            StackPane root = new StackPane();
            root.getChildren().add(textArea);
            Scene scene = new Scene(root, 300, 250);
            primaryStage.setScene(scene);
            primaryStage.show();
            scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
            ScrollBar scrollBarv = (ScrollBar)textArea.lookup(".scroll-bar:vertical");
            scrollBarv.setDisable(true);
        public static void main(String[] args) {
            launch(args);
    }

  • How can I hide horizontal scroll bar?

    Some websites use CSS code (overflow-x: hidden or overflow-y:hidden), that shows the horizontal scroll bar while the frame on the website is centered and only 800 pixels wide, but I really don't need my horizontal scroll bar to show up. So how can I hide it?
    Thanks!

    If you use <b>overflow: hidden</b> then you shouldn't see a scroll bar (overflow:scroll does that).<br />
    If that doesn't work then try to add the !important; or use the code in Stylish or to userContent.css in the chrome folder.
    *http://kb.mozillazine.org/userContent.css
    *https://developer.mozilla.org/en/CSS/@-moz-document

  • How can I get the scroll bar to go to the top or bottom of the page with a right click command?

    When I right click on the scroll bar nothing happens. I have to spin the mouse wheel repeatedly to get to the top or bottom of the page. I just switched from explorer. I'm used to being able to do this. It's much less time consuming and frustrating. I hope someone can help. Thanks.

    You can hold down the Shift key and left-click the scroll bar to go to that position.
    If you set the Boolean pref <b>middlemouse.scrollbarPosition</b> to "<i>true</i>" (default on Linux) on the <b>about:config</b> page then you can middle-click the scroll bar to go to that position.
    *http://kb.mozillazine.org/middlemouse.scrollbarPosition
    *http://kb.mozillazine.org/ui.scrollToClick

  • How can I get extra scroll bars in Firefox to read Yahoo mail on a small screen, the way Explorer has?

    When I read my Yahoo emails on my little Asus eee pc, I have to use Explorer because it has extra scroll bars that allow me to scroll back and forth to see things that there is no room for on the screen. Firefox doesn't have these scroll bars.

    Hi ncleeno,
    I understand that on a small screen you would like to know how to add scrollbars to the page so that you can read parts of the email that are not on the screen.
    I have not tried this myself, but I think in about:config: In order to change your Firefox Configuration please do the following steps :
    # In the [[Location bar autocomplete|Location bar]], type '''about:config''' and press '''Enter'''. The about:config "''This might void your warranty!''" warning page may appear.
    # Click '''I'll be careful, I promise!''' to continue to the about:config page.
    # Search for scrollbar and I believe layout.testing.overlay-scrollbars.always-visible set to true would put these on.
    dom. disable_window_open_feature.scrollbars is the one that is set to false by default as well that prevents the scrollbars on a popup from being disabled. i am not sure if viewing Yahoo mail is a popup. I do not use it, but I will assume its not.
    Did this help?

  • How can we remove the scroll bars from the table?

    Hi,
    I have a dynamic table. Currently the table appears with the scroll bars. But there is a requirement that the scroll bar should not appear and the table should stretch in the entire page. How can this be achieved.
    Thanks in advance
    Nita

    Thanks Mohammad for the reply.
    Was able to remove the scroll bars by using only the styleClass as AFStretchWidth. But there is a default partition in middle of the page still? Can i remove that too by any way.

  • How can I retrieve the scroll bar in Home applications using OS 10.6.8?  I don't have a general section after clicking on System Preferences.  Thanks.

    I have deleted the scroll bar twice in 4 years and I still don't know how to set it back.  Please help.

    hi Samberl
    thanks a lot for the fast reply.
    I was dragging folders from main folders on the laptop-desktop  onto the external drive icon - to copy them across....
    Your suggestion sounds very promising -  I didn't know about 'cloning'.
    Yes the idea is to backup the laptop -    I thought I would just move it all now, new - and then keep saving/dragging physically   across to the new drive myself each day or two...
    Would this be the sizeof the internal hard drive = c.500 gb  ?   =   under the HD icon on desktop is written  : 
    " 499.76gb , 311.5 gb free  " 
    I can erase and start agin on the new external drive - so this plan is to make two partititions, rather than the one at present, and make one of them 500 gb ?
    I have found CCC [carbon copy cloner] googling - looks good.
    When CCC site says it backs up  the hard drive - would this  mean all my files  [over 100 gb] that are mostly  in folders on the desktop, plus the others in itunes, iphotos etc found in the HD icon,  would all copy across successfully [wherever they are in the computer ]  ?
    thanks again, hope you can clarify these things and then I will go for it. 
    It would be great and amazing if this 'lack of permission' message doesn't show up in the process of doing this ccc transfer - hopeful!
    Julie

  • How can I get the scroll bars to be more visible/contrasting?

    The scroll bars are difficult for me to differentiate from their background. Can I change their colour or darkness to make them more visible?

    Firefox uses the native scroll bars by default.<br />
    You can try to select another window theme in your Linux distribution that has better scroll bar appearance or see if installing a Firefox theme helps.
    * https://support.mozilla.org/kb/Using+themes+with+Firefox
    *https://addons.mozilla.org/firefox/themes/

  • How can I get a scroll bar at the bottom of the page so I can see the right side of the page when I am using two windows?

    With two or three pages open, I have scroll bars that allow me to see the right side of the other pages, but not on the Firefox page.

    Thank you for the reply, Fred, but when I went to my saved screenshot, I realized that the shortcut on my desktop had opened in IE, not Firefox. There is no scroll bar and the directional arrows do not work. My daughter has been playing with my laptop again. When I set up the same conditions with Firefox, there is no scroll bar, but the arrows function properly, so I can read to the right edge of the page. Now to find someone who knows IE11. Thanks again, for your reply.

  • Can i put the scroll bar on the left hand side of the page

    i am left handed and using a touchscreen asus and would like to get the scroll bar on the left

    Hi!
    Yes, you can!
    # Type "about:config" (without quotations) in the urlbar and hit Enter
    # Search for "layout.scrollbar.side" (without quotations) variable
    # Double click on that
    # Modify the value to "3" (without quotations)
    # Click Ok
    # Restart Firefox

  • How can I put back the bar that held my go-to site icons?

    I am referring to the bar that has the site address, and Google box. In the past, I placed a lot of icons on that bar, that I got from my bank, utility sites for bills, mail, facebook, etc. It was a great convenience. The bar had a plus sign, to add more icons. A window would appear, that allowed you to choose an icon and enter the site address. A lot of the sites had their own icons, that would automatically appear, in the window. Now, I tried to follow the directions to add icons to the bar, but it looks like there are very few available, and hardly any that I use. I'm hoping that there is a way that can be used to add back the bar's abilities to place very useful icons, that were so easy to use. I'm sure many people are upset also. It's a mystery how anyone could think that the new features would be better than the old, at least for this one bar's usefulness. Thanks, in advance, for your help.

    # Right-click an empty area of the tab bar and choose Customize.
    # Click the Show / Hide Toolbars button near the bottom and make sure "Bookmarks Toolbar" is checked.
    # Make sure the "Bookmarks Toolbar Items" element is on the Bookmarks Toolbar (the bar below the navigation toolbar, which is the part with the address bar and the search box).
    # Click the Exit Customize button near the bottom right when done.
    # When you want to bookmark the current page, drag the icon on the left side of the address bar (usually a globe or a padlock) onto the Bookmarks Toolbar.
    [[Bookmarks Toolbar - Display your favorite websites at the top of the Firefox window]]

  • On a Parallax Scrolling Page, How can I start the scroll bar at the bottom on page load?

    Hello,
    I'm working on a parallax scrolling animated page in Edge Animate, and it's a timeline of life on Earth. But we wanted to start from the bottom, or "Origin of Life" and then scroll up while our 'tree of life' animates in as the user scrolls up. We definitely know it's not good web etiquette to start at the bottom, but our client is determined. I am more of an animator than a web designer, but I was wondering how one might do this using a bit of code? We are using EC.Parallax.setup(sym); from Edgecommons for the parallax function, which is basically just tying the timeline animations to the scrollbar. I've already got the animations setup to go the right way  but we don't want visitors to have to scroll to the bottom first, as they'll then see everything animated in reverse! In my google searches I found something called an Iframe that you can use, and then a flurry of responses on how horrible Iframe is. Thanks for your help, we really appreciate it!

    Hi, Vizkid-
    You can find the height of the document and then use window.scroll in your initialization function to default your scrollbar to the bottom of the page.
    http://stackoverflow.com/questions/1145850/how-to-get-height-of-entire-document-with-javas cript
    Hope that helps,
    -Elaine

  • How can i get the footer bar to stay, whilst page scrolls?

    how can i get the footer bar to stay, whilst page scrolls?
    at the moment, on my site, if the page is longer than the screen, it goes behind the footer,
    but the foot bar moves up the page as yo scroll down to see the rest of the content.
    any way of getting the footer to stay put, while body/page contant scrolls ?
    thanks

    You can use some css to do it...
    #footer_id {
         position:fixed;
         bottom:0px;
    <div id="footer_id">Your footer content</div>
    The css above will lock your footer to the bottome of the browser window. As long as your footer <div> is last in your html, it will float over the top of everything on your page when the page is scrolled. If it's not last in the html, you'll need to add a z-index to get it on top of your other content in the stack.

  • On Firefox 4, how can I put one "new tab" on the "tab bar" (The + sign) and one next to the "back/forward" buttons (as in FF 3.6)?

    On Firefox 4, how can I put one "new tab" on the "tab bar" (The + sign) and one next to the "back/forward" buttons (as in FF 3.6)?
    In my current Firefox, the "new tab" icon/item from the "customize" pop-up window menu of items is placed next to my home, back, forward buttons near the top-left of my header (Button 1 for "new tab"). Then, the tab bar automatically come with a small tab (with a + sign) to the right of your last tab opened (so you click on + and a new tab opens. Button 2 for "new tab"). I like to have this "new tab" button twice (as a + mini tab, and next to my "home icon".
    When I upgraded to Firefox 4, I seemed to be only able to "customize" or use the "new tab" in one place. Either as an icon next to home button, or as a "+ minitab", but NOT both.
    What can I do to put this button in Firefox 4 on BOTH places???
    Your help is really appreciated. I want to upgrade, but I want my buttons on both places...
    I upgraded to FF 4, but downgraded again just because this feature... that's just me of coarse :-)

    *New tab toolbar button: https://addons.mozilla.org/firefox/addon/new-tab-toolbar-button/

Maybe you are looking for

  • How do I get rid of audio pops and clicks between clips in Final Cut Pro X?

    Is there a layman, non-professional way to do this? These are just video files... i don't know anything about formats of different files and all that, but i read in other posts that the files should be "uncompressed 48k something something", but i do

  • Installing Oracle 8i and Developer 6.0 technet packages on NT

    I recently purchased the Oracle 8i (8.1.6) and Developer 6.0 "packages" from technet ($200/each). The Oracle 8i Enterprise Server software installed without any problems [ Oracle home = ora81 ]. However, when I tried to install the Developer package

  • E-Mail in iOS 7.0.2 with massive problems sending big e-mails

    Dear all, i have massive problems in sending e-mails with attachments using iOS 7.0.2 on an iPhone 5s using iCloud E-Mail services. If i try to send more than one photo done with the iPhone, it is just sending and sending, but after an endless time n

  • Why can't I connect to my email when I push mail button on my device

    This morning when I checked my email I received an email from my email provider ( yahoo.com ) advising me to change my password because of some suspicious activity on my account. I proceeded to sign in & change my password & was successful ( so I tho

  • LSMW- Error :No target structure could be found.

    Hi All, In LSMW I'm using Business Object BUS1001006 and Method SAVEDATA. Which is working fine in Development system and Testing system. But the problem is in the production system. At the 4th step (Maintain Structure Relation )in LSMW  I'm getting