ScrollPanel & ScrollBar

Ok, im having a little difficulty setting up a scroll bar on a text area, tried to use the tutorial (but that is confusing me even more!).
I have a JPanel resultPanel, JTextArea result which is added to the resultPanel so my results are visible. All i want is a vertical scrollbar so i can see all the results as they pour in. When i implement the scrollPane and scrollbar classes, the scrollbar doesnt appear and the textarea messes up.
Anyone got a simple solution, to this simple prob.
Any help greatfully appreciated.
Thanks.

Hope this will help.
import javax.swing.*;
import java.awt.*;
public class TestApp extends JFrame{
        JTextArea textDisplay=new JTextArea(" HI !");  
        JScrollPane scrollDisplay=new JScrollPane();
        JPanel displayPanel=new JPanel();
        TestApp(){
            init();
        private void init(){
            setSize(400,300) ;
            setResizable(false);
            scrollDisplay.setPreferredSize(new Dimension(200,150));
            scrollDisplay.getViewport().add(textDisplay);           
            displayPanel.add(scrollDisplay);
            getContentPane().add(displayPanel);           
            show() ;
    public static void main(String args[]) {
        new TestApp();
}

Similar Messages

  • No scrollbars on scrollpanel

    hi!
    i have the following problem:
    within an applet i got a scrollpanel. on this scrollpanel i added another panel that is much larger than the scrollpanel and i also did put some strings on this new panel that are out of the visible area of the scrollpanel.
    but, no scrollbars appear on the scrollpanel and therefore i can't navigate to those strings that are not visible within the scrollpanel bounds.
    i read already a couple of possible "solutions" from other topics but none of them worked. what i tried was
    - set a layout (i. e. gridbaglayout) for the detail panel
    - call a doLayout function for the detail panel
    - detemine the preferredSize of the detail panel
    - using a ScrollPanel constructor with SCROLLBAR_ALWAYS (the scrollbars did appear then, but scrolling was impossible...)
    so if anyone has annother idea any help would be great
    thanx in advance

    call panel.setPreferredSize(new Dimension(1024, 1024).
    It should work.
    Angus
    Visual Paradigm for UML
    Full Feature UML CASE tool
    http://www.visual-paradigm.com/

  • Browser scrollbar and Flash scrollbar ? I need help!

    Now I have a problem about the scrollbar:
    The height of my swf file is longer than browser height, so
    the scrollbar of browser's occurred, if I scroll my mouse wheel,
    the whole flash roll down, but the problem is that I have used a
    scrollPanel component which write by myself, and in this situation,
    when I scroll the mouse wheel, the scrollbar in flash and browser
    will both in effect.
    The question is that how to disable the brower scrollbar when
    I scroll mouse wheel inside the scrollPanel component. In fact,
    adobe already done this, if my cursor inside a textfield object,
    the scrollbar of bowser will not get focus. How to achieve this
    effect? My english is bad, but I need help!

    i recently downloaded trails of flash cs4 and web premium package cs4 (took a day to download at high speed starbuck's internet). couldnt get the setup.exe to work or the uninstaller to work. surfing tech support over next couple weeks to try various agents was useless and expensive until i finally reached someone with useful info. all the agents had foriegn accents and read from scripts and web support pages until yesterday, when i reached a guy who told me two things i'll report to various forums addressing this same issue:
    1. download windows uninstaller program from their website (google: windows ininstaller). this program is different from the one that doesnt work in the programs and features area of control panel when you try to uninstall adobe products from there.
    2. windows explorer 8, the newest version, DOES NOT download adobe softare properly and leaves things out, causing all sorts of issues including the setup.exe program not working. download firefox browser from mozella (google: firefox) and use it for all adobe downloads. apparently the old windows explorer 7 will work, but if you already have explorer 8 installed its easiest to just use firefox.
    i'm spending the next couple days downloading the 4.14 G web premium trail with firefox and will report if this works.

  • Setting ScrollBars From Child Class

    I have a JScrollPane which contains a JPanel that displays an image. I have a rubberband box which will zoom in on the image which works fine. The problem that I am having, is that I need to adjust the JScrollPane's sliders. From within the mouse listener, I zoom the image to the desired scale and after it has zoomed, I call the parent class, JScrollPane to set the sliders to the new ratio. Even though I call it after it has zoomed and I call revalidate, the JScrollPane still has the old values for the sliders and has not updated them. If anyone has any ideas, I would appreciate it.

    For ratio.... I just converted the place where I zoomed to as a percentage rather than the exact pixels. So I would zoom in from the jpanel.... repaint the image to the panel, revalidate. I would then call the JScrollPane and set the slider values to, H=35%, V=27%.
    I tried your suggestion on overriding getPreferredSize() but I could not get it to work.
    I think this will demonstrate my problem a little better:
    (from the image panel)
    ZoomToBox(image); //scales image to correct zoom and paints to panel(works fine)
    this.setPreferredSize(new Dimension(image.width, image.height));
    this.revalidate();
    jScrollPanel.revalidate();
    System.out.println(image.getWidth() + " " + jScrollPanel.getHorizontalScrollBar().getMaximum());
    what prints out is (567 1150) which tells me that even though the image has zoomed, the scrollbars have not yet been updated.... then on the next zoom it will display(1150 4602) always beeing one behind. I tried to force setPreferredSize, even tried to force setSize before displaying the values but the scrollpanel is always behind.
    For some reason, I dont even know why I tried it, but if I create a new thread to set the scrollbars it works (most) of the time. I dont want to have to do it that way though.

  • Slideshow controlled by scrollpanel?

    Is there a way to create an automatic slideshow gallery that is controlled by the thumb position on a scrollbar?
    I'm a FLash AS3 noob and I'd like to place an article or story inside a scrollpanel. At certain points of the story, I'd like the thumb (on the scrollbar) to trigger an event that transitions to a new image inside the slideshow gallery.
    For example, let's take Goldie Locks and the Three Bears:
    - Story opening    : Frame1
    - Porridge Scene  :Frame 2
    - Chairs scene     :Frame 3
    - Beds scene       : Frame 4
    Again, I would like the slideshow to be controlled by the up and down movement of the scollbar.
    If you good people would help me with this, my kids and my students would be eternally grateful!!
    Thanks.

    I'll assume you mean a text box to be a textarea component.  Here's some code where 'ta' is the textarea component, and the vertical scroll position is compared to values (end1,end2, etc, which you will  have to determine/specify) that mark the boundaries for changing frames in the movie any time the scroll bar is scrolled.
    import fl.events.ScrollEvent;
    function updateMovie(evt:ScrollEvent):void {
        // determine scroll position
        var sPosition = ta.verticalScrollPosition;
        // test position to see which frame should be showing for the movie
        if(sPosition >= 1 && sPosition < end1){
            movie.gotoAndStop(1);
        } else if(sPosition >= end1 && sPosition < end2){
            movie.gotoAndStop(2);
        } // etc...
    ta.addEventListener(ScrollEvent.SCROLL, updateMovie);
    If your intention is to use a regular textfield with a uiscrollbar component, then the only changes would be to name that scrollbar 'ta' (or change the name in the code to whatever name you use) and use scrollPosition instead of verticalScrollPosition.
    Determining the end# values will be a matter of you going thru and seeing what the sPosition value is as you scroll.  You can either place a textfield on the stage temporarily to write the value so you can see it, or you can use the trace function to have it appear in the output panel.

  • Scrollbar adjustment

    Hello,
    I got a simple problem. I have a JTextArea within a JPanel. That Textarea has a scrollbar. Now I want to listen to the events coming, so that my Textarea will... SCROLL.
    Thats about it. The source code is appended down there.
    Thank you very much for any help.
         import java.awt.*;
         import java.awt.event.*;
         import javax.swing.*;
         public class ScrollPanel extends JPanel {
         JLabel label;
         public ScrollPanel() {
         super(true);
         area = new JTextArea();
         setLayout(new BorderLayout());
         JScrollBar hbar=new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
         JScrollBar vbar=new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
         hbar.setUnitIncrement(2);
         hbar.setBlockIncrement(1);
         hbar.addAdjustmentListener(new MyAdjustmentListener());
         vbar.addAdjustmentListener(new MyAdjustmentListener());
         add(hbar, BorderLayout.SOUTH);
         add(vbar, BorderLayout.EAST);
         add(area, BorderLayout.CENTER);
         class MyAdjustmentListener implements AdjustmentListener {
         public void adjustmentValueChanged(AdjustmentEvent e) {
         //label.setText(" New Value is " + e.getValue() + " ");
         //repaint();
         public void setText(String text){
              area.setText(text);
         private static final long serialVersionUID = 1L;
         private JTextArea area;

    Uuhm, haven't thought about it because I took the code from a book.

  • How to enable a scrollbar in a JPanel

    Hi
    I am adding some components in a JPanel and I am adding the JPanel to a JScrollPane.The JScrollPane is finally added to the container.Now I could manage to get only the scrollbars added but it does not work!How should I use the scrollbars to view all the components that are added inside the JPanel.
    Here is my source code:
    tagPanel = new JPanel();
    tagPanel.setLayout(new FlowLayout());
    tagPanel.setPreferredSize(new Dimension(100,100));
    tagPanel.setBackground(Color.white);
    tagPanel.setAutoscrolls(true);
    for(int i = 0; i<=20; i++)
    tempButton = new JButton("Testing");
    tagPanel.add(tempButton);
    container.add(forbiddenscroll= new JScrollPane
    (tagPanel),BorderLayout.WEST);
    forbiddenscroll.setHorizontalScrollBarPolicy
    (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    forbiddenscroll.setVerticalScrollBarPolicy
    (ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    Thank you for your reply!
    Your help is very much appreciated.

    don't set prefered size of the tag panel.
    run this code pasted below. it work fine.
    regards,
    Pratap
    import java.awt.*;
    import javax.swing.*;
    public class Frame1 extends JFrame {
         JScrollPane forbiddenscroll;
         JPanel tagPanel;
         JButton tempButton;
         public Frame1() {
              tagPanel = new JPanel();
              tagPanel.setLayout(new FlowLayout());
              tagPanel.setBackground(Color.white);
              tagPanel.setAutoscrolls(true);
              for(int i = 0; i<=20; i++)
                   tempButton = new JButton("Testing");
                   tagPanel.add(tempButton);
              forbiddenscroll = new JScrollPane();
              forbiddenscroll.getViewport().setView(tagPanel);
              getContentPane().add(forbiddenscroll, BorderLayout.CENTER);
              forbiddenscroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
              forbiddenscroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         public static void main(String[] args) {
              Frame1 f = new Frame1();
              f.pack();
              f.setLocation(200,200);
              f.show();
    }

  • HTML Frames not using custom scrollbar in Flex 3 mx:HTML

    I've been working on an app that uses a custom skin in Flex 3. The app has a help window. The help contains an HTML with frames. Problem is, the main app vertical scrollbar custom skin is being ignored for the HTML Frames scrollbar (what looks like the classic version of Halo - maybe). This only happens with frames. It happens no matter how or where I place my HTML or HTMLLoader. If I dont have frames the custom scrollbar is used. Is there a node im missing in my skin css (obviously not VScrollBar or ScrollBar - the two standard used by Flex)? or some other way to connect the HTML Frames scrollbar to my custom skin.
    I'm not a noob but not an expert.
    Thanks.
    See attached image for example.

    Take the code of the jsp file :
    <%@ page language="java" %>
    <%@ taglib uri="WEB-INF/struts-html.tld" prefix="html" %>
    <html>
       <head>
         <title> First Struts Application </title>
       </head>
         <body>
            <table width="500" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td> </td>
            </tr>
            <tr bgcolor="#36566E">
              <td height="68" width="48%">
                <div align="left">
                  <img src="images/hht.gif" width="220" height="74">
                </div>
              </td>
            </tr>
            <tr>
             <td> </td>
            </tr>     
           </table>
           <html:form action="Lookup"
                      name="lookupForm"
                      type="wiley.LookupForm" >
           <table width="45%" border="0">
            <tr>
              <td>Symbol:</td>
              <td><html:text property="symbol" /> </td>
            </tr>
             <tr>       
              <td colspan="2" align="center"><html:submit/> </td>
             </tr>       
            </table>              
          </html:form>
         </body>
    </html>

  • Problem with panelbox and af:table scrollbar issue and panelstretchlayout

    Hi,
    <af:panelStretchLayout >
    <f:facet name="center">
    <af:panelSplitter orientation="vertical" positionedFromEnd="true" inlineStyle="vertical-align:inherit;">
    <f:facet name="first">
    <af:subform default="false" id="xyz">
    <af:panelBox background="light" text="Advance Search" inlineStyle="color:InactiveCaption;" type="default">
    <af:panelGroupLayout layout="scroll">
    <af:commandButton text="Search" id="advSearch" actionListener="#{ADFStandardsLeftMenu.getAdvancedSearchData}"/>
    <af:spacer width="20"/>
    <af:commandLink text="Search Tips" id="searchtips2" inlineStyle="font-weight:bold;" partialSubmit="true" clientComponent="true">
    <af:showPopupBehavior triggerType="click" align="afterEnd" popupId="advSearchPopupId"/>
    </af:commandLink>
    </af:panelGroupLayout>
    </af:panelBox>
    </af:subform>
    </f:facet>
    <f:facet name="second">
    <af:panelBox background="light" text="Basic Search" inlineStyle="color:InactiveCaption;" type="default">
    <af:spacer height="20"/>
    <af:panelGroupLayout layout="scroll" >
    --- some inputtext command buttion, dropdowns...selectonechoice..are there inside this
    </af:panelGroupLayout>
    </af:panelBox>
    </f:facet>
    </af:panelSplitter>
    </f:facet>
    </af:panelStretchLayout>
    problem:
    (we have 2 panels) of vertical
    when i run this application it is working fine. But when we minimise the browser(half size) or if we add more no of toolbars in browser (important) obviously browser size will decrease,
    that time 1 panel getting decreased second panel is maintaing fixed size, not resizing.
    I tried to give fixed size (percentage) for both panels wt ever the operation does.
    and 2nd issue
    ========
    <af:panelStretchLayout>
    <f:facet name="center">
    <af:panelSplitter orientation="vertical"
    positionedFromEnd="true" >
    <af:panelBox background="light" text="Search For Standards" inlineStyle="color:InactiveCaption;vertical-align:50%;" >
    <af:table value="#{ADFStandardsLeftMenu.mostCommonAgencySelectedList}"
    id="t1" width="100%" var="stdURL"
    emptyText="<html><b><font color='red'><center>No Records Found</center></font></center></b></html>"
    disableColumnReordering="true"
    columnSelection="multiple"
    rowSelection="multiple"
    inlineStyle="text-align:left;"
    verticalGridVisible="true"
    horizontalGridVisible="true">
    <af:column>
    </af:column>
    ---- we have more 8-10 columns
    </af:table>
    </af:panelbox>
    </af:panelsplitter>
    </f:facet>
    </af:panelstretchlayout>
    problem: that time im getting by default horizontal and vertical scrollbar, but if user add toolbars in browser (view->customize)add toolbar no of say 10-15 that time window size decreasing
    so, table size is crossing panelbox size, and bottom scrollbar is not visible (hiding under site bottom layout say site is divided into 4 parts (leftmenu, body(2 panels), right, bottom) (im not using any right layout)
    regards,
    sandeep

    Hi,
    if minimises browser window(half) or by adding more no of toolbars, i given an option as panelgrouplayout layout=scroll.
    it is working fine for 1st panel.
    but 2nd panel scrollbar not coming.
    thanks in adv.
    regards,
    sandeep

  • Label display issue in Tree component when it is having vertical scrollbar

    I am using tree component as dropdown factory for combo box. When i open dropdown, it doesn't have vertical scrollbar and all the root nodes are getting displayed correctly(in closed mode). Now if i try to open any node, i am getting vertical scrollbar as the child nodes are more. Now the problem is if scroll down, some of the nodes(labels) are not getting displayed but i am able to see the icon. If i keep on scrolling bottom to top and top to bottom, some of the nodes are showing labels and some are not(It is inconsistant).
    I have not used any custom item renderer for tree control. I used my custom dataDescriptor which i have implemented from ITreeDataDescriptor. Also I tried extending DefalutDataDescriptor, but no luck.

    Does it work if the tree is not in a combobox?

  • How to add vertical scrollbar to a tree region

    Hi,
    I have a page containing two regions. The first is a tree region displayed on the left hand side of the page. The second is form region displayed to the right of the tree, showing details relating to the selected node from the tree.
    How can I add a vertical scrollbar to the tree, so that I can I browse all nodes in the tree without affecting the position of the form? Currently, if my tree extends beyond the height of the page I have to use the page vertical scrollbar to view the bottom of the tree. This obviously means that the form is no longer in view.
    Thanks
    Andrew.

    Hi Andrew,
    You can't add a scrollbar directly to the region's contents, but you can wrap the contents within a DIV tag.
    In the Region Header add in:
    &lt;DIV style="height:500px; overflow:auto"&gt;
    In the Region Footer add in:
    &lt;/DIV&gt;
    Obviously, change the height value to suit your needs.
    Regards
    Andy

  • Need Images To Open Up From Scrollbar

    Hi all. I am trying to get pictures to pop up in a box when
    the cursor rolls over one of the thumbnails in a scroll bar i have
    created. i know it is possible because i have seen it on websites
    before, but am stuck in an area and don't know how to resolve the
    problem. i don't know if it needs actionscript or can be done
    another way. Any help would be greatly appreciated. here is the
    address to the page and as far as i am with it right now, so you
    can get a better idea of what my problem is.
    http://www.vaughnleekustomz.com/scrollfinish.swf
    and here is the page to the tutorial that i did step by step,
    so you can see what i did to get where i am to with the scrollbar.
    http://www.vaughnleekustomz.com/tutorial.html
    thanks and have a good day!

    Hi,
    The 5D mark III requires ACR 6.7 or higher - PSE 9 can only goes as far as ACR 6.5.
    You need to update to a newer version of PSE or use the free DNG converter to turn the CR2 files into DNGs which can then be read by PSE9.
    Brian

  • How can I allow a user to control my Edge Animation using only the scrollbar?

    I have seen a few examples of an Edge Animation being conrolled by the scrollbar, and I am wondering how I could achieve the same effect.
    Example:
    http://dominikruckli.ch/scrolltest/scrolltest.html
    I have searched the corners of the internet and have found 2 or 3 different tutorials, but none of them have proven successful.
    In basic terms, I am creating an animation that involves a character getting from Point A to Point B, from the beginning of my timeline to the end.
    Rather than exporting my animation so that it plays automatically, by itself, I would like for a user to scroll vertically, and the playing of the animation moves in conjunction with the scroll bar.
    As the user scrolls from top to bottom on the scrollbar, the character in my animation moves from Point A to Point B.
    Also, if the user stops scrolling... the character will stop moving as well.
    In addition, I would like the surrounding area, outside of my stage, to remain hidden. I do not want to allow the user the ability to scroll around and see off of my designated stage area. I only want the scroll bar to act as a playhead for the animation.
    Any help will be greatly appreciated.
    Thank you
    Note:
    If you have special CSS (or other form of Code), please provide specific instructions on how to insert this code, where it should be located, what part(s) of the code should be altered, and any additional instructions on how to apply any form of coding. (Screenshots would be amazing)

    Never mind.  I figured it out myself.  I changed the myComp.play("scenefour"); to myComp.getStage().play("scenefour"); and it worked fine. 

  • How can I activate my scrollbar to work on the ipad?

    I am using my ipad and the scrollbars don't work in my applications. Does anyone know how to change this setting?

    Are you talking about the scroll bar when you put your finger on the page doesn't show, work, or other ?

  • To disable the horizontal scrollbar and to create a next button to navigate

    To disable the horizontal scrollbar and to create a next button to navigate through the records. At present I create a JSF page and drag and drop my table view and then using the Tuning property I have limited the number of records to be shown. But I need to add a button and then code it to display the next few records. Can someone kindly suggest a suitable mechanism to get this accomplished.
    Edited by: 888970 on Oct 2, 2011 10:15 PM

    Hi Erp,
    At present these are the entries that I have in my JSPX page.
    I have a Table, Iterator and a Input List of Values. As per the scenario, I want a few rows to appear on the table for which I wanted to disable the horizontal scroll bar and then once I click on the list of values it must prompt me with the remaining page numbers.
    Earlier there are about 150 records in the table. I want to show them as 15 per page.
    For which I have added the Iterator and a LOV component code in my JSPX page.
    <af:iterator id="i1"
    value="#{bindings.NsEventDetailsView1.collectionModel}"
    var="row"
    binding="#{pageFlowScope.testPageBean.myIterator}"/>
    <af:inputListOfValues label="Label 1"
    popupTitle="Search and Result Dialog" id="ilov1"/>
    Then I created the bean class as per the example.
    Below is the bean class:
    import javax.faces.event.ValueChangeEvent;
    import oracle.adf.view.rich.context.AdfFacesContext;
    import org.apache.myfaces.trinidad.component.UIXIterator;
    import org.apache.myfaces.trinidad.event.AttributeChangeEvent;
    public class TestPagebean {
    public TestPagebean() {
    public void i1ov1_valueChangeListener(ValueChangeEvent valueChangeEvent) {
    // Add event code here...
    private UIXIterator myiter;
    public void setI1(UIXIterator myiter) {
    this.myiter=myiter;
    public UIXIterator getmyiter() {
    this.myiter=myiter;
    public UIXIterator setmyiter() {
    return myiter;
    UIXIterator valueIterator = getmyiter();
    if (!valueChangeEvent.getNewValue().equals(valueChangeEvent.getOldValue())) {
    int newPage =
    Integer.parseInt(valueChangeEvent.getNewValue().toString());
    int pageStart = (newPage) * valueIterator.getRows();
    valueIterator.setFirst(pageStart);
    AdfFacesContext.getCurrentInstance().addPartialTarget(valueIterator);
    But i am getting errors in the bean class.
    1. Block expecting }
    2. public UIXIterator getmyiter() {
    this.myiter=myiter;
    Return Statement missing
    3. Block expecting {
    4. Type or variable 'valueChangeEvent' not found
    5. Method 'getNewValue' not found
    6. Method 'getOldValue' not found
    7. Method 'toString' not found
    Can you suggest a possible solution?

Maybe you are looking for

  • My issues with iPhone 2.0 on Original iphone

    Here are some of the issues i am seeing with the 2.0 update on my iPhone 2g. Texting is sometimes slow, however, exiting the app, or rebooting fix's the issue. Even though Mail was properly configured, upon the first install of 2.0, mail would crash

  • How can I import High res graphics from Photoshop?

    I've figured out how to save the title graphic as a channel and as a tiff, then drag it into imovie but the resolution un-attractively low. Any help would be appreciated. Thanks.

  • Using Flash/Actionscript to create PDF Portfolio Navigator

    Hi Guys We've been using Acrobat Pro Extended to create PDF Portfolio's for a wee while now, and now in order to create a 'fresh look', my boss is wanting to create custom navigators. As the programmer of the team, I've looked into it and found out t

  • BAPI/BADI for mass upload

    Hi Everybody,     I want to mass upload all the entries in EK01 and EK02 from an excel file (or any legacy system)rather than manually entering all the details which consumes a lot of time.Althogh we can do it through LSMW  but if there could be a a

  • How to calculate a week & Month in given date range (not for sele-options)

    Hi ,   I have defined 2 date parameters in sel-screen (Plz remember that date variable are not a SELECT-OPTIONS).  Now i want ot display week nos & monts in output.       Ex: date1: 20080101 & date2: 20080229. then                 weeks : 1, 2, 3,---