Jtable Horizontal ScrollBar problem

Hi,
I am having a Jtabel inside a JscrollPanel with horizontal and vertical scrollpane.
My table model contains say 20 columns.But i am showing only 10 columns hiding the other 10.when i click on the table header i will show the rest of 10.so now the total columns are 20.but when i scroll thehorizantal bar to the see the other 10 coulmns the header for the latest 10 coulmns is not showing properly.
Is there anybody to help me to sort out this problem.
Thanks in advance.
sree

Hi,
how ican saw Scrollbar with out Jtable.AUTO_RESIZR_OFF.That i already did.That not the actual problem.any how i solved this problem finally.It is something with TableHeaderRenderer..Any how thanks for ur help.
sree

Similar Messages

  • JTable horizontal scrollbars problems.

    When I create JTable component with colons that width more than ScrollPane object one, no horizontal bar is created and all colomns shrank so i can't view what is written in cells.
    If somebody know why horizontal bar is not created?
    Some problem with ScrollPane or I need do some trics?
    Thanx:))

    JPanel contentPane;
    XYLayout xYLayout1 = new XYLayout();
    JScrollPane jScrollPane1 = new JScrollPane();
    String[] cols = {"Name", "Type", "Weignt", "Height", "EyaColor", "EyaSkin"};
    String[][] rows = {{"dklfgjfghjfdjfghj","dkffghjfghjfgjjjd","dkffghjfghjfgjjjd,h,ffgdf","dfgdlhjklhjkhjlfgdfg","dfghjlhjlhjkhgjkdfg","dfghdfhgjklhjkgfkgfhjhdfgh"},
    {"dklfgjfghjfdjfghj","dkffghjfghjfgjjjd","dfgffgdf","dfgdfgdfg","dfgdfg","dfghdfhdfgh"},
    {"dklfgjfghjfdjfghj","dkffghjfghjfgjjjd","dfgffgdf","dfgdfgdfg","dfgdfg","dfghdfhdfgh"},
    JTable jTable1 = new JTable(rows,cols);
    //setIconImage(Toolkit.getDefaultToolkit().createImage(TestTableFrame.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(639, 339));
    this.setTitle("Test Table");
    contentPane.add(jScrollPane1, new XYConstraints(21, 29, 570, 279));
    jScrollPane1.getViewport().add(jTable1, null);

  • JTable -  Horizontal Scrollbar - Column Width

    I wish to add a horizontal scrollbar(which for some stupid reason Java has not included) to my JTable which is inside a JScrollPane and also make sure that the width of the fourth column is longer and can fit the String that i wish to display. Now, i have searched the forum for solutions but none of them seem to work. The setting of the column width with the help of TableColumnModel does not seem to work and not to mention the fact that when i turn auto rezise off for the JTable, the JTable does give me a horizontal scrollbar but then it makes the columns so less in width that i have gray area left on the right hand side and the setColumnsToFit method does not work. I have five columns and here is the code, any help would be greatly appreciated Thanks:
    excepTable = new JTable(excepTableModel);
    excepTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    int width = 100;
    TableColumnModel tcm;
    TableColumn tc;
    for(int i = excepTable.getColumnCount(); i > 0; i--)
    tcm = (TableColumnModel)excepTable.getColumnModel();
    tc = tcm.getColumn(i);
    if(i == 3)
    width = 400;
    tc.setWidth(width);
    tc.setMinWidth(width);
    tc.setMaxWidth(width);
    tc.setPreferredWidth(width);
    width = 100;
    exScroller = new JScrollPane(excepTable);

    .I've set a horizontal scrollbar by using 'table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);You are welcome.
    i want the column widht to be adjusted according to the length of column names and record length.so please tell me how to do it?Search the forum. This question has been asked and answered before.

  • TOC horizontal scrollbar problem

    Dear all experts,
    In my java help, TOC's horizontal scrollbar is set in the middle whenever it first shows up and the "plus" signs on the left of the tree icons cannot be seen initially. How can I fix the scrollbar to the left?

    Dear all experts,
    In my java help, TOC's horizontal scrollbar is set in the middle whenever it first shows up and the "plus" signs on the left of the tree icons cannot be seen initially. How can I fix the scrollbar to the left?

  • Sliding panel horizontal scrollbar problem

    Issue: This is about horizontal sliding panels.
    I want to restrict the height on the sliding panel to say,
    200px. Some of the panel content is longer than that. So I want a
    scrollbar to appear vertically (overflow:auto). It does this.
    However, when the panel with the scrollbar slides off to the left,
    its scrollbar remains present at the leftmost part of the window...
    where the new content panel is.
    Is there any way to prevent this from happening, and allow
    the content that needs the scrollbars to have it?
    thank you

    Hi jratlantic,
    So it appears that you changed the default setting for
    overflow on the .SlidingPanelsContent rule:
    .SlidingPanelsContent {
    width: 547px;
    height: 100px;
    overflow:auto;
    Instead of putting it on the .SlidingPanelsContent, try
    putting it on:
    .SlidingPanelsCurrentPanel {
    overflow:auto;
    And see if that makes a difference. That will ensure that
    only the panel that is currently showing, and not animating, has
    scrollbars.
    --== Kin ==--

  • How to make JTable use horizontal scrollbar

    My application uses a table to which data is added dynamically(both columns and rows). My problem is that when number of columns increase i want JTable to use horizontal scrollbar instead of resizing columns(which i achieve by setting resize mode to OFF state), But due to this if number of columns are less then there's alot of empty space left after showing columns(coz JTable cannot resize cols to fit Viewport area). To achieve both criteria i used following solution
    1. Set Auto resizing to OFF.
    2. Check if width of table is less than viewport width and if so then set auto
    auto resizing ON :) which will fit columns in viewport thereby occupying empty space.
    But this solution doesn't seem to be straight and simple to me. Is anyone aware of a simple solution to this problem.
    Dimension dm_Dm = new Dimension();
        RSBrowser.setModal(false);
        browseTable_Jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        // reqd o.w. JTable resizes column widths instead  of using horizontal
        // scrollbar
        RSBrowser.setVisible(true);
        browseTable_Jt.getSize(dm_Dm);
        // if table width is less than total viewport size then fill the extra
        // space by setting suto resize property to ON.
        if ( browseTable_Jt.getPreferredScrollableViewportSize().getWidth() >
             dm_Dm.getWidth() )
            browseTable_Jt.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
            browseTable_Jt.doLayout();
        RSBrowser.setModal(true);

    hi,
    with your problem statement it seems you should use javax.swing.JScrollPane like the one below
    JScrollPane tableScroller = new JScrollPane(yourTable);
    tableScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);hope this helps you,
    regards,
    Afroze.

  • JTable resizing VS Horizontal scrollbar

    Heila',
    I have to show the content of a text file in a JTable; the JTable has 2 columns: the first contains the line number and the second column contains the text of the line.
    In order to allow the user to view and scroll the whole text line I added an horizontal scrollbar to the JTable.
    Here is the relevant code:
    gridVis.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    JPanGriglia = new JScrollPane(gridVis, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JPanGriglia.getViewport().putClientProperty("EnableWindowBlit", Boolean.TRUE);     
    The problem is that if I set the AutoResizeMode to JTable.AUTO_RESIZE_OFF then I can see the horz scrollbar but when I resize the JFrame containing the JTable the JTable doesn't resize itself.
    Viceversa if I comment the statement:
    gridVis.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    then the JTable resizes correctly but the scrollbar disappears.
    Does exists the way to obtain both this features ?(correct resizing AND horizontal scroll bar)
    Thanks
    Ciao

    Try overriding getScrollableTracksViewportWidth() in JTable. The method returns a boolean value indicating whether the table should resize when its viewport is resized. If you setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS) and add a check to getScrollableTracksViewportWidth() such that it returns true only if viewport.getExtentSize().width is greater than some minimum width, then your table will resize automatically unless it is scaled below the minimum width, in which case a scrollbar will appear. If you're going to do this you'll need your JTable subclass to store a pointer to its scroll pane's viewport so it can get the extent size.

  • Problem with the HORIZONTAL Scrollbar

    Someone (I thanks him) has explain me how to have a horizontal scrollbar in a JTable (I use setHorizontalScrollBarPolicy(...)).
    So, now I have my Horizontal scrollbar but ONLY de bar and NOT the "button" in the bar. So, I am not able to scroll (and for a scrollbar it looks stupid). I have tried also setHorizontalScrollBar(...) but that didn't change anything.

    1. Try calling setEnabled(true); on the scrollbar
    2. Check that you need to scroll. If efffectively the knob (as the API docs call it) is larger than the scrollbar, it probably won't be shown.

  • Display a horizontal scrollbar in a JTable as to fit column width

    hi all,
    I am using JTable to display records.I've set a horizontal scrollbar by using 'table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);',but although i got a horizontal scrol bar the column width is constant for all the columns and not getting adjusted according to the lenght of the column names. As the column names and the records are of different size in the database i want the column widht to be adjusted according to the length of column names and record length.so please tell me how to do it?
    regards...

    .I've set a horizontal scrollbar by using 'table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);You are welcome.
    i want the column widht to be adjusted according to the length of column names and record length.so please tell me how to do it?Search the forum. This question has been asked and answered before.

  • Probleme with an unwanted horizontal scrollbar

    Hi
    Link of reference : http://www.episodesoft.com/demo/index_fr.html
    I'm having a little difficulty with the horizontal scrollbar, i dont want it to appear since the website is designed for 1024x768 up to 2000, so obviously everything is adjusting itself depending of your viewscreen, So does the flash ( the menu and header ).
    However it is the flash that cause the scrolling on the right but not on the left ??? the browser automatiquely adjust the left portion of the flash and is not creating a scrollbar for that, however i cannot find a way so it manage the right portion the same way it do the right one.
    It is weird because before the header was not in flash but still 2000px and i didn't have that probleme with the CSS.
    For the flash there is no CSS but here is the code. Feel free to view the source of the webpage itself
    Any idea ?
    Thanks a lot !
    <div id="layer1" style="position:absolute; top:-10px; left:50%; margin-left:-1000px; width:2000px; height:580px; z-index:2">
    <table width="950" border="0" align="center" >
      <tr>
        <td align="center" valign="middle">
        <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="2000" height="580">
          <param name="movie" value="Video/Menu.swf" />
          <param name="wmode" value="transparent">
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <param name="swfversion" value="6.0.65.0" />
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <param name="embed" value="wmode=&quot;transparent&quot;" />
          <param name="selectable" value="false" />
          <param name="border" value="0" />
          <param name="embed" value="border=&quot;0&quot;" />
         <object type="application/x-shockwave-flash" data="Video/Menu.swf" width="2000" height="580">
            <param name="quality" value="high" />
            <param name="wmode" value="transparent" />
            <param name="swfversion" value="6.0.65.0" />
            <param name="expressinstall" value="Scripts/expressInstall.swf" />
            <param name="embed" value="wmode=&quot;transparent&quot;" />
            <param name="selectable" value="false" />
            <param name="border" value="0" />
            <param name="embed" value="border=&quot;0&quot;" />
            <div>
              <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
              <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>
          </object>
          </object>
        </td>
      </tr>
    </table>
    </div>

    Herm oook.
    I just tryed to remove the margin-left:-1000px; however when i do that, the flash start in center of the viewscreen or will no longer auto center itself.
    The flash is in his own div and that div is above another div ( the content ).... so as long i put a background color in this one, it will cover all the website or the right side if i make one going from transparent to 100% on the right.
    Here is the whole code to help you
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Logiciel Épisode</title>
    <style type="text/css">
    #bottom {
    background-repeat:no-repeat;
    background-position: bottom;
    background-image: url(images/barre_bottom.png);
    height: 5px;
    #headinner  {
    background-position: center top;
    margin-top: 0px;
    margin-bottom: 0px;
    background-color: #F5F6F7;
    background-repeat: no-repeat;
    height: 95px;
    background-image: url(images/HeaderFR.png);
    body {
    background-color: #ffffff;
    margin-top: auto;
    margin-right: auto;
    margin-bottom: auto;
    margin-left: auto;
    background-image: url(images/fond.png);
    text-align: center;
    background-position: bottom;
    background-repeat: no-repeat;
    #Copyright {
    text-align: center;
    margin-bottom: 1px;
    margin-top: 1px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    #layer2 #Layer2 tr td p {
    text-align: center;
    font-size: 36px;
    margin-top: 100px;
    <!-- margin-left: 30px;
    -->;
    </style>
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    </head>
    <body>
    <!--<div id="headinner">
    INACTIVE HEADER  
    </div> -->
    <div id="layer1" style="position:absolute; top:-10px; margin-left:-1000px; left:50%; width:2000x; height:580px; z-index:2">
    <table width="950" border="0" align="center" >
      <tr>
        <td align="center" valign="middle">
        <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="2000" height="580">
          <param name="movie" value="Video/Menu.swf" />
          <param name="wmode" value="transparent">
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <param name="swfversion" value="6.0.65.0" />
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <param name="embed" value="wmode=&quot;transparent&quot;" />
          <param name="selectable" value="false" />
          <param name="border" value="0" />
          <param name="embed" value="border=&quot;0&quot;" />
         <object type="application/x-shockwave-flash" data="Video/Menu.swf" width="2000" height="580">
            <param name="quality" value="high" />
            <param name="wmode" value="transparent" />
            <param name="swfversion" value="6.0.65.0" />
            <param name="expressinstall" value="Scripts/expressInstall.swf" />
            <param name="embed" value="wmode=&quot;transparent&quot;" />
            <param name="selectable" value="false" />
            <param name="border" value="0" />
            <param name="embed" value="border=&quot;0&quot;" />
            <div>
              <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
              <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>
          </object>
          </object>
        </td>
      </tr>
    </table>
    </div>
    <div id="layer2" style="margin-top:100px" >
    <table border="0" align="center" id="Layer2" name="Layer2">
      <tr>
        <td background="images/accueil_fond.png" width="1035" height="485" aling="right" ><img src="images/accueil2_4.png" width="950" height="485" align="left" valign="middle"/></a></td>
        </tr>
    </table>
    </div>
    <div id="bottom">
    </div>
    <p id="Copyright">© 2010 - Logiciel Episode Inc.</p>
    <table width="10" border="0" align="center">
      <tr>
        <td align="center" valign="middle"><a href="index_us.html" target="_self">English</a></td>
        <td align="center" valign="middle"><a href="index_fr.html" target="_self">Francais</a></td>
    <!--
        <td align="center" valign="middle"><p><a href="index_us.html" target="_self"><img src="images/Drapeau_US.png" width="25" height="15" border="0" align="absmiddle" /></a></p></td>
        <td align="center" valign="middle"><a href="index_fr.html" target="_self"><img src="images/Drapeau_fr.png" width="25" height="15" border="0" align="absmiddle" /></a></td>
    -->  </tr>
    </table>
    <script type="text/javascript">
    <!--
    swfobject.registerObject("FlashID");
    //-->
    </script>
    </body>
    </html>

  • ScrollPane will not create Horizontal Scrollbar

    Hi,
    I have a JTable that I add to a JScrollPane. The Vertical scrollbars show up fine but I can't seem to get the horizontal scrollbars to appear. Is there something that I am doing wrong or is there a way to force the scrollbars to appear.
    Thanks!
    public void drawContractPanel() {
    SearchEvent searchEvent = SearchEvent.getInstance();
    searchEvent.setDealerList(dealers);
    searchEvent.setStatusList(statuses);
    String [] arrayDealers = searchEvent.getSelectedDealers();
    String [] arrayStatus = searchEvent.getSelectedStatuses();
    summaryTableModel.setQuery(arrayDealers, arrayStatus);
    contractTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    contractTable.setPreferredScrollableViewportSize(new Dimension(694, 135));
    saveAdapter = new SaveAdapter();
    contractTable.addMouseListener(saveAdapter);
    contractScrollPane.setPreferredSize(new Dimension(800, 140));
    contractScrollPane.setBounds(24, 340, 800, 140);
    contractScrollPane.setVisible(true);
    summaryTableModel.fireTableChanged(null);
    getContentPane().add(contractScrollPane);
    getContentPane().invalidate();
    getContentPane().validate();
    }

    You may be running into the problem of having the table resize the widths of the columns in order to make it fit into alloted viewport size. Try this line of code to make sure that the table columns remain at their preferred size.
    contractTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);If The widths of your columns are larger than the viewport of your scrollpane, this should give you the horizontal scrollbar you are after.
    Jerry

  • How to set the extra component to horizontal scrollbar position

    How to set the component to position of horizontal scrollbar , that position contain two component horizontal scrollbar and any component (JButton , JLabel ) like that.. Ms-Word scrollbar ,
    Like that bellow fig.
    <!--[if !mso]>
    <style>
    v\:* {behavior:url(#default#VML);}
    o\:* {behavior:url(#default#VML);}
    w\:* {behavior:url(#default#VML);}
    .shape {behavior:url(#default#VML);}
    </style>
    <![endif]--><!--[if gte mso 9]><xml>
    <w:WordDocument>
    <w:View>Normal</w:View>
    <w:Zoom>0</w:Zoom>
    <w:PunctuationKerning/>
    <w:ValidateAgainstSchemas/>
    <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
    <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
    <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
    <w:Compatibility>
    <w:BreakWrappedTables/>
    <w:SnapToGridInCell/>
    <w:WrapTextWithPunct/>
    <w:UseAsianBreakRules/>
    <w:DontGrowAutofit/>
    </w:Compatibility>
    <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
    </w:WordDocument>
    </xml><![endif]--><!--[if gte mso 9]><xml>
    <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
    </w:LatentStyles>
    </xml><![endif]-->
    <!--
    /* Style Definitions */
    p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:"Times New Roman";}
    @page Section1
    {size:8.5in 11.0in;
    margin:1.0in 1.25in 1.0in 1.25in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-paper-source:0;}
    div.Section1
    {page:Section1;}
    -->
    <!--[if gte mso 10]>
    <style>
    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-parent:"";
    mso-padding-alt:0in 5.4pt 0in 5.4pt;
    mso-para-margin:0in;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:10.0pt;
    font-family:"Times New Roman";
    mso-ansi-language:#0400;
    mso-fareast-language:#0400;
    mso-bidi-language:#0400;}
    </style>
    <![endif]-->{font:'Times New Roman'}{size:12pt}<!--[if gte vml 1]><v:shapetype id="_x0000_t75"
    coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
    filled="f" stroked="f">
    <v:stroke joinstyle="miter"/>
    <v:formulas>
    <v:f eqn="if lineDrawn pixelLineWidth 0"/>
    <v:f eqn="sum @0 1 0"/>
    <v:f eqn="sum 0 0 @1"/>
    <v:f eqn="prod @2 1 2"/>
    <v:f eqn="prod @3 21600 pixelWidth"/>
    <v:f eqn="prod @3 21600 pixelHeight"/>
    <v:f eqn="sum @0 0 1"/>
    <v:f eqn="prod @6 1 2"/>
    <v:f eqn="prod @7 21600 pixelWidth"/>
    <v:f eqn="sum @8 21600 0"/>
    <v:f eqn="prod @7 21600 pixelHeight"/>
    <v:f eqn="sum @10 21600 0"/>
    </v:formulas>
    <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
    <o:lock v:ext="edit" aspectratio="t"/>
    </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:453pt;
    height:26.25pt'>
    <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\04\clip_image001.png"
    o:title=""/>
    </v:shape><![endif]--><!--[if !vml]--><img src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/04/clip_image002.jpg" alt="" width="485" height="27" /><!--[endif]-->{size}{font}
    How to design ?

    pradeep.rajadurai wrote:
    I want set the JTable as a background of jframe or jinternalframe , how it is possible One way that may work, you can always extract the image from a rendered JTable and then paint the same image into the JPanel that holds your components via it's paintComponent method, then added the JPanel to the app's contentPane.
    give me simple pgmIs English your second language? Because if so, please understand that this demand can be taken by some as rude.

  • Horizontal scrollbar for JComboBox - Not workable under Mac

    By referring to this thread Re: Horizontal scrollbar for JComboBox across multiple look and feel I try to provide horizontal scroll bar for JComboBox to my clients.
    private void adjustScrollBar() {
        //if (this.getItemCount() == 0) return;
        Object comp = this.getUI().getAccessibleChild(this, 0);
        if (!(comp instanceof JPopupMenu)) {
            return;
        JPopupMenu popup = (JPopupMenu) comp;
        // Works fine under Windows and Ubuntu Linux
        // However, in OSX 10.6.4
        // javax.swing.Box$Filler cannot be cast to javax.swing.JScrollPane
        JScrollPane scrollPane = (JScrollPane) popup.getComponent(0);
        scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }The above code will cause ClassException under OSX 10.6.4. (Works fine for Windows and Linux)
    Any suggestion to resolve this problem. Sorry. I do not have a Mac machine. Hence, can't experiment out much with it.
    Thanks

    The following code works quite well for me.
        private void adjustScrollBar() {
            final int max_search = 8;
            // i < max_search is just a safe guard when getAccessibleChildrenCount
            // returns an arbitary large number. 8 is magic number
            JPopupMenu popup = null;
            for (int i = 0, count = this.getUI().getAccessibleChildrenCount(this); i < count && i < max_search; i++) {
                Object o = this.getUI().getAccessibleChild(this, i);
                if (o instanceof JPopupMenu) {
                    popup = (JPopupMenu)o;
                    break;
            if (popup == null) {
                return;
            JScrollPane scrollPane = null;
            for (int i = 0, count = popup.getComponentCount(); i < count && i < max_search; i++) {
                Component c = popup.getComponent(i);
                if (c instanceof JScrollPane) {
                    scrollPane = (JScrollPane)c;
                    break;
            if (scrollPane == null) {
                return;
            scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
            scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        }

  • JTable Horizontal Scroll WHEN NEEDED fix?

    Me again....
    JTable in a JScrollPane When the Jtable width exceeds the scrollpane I would like a horizontal scrollbar to appear. If the Jtable does not exceed the width Id like it to fill the ScrollPane.
    If I use the AUTO_RESIZE_OFF I get a horizontal scrollbar all the time. I dont want this if possible.
    I did try to overwrite getScrollableTracksViewportWidth() and getPreferredSize() as suggested by work around http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4127936
    However this bug is not exactly what I am having trouble with.
    Anyone know what I can do for this?
    Thanks
    B.

    You're welcome.
    Autoscrolling means that you can middle click on a web page and then get a scroll icon to indicate that you can move the mouse up or down to scroll the page automatically.

  • An unpleasant horizontal scrollbar in Internet Explorer

    Hello,
    I have a problem with an unpleasant horizontal scrollbar in
    Internet Explorer. There is no problem in Fireworks, but in I.E. I
    can't remove him.
    Here is the website:
    http://www.wolf-design.nl/concept/tresbon
    > click on "Ons menu" to see the horizontal scrollbar.
    Is there anyone who 'knows how I can solve this problem?
    Idwd

    I have the answer fount on another Forum.
    The doctype was:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    and must be:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN" "
    http://www.w3.org/TR/html4/loose.dtd">
    Idwd

Maybe you are looking for