Frame need's Scroll Bars

I need some help. I have created a JFrame using a GridBoxLayout, but they problem I have encountered is that when the frame is too small for the content it overlaps. This is not a problem for the width since I am setting the size of the screen unResizable. But when the content grows to long for the height of the frame all the JLabels, JTextFields and etc. overlap. What I would like is when there is too much content for the screen that a Scroll Bar appears on the right side of the screen and the content of the screen remains the same, and to see the content below all I have to do is scroll down. Much like a text area or I guess the same a web page. The only way I know how to add a scroll bar is to a text area. I would like to be able to add a scroll bar to a frame, container or panel.
Derek

1) What is a GridBoxLayout?!
2) The solution to your problems - set the content pane to a JScrollPane, set the viewport to a JPanel with your layout (whatever it is) and add your components to the panel.
3) If you want to add scroll bars to anything, use a JScrollPane. See the API documentation for details.
Stephen

Similar Messages

  • Drag JTabbedPane out of the main Frame and set scroll bars for the tabs

    hi ,
    Iam working on a Swing application . In it i have Six Tabs added to a single JTabbedPane. all the tabs are different class files . is it possible to drag any of the tabs out of the frame.
    how to add scroll bars for the tabs individually. i have tried adding JScrollPane to the main frame and add the JTabbedPane to the Scrollpane . the scroll bar was not visible and i have tried adding
    all the six tabs to the individual JScrollPanes and add the six scrollpanes to the TabbedPane .
    only the scroll arrows are visible , when i minimised or resized the application the scrollbars were not appearing .
    could any one help me to solve the above two problems.

    just trying.....
    public void mouseDragged(MouseMotionEvent e){
    // this event should be activated only when the Drag goes out of scope of the parent JFrame which i dont know how
    Component c=JTab.getComponentAt(JTab.getSelectedIndex());
    JFrameobj.getContentPane().add(c,"Center");
    }

  • How come I need a scroll bar?

    I just updated my Firefox and now I have to use scroll bars to see the whole page. I'd like to see everything without them. I've tried adjusting the zoom and searched for other settings...I don't have this problem with IE...

    There is a solution on livedocs for auto-scrolling in response to a focus change in the application:
    http://livedocs.adobe.com/flex/3/html/help.html?content=accessible_6.html
    Relying on the browser for scrolling will severely constrain the design of your application.

  • 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.

  • Remove/Hide scroll bars in scroll panes.

    Hi all,
    I am pretty new to action script. I am building a photo gallery and I am loading the thumbnails from an XML file into a scroll pane dynamically. As the scroll pane fills up, it gets wider to accomodate the thumbnails. There is one row, and eventually, I want to have the user be able to mouse left or right and have the scroll pane scroll, versus clicking on the bar or the left/right arrows. However, in order to accomplish this, I need the scroll bars to disappear!
    Is there anyway to either remove or hide both the x and y scroll bars on a scroll pane? My scroll pane is called: thumbPane.
    Thanks in advance!
    -Rob

    Hello friend,
                       first select scrollpane.Then open parameters panel (if dont know go to window > properties > paramiters ) turn to OFF HorizontalScrollPolicy  and verticalScrollPoliy then left and right scroll Bar will not display.
    THANKS.

  • Unable to set  size and scroll bar to table components in visual web jsf

    Hi Friends,
    Good day all of you,
    my requirement is to display multible tables in the same jsp page with same size.
    if some tables have more columns than other tables then that table need horizontal scroll bar...

    Hi BalusC,
    Good day,
    we didn't use any CSS sheets.is there any other way to set.

  • Removing Scroll Bar from JPanel..emergency

    Can any one tell me please, that i wan that
    when i hav 6 or greater than 6 components in my panel then there appear Scoll bar
    else if i hav less than 6 componets then there is no need of Scroll bar..
    Any help will be Appreciated..

    Scroll bars appear when the space required to display the components is greater the space available to display the components. It has nothing to do with the number of components. So yes you could count the number of components a display a scroll bar, but it would do nothing, so your requirement doesn't make any sense. You need to clarify your question.

  • Vertical scroll bar on tab page.

    Hello,
    I have to show vertical scrollbar on my tab canvas.
    I have one Content canvas on which I have 1 tab canvas with 8 tab pages.(sec1,sec2,sec3 ..sec8)
    I have another tab canvas(kind of seb section for the above and each has 3 tab pages) like
    Sec1 will have (sub sectiion tab canvas) which has again 3 tab pages 1.1,1.2,1.3 and soon
    now on the third tab page of the sub section or second tab canvas, I need vertical scroll bar to fit number of fields which are more than the tab canvas size.
    all are from the same data block
    Could you please help me. i tried by creating staked canvas but no luck.
    can you please let me know the procedure to be followed
    Thank you in advance.

    Could you please help me. i tried by creating staked canvas but no luck.What happened when you tried to use a stacked canvas?
    If the items in the area you want to scroll are all in the same datablock you can set the Scrollbar properties of the block to be displayed. This will enable scrolling of the items that are within the specific block. If you items are assembled from more than block, then using a stacked canvas is a better option for enabling scrolling within an area.
    Also, what is your Forms version?
    Craig...

  • Scroll bar display in report

    Hi
    I want to set scroll bar in my report ..my column names should be fixed header...I surely need vertical scroll bar than horizontal scroll bar...I used the following javascript code to display scroll bar.
    <script language="JavaScript" type="text/javascript">
    <!-- Hide
    //Function Builds Static Header and Scrollable Div called with document onload
    function MakeStaticHeader(xDataGridName,xScrollHeight){
    //Grab the Table object
    var theTable = document.getElementById(xDataGridName);
    //Create a holder div so div header can be added correctly before table
    var myHolderDiv = document.createElement("div");
    myHolderDiv.setAttribute('id','tableHolder_'+ xDataGridName)
    //Create the Header Div, setting id and adding to Holder
    var myHeaderDiv = document.createElement("div");
    myHeaderDiv.setAttribute('id','divHeader_' + xDataGridName)
    myHolderDiv.appendChild(myHeaderDiv);
    //Insert the Holder and Header divs
    theTable.parentNode.insertBefore(myHolderDiv,theTable);
    //Append the Child
    myHolderDiv.appendChild(theTable)
    //More messy code with IE
    if(document.all){
    theName = "hold2_" + xDataGridName;
    else{
    theName = xDataGridName;
    //Create Body Div for scrollable body (IE creates a holder, mozilla creates the scroller)
    var theBodyDiv = document.createElement("div");
    theBodyDiv.setAttribute('id','divBody_' + theName);
    theBodyDiv.setAttribute('style','OVERFLOW-Y: scroll; OVERFLOW-X: auto; OVERFLOW: auto; HEIGHT: ' + xScrollHeight + ';')
    theTable.parentNode.insertBefore(theBodyDiv,theTable);
    theBodyDiv.appendChild(theTable);
    //Since IE can not apply the style to the new Child above, we need to make it messy! (IE is making this hard!)
    //Converts the holder to a scroller
    if(document.all){
    var theMessDiv = document.getElementById('divBody_' + theName);
    startDiv1 = '<div id="divBody_'+ xDataGridName +'" style="OVERFLOW-Y: scroll; OVERFLOW-X: auto; OVERFLOW: auto; HEIGHT: '+ xScrollHeight +';">';
    endDiv1 = '</div>';
    theMessDiv.innerHTML = startDiv1 + theMessDiv.innerHTML + endDiv1;
    //The following Code Builds the header
    theTable = document.getElementById(xDataGridName); // Arie
    //Grab border widths (have to check for different ways to define it!)
    var borderWidth = parseInt(theTable.style.borderwidth);
    if(!borderWidth){
    borderWidth = parseInt(theTable.border); }
    if(!borderWidth){
    borderWidth = parseInt(0); }
    //Grab the table Headers (if exsists)
         var theThs = theTable.getElementsByTagName("th");
         var hasThs = parseInt(theThs.length);
         var hasHeadCells = false;
         //See if the Table Headers exist
         if(hasThs>0){
         hasHeadCells = true;
    //Grab the table rows
         var theTrs = theTable.getElementsByTagName("tr");
    //Find the number of columns
    var theTrsTds = theTrs[1].getElementsByTagName("td");
         var numberOfColumns = parseInt(theTrsTds.length);
    //Grab all of the table cells
    var theTds = theTable.getElementsByTagName("td");
    //Determine the widths of the columns of the table
    var totalWidth = 0;
    var theWidths = new Array();
    for(i=0;i<numberOfColumns;i++){
              if(hasHeadCells){
              theWidths[i] = theThs.offsetWidth;
              else{
    theWidths[i] = theTds[i].offsetWidth;
              theTds[i+numberOfColumns].style.width = theWidths[i];
    totalWidth += parseInt(theWidths[i]);
    //Set the width of the div so the scroll bar is on the edge of the table
    document.getElementById("divBody_" + xDataGridName).style.width = document.getElementById("divBody_" + theName).offsetWidth;
    //Grab the content for the headers
    theHeaderCode = theTrs[0].innerHTML;
    //This is for IE only since it does not support getComputedStyle which is alot easier!
    var theStyle = "";
    if(document.getElementById("divBody_" + xDataGridName).currentStyle){
    //Grab the innerHTML and locate the style
    theX = document.getElementById("divBody_" + xDataGridName).innerHTML;
    theX = theX.split("style");
    //Verify that there is a style tag in the table tag
    if(theX[0].indexOf(xDataGridName) >= 0 && theX[1].indexOf("<TBODY>") >=0){
    //split aprt to get the style
    theQ = theX[1].split('"');
    //set the style string
    theStyle= "style='" + theQ[1] + "'";
    //Create the table code and set it on the document
    tbCode = "<table id='theAddon_"+ xDataGridName +"' "+ theStyle +">" + theHeaderCode + "</table>";
    document.getElementById("divHeader_" + xDataGridName).innerHTML = tbCode;
    //Apply the CSS Class and the Widths to the header Elements
         if(hasThs > 0){lookFor = "th";}
         else{lookFor = "td";}
    theNewTD = document.getElementById("divHeader_" + xDataGridName).getElementsByTagName(lookFor);
    for(i=0;i<theNewTD.length;i++){
    theNewTD[i].style.width = theWidths[i];
    /* Arie Workaround - English version*/
    //theNewTD[i].style.borderStyle = "solid none solid solid";
    //theNewTD[i].style.borderWidth = "1px";
    //Apply CSS to the static table
    theOrgTable = document.getElementById(xDataGridName);
    theNewTable = document.getElementById("theAddon_" + xDataGridName);
         for(x=0;x<theOrgTable.attributes.length;x++){
         if(theOrgTable.attributes[x].nodeValue && theOrgTable.attributes[x].nodeName.toLowerCase() != "id"){
         theNewTable.setAttribute(theOrgTable.attributes[x].nodeName,theOrgTable.attributes[x].nodeValue);
    // Calculate the scrollbar width and streach the last header cell
    var scrollbarWidth = document.getElementById("divHeader_" + xDataGridName).offsetWidth - document.getElementById("theAddon_" + xDataGridName).offsetWidth
    var lastHeaderCell = theNewTD.length - 1;
    theNewTD[lastHeaderCell].style.width = theWidths[lastHeaderCell] + scrollbarWidth;
    theNewTD[lastHeaderCell].style.borderStyleLeft = "solid";
    theNewTD[lastHeaderCell].style.borderWidthLeft = "1px";
    //Hide the orginal header row
         theTrs[0].style.display = "none";
    //Make mozilla browsers see the applied styles
    makeSame(theOrgTable,theNewTable)
    //Function to make Mozilla have the same inline styles
    function makeSame(elem_1, elem_2){
    if (window.getComputedStyle){
    elem_1x=window.getComputedStyle(elem_1, "");
    elem_2x=window.getComputedStyle(elem_2, "");
    elem_2x = elem_1x;
    // End Hide -->
    </script>
    I called the script code in onload event like
    onload="MakeStaticHeader('table_grab',50)"
    but my problem is that it is not displaying the data in proper format(not displaying data under correct columns)...i got this problem only when I have more columns(horizontally large)..I am not finding any problem if i have less columns with much data(vertically large)....
    I gave a sample report in the following link...
    http://apex.oracle.com/pls/otn/f?p=9608:1:409755984054854:::::
    Can anyone say how to set vertical scroll bar with fixed column headers in neat format even the number of columns are more...?
    Fazila

    Hello,
    This is a well-known issue with this code, as you can see in the thread you copied the code from.
    In the following post, Laura is presenting an IE only solution, based on a different code I wrote - Re: How to implement fixed column headers . Cross browser solution is yet to be found.
    Regards,
    Arie.

  • Scroll bar in Content Viewer

    Hello everyone,
    I have place three different height images into a frame and applied scroll bar using Content viewer. I am calling each image through a button.
    My question is:
    Can we control the scroll bar height limiation as per the image's height. Right now its taking the largest image's height as a reference, when i click and check the small height image, i see lot of white space in it.
    Thank you very much.
    Regards,
    Shiva

    What do you mean you added a scroll bar? Do you mean a scrolling frame?
    If so, no, you cannot adjust the size of that dynamically. That said, I still don't totally get what you're doing.
    You can't click to move content in a scrolling frame, only an MSO.
    Bob

  • Scroll bars on a tab canvas

    Hi
    when I run my forms the scroll bar on the tab canvas is disabled. How can enable it?

    hi
    Scroll bar will be enable once the no of records in the block increases , when u have one or two records the need of scroll bar is unnecessary so it is disabled.
    u try adding few records to the block and check for the scroll bar.....

  • Scroll Bar arrows Gone?

    The verical scoll bar arrows are no longer there on OS X 10.7.
    Any way in System prefs or Safari prefs to get them back?

    Installed Lion today. Started testing out applications and I miss and still need the scroll bar arrows.
    I use several applications where the arrows on the scroll bar allow small movement as one line, especially important when copying several different sections of several paragraphs in Word, picking and choosing file movement in Spring Cleaning, or seeing just how far your object is off the printable field in Visio.
    I do love the touch functions of my iPhone but this will just not work on a desktop workstation.
    Does someone know if Apple will look at these comments with some interest in keeping those of us that have used Apple hardware since the Apple II happy?
    Well for now, I'm just moving back to Snow Leopard. So much for progress.

  • Has anyone downloaded Yosemite and found that there are no ore scroll bars? I have to move the window (of any window, Skype window, browser window etc.) in order to find the scroll bar and then it disappears so fast I can't even use it.

    Has anyone downloaded Yosemite and found that there are no ore scroll bars? I have to move the window (of any window, Skype window, browser window etc.) in order to find the scroll bar and then it disappears so fast I can't even use it.

    Not sure why that was unchecked but good to know!
    Apple's new default (since at least a couple of OS releases back) is to have it off so OS X matches the behavior of an iPhone or iPad.
    I almost never need a scroll bar, and when I do, I just move over to the edge of the window when scrolling and a larger scroll bar appears.
    Yes, for the most part, users don't really need the scroll bar. That's what the scroll wheel on almost all mice is for. Saves the trip over to bar to physically grab and move it. But, I do like it on all the time regardless. That way (especially with a long article) I can just take a quick glance over to the bar to see about where I am on the page (a third of the way down? halfway?). Otherwise, I have to move the page just to make it appear to give me the same information.

  • Adding a scroll bar

    Hello
    I have designed this website for my client... http://www.applebybowers.com/for_web/
    They wish to add a vertical scroll bar to the middle where the majority of text is so that more text can be added if necessary without the res of the page disappearing out of view on smaller monitors.
    Can anyone advise the best way to go about this.
    Thanks

    I'm not crazy about it either, but sometimes the client just won't change their mind no matter how much you try to persuade them!
    It's actually only on one page that I need the scroll bar - http://www.applebybowers.com/for_web/news.html
    The client would like a scroll bar here so that all of the news articles can be viewed on one page without the rest of the page disappearing off the monitor.
    I read Bob's advice but now that I've come to have a go at adding the code I'm not sure where to add it. Also, do I need to add a div inside the table cell, and if so how do I do that? I've looked on a few forums and found similar bits of code to use but haven't got a clue where to include it...
    <div style="overflow: auto; height: 100px; width: 200px;">Put your text or images or anything in here.</div>
    Would someone please have a look at my code and advise me on what I need to do.
    Thanks.

  • The scroll bar does not show in my SaaS application.

    I have a spreadsheet application and the scroll bar does not show on FF4. I need the scroll bar to navigate the app.

    table is surround by panelStretchLayOut but I examine this and has no difference.
    scrollBar show for data under one milion records!!
    and here is my code:
    <af:popup id="t1DataPopup"
    binding="#{B1Bean.t1DataPopup}">
    <af:dialog id="d9"
    type="ok"
    affirmativeTextAndAccessKey="#{viewcontrollerBundle.okLabel}"
    title="#{bindings.R1.hints.label} : #{bindings.R1.inputValue}"
    inlineStyle="position: absolute; left: -410px; top: -200px;">
    <af:panelStretchLayout id="psl4" topHeight="30px"
    inlineStyle="width:800px; height:400.0px;">
    <f:facet name="bottom"/>
    <f:facet name="center">
    <af:table value="#{bindings.s1Graph.collectionModel}"
    var="row"
    rows="#{bindings.s1Graph.rangeSize}"
    emptyText="#{bindings.s1Graph.viewable ? viewcontrollerBundle.noDataToDisplayMessage : viewcontrollerBundle.accessDeniedMessage}"
    fetchSize="#{bindings.s1Graph.rangeSize}"
    rowBandingInterval="0"
    filterModel="#{bindings.s1GraphQuery.queryDescriptor}"
    queryListener="#{bindings.s1GraphQuery.processQuery}"
    filterVisible="true" varStatus="vs"
    selectedRowKeys="#{bindings.s1Graph.collectionModel.selectedRow}"
    rowSelection="single" id="t1"
    partialTriggers="::s1Graph ::s1BarGraph ::s1HoriBarGraph ::s1AreaGraph"
    autoHeightRows="-1">
    <af:column sortProperty="T1Stmp"
    filterable="true" sortable="true"
    headerText="#{bindings.s1Graph.hints.T1Stmp.label}"
    id="c94" align="center">
    <af:outputText value="#{row.T1Stmp}"
    id="ot139"/>
    </af:column>
    </af:table>
    </f:facet>
    <f:facet name="start"/>
    <f:facet name="end"/>
    <f:facet name="top">
    <af:panelGroupLayout id="pgl20">
    <af:commandButton text="#{viewcontrollerBundle.saveAsExcelCommandButtonLabel}"
    icon="/Images/excel.gif"
    id="cb9">
    <af:exportCollectionActionListener exportedId="t1"
    type="excelHTML"
    title="T1Data"/>
    </af:commandButton>
    </af:panelGroupLayout>
    </f:facet>
    </af:panelStretchLayout>
    </af:dialog>
    </af:popup>
    and fetchsize=25
    Edited by: Mansoor on Jul 17, 2012 8:28 AM

Maybe you are looking for