Horizontal scroll bar at top in JScrollPane

Hi,
How can i get the horizontal scroll bar to be on the top instead of bottom
here is my code
TableModel tableModel = new TableModel(totalData,
columnHeader);
JTable table = new JTable(tableModel);
JScrollPane scrollPane = new JScrollPane(table);
Ashish

Hi Ash
I dont know whether this is feasible please sorry if i am wrong.
Create a JPanel and add scroll bar to the left and top.
I have posted a Q in the subject JDialog Esc Key. please answer the Q for me.
Lakshmi.

Similar Messages

  • JList in JScrollPane never shows horizontal scroll bar

    I have a JList inside a JScrollPane. When I add a lot of cells to the list, the vertical scroll bar appears as expected. However, if I add a cell that would require lots of horizontal space in which to render, the horizontal scroll bar never appears.
    Is there a way to make the JList take on the width of the widest rendered cell?
    Josh

    Here's some code that will demonstrate the problem. Run the code, then resize the window so that the horizontal scroll bar should appear.
    Code for jds.toys.Main:
    package jds.toys;
    import javax.swing.DefaultListModel;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    public class Main extends JFrame {
         protected DefaultListModel model;
         public Main()
              super("JList in JScrollPane");
              model = new DefaultListModel();
              model.addElement("A very very very very very very long String");
              model.addElement("A very very very very very very very long String");
              model.addElement("A very very very very very very very very long String");
              model.addElement("A very very very very very very very very very long String");
              model.addElement("A very very very very very very very very very very long String");
              model.addElement("A very very very very very very very very very very very long String");
                      JList list = new JList(model);
                      list.setSize(300,300);
                      list.setFixedCellHeight(30);
                      list.setCellRenderer(new MyCellRenderer());
                      JScrollPane scrollPane = new JScrollPane(list);
                      add(scrollPane);
                      setSize(400,400);
        public static void main(String[] args) throws InterruptedException {
             final Main m = new Main();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                     m.setVisible(true);
    Code for jds.toys.MyCellRenderer:
    package jds.toys;
    import java.awt.Component;
    import java.awt.Graphics;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.ListCellRenderer;
    public class MyCellRenderer extends JPanel implements ListCellRenderer
         private Object currentValue;
         private JList currentList;
         public MyCellRenderer()
         public Component getListCellRendererComponent(     JList list,
                                             Object value,
                                       int index,
                                       boolean isSelected,
                                       boolean cellHasFocus)
              currentValue = value;
              currentList = list;
              return this;
         public void paintComponent(Graphics g)
              int stringLen = g.getFontMetrics().stringWidth(currentValue.toString());
              int ht = currentList.getFixedCellHeight();
              g.setColor(getBackground());
              g.fillRect(0,0,stringLen,ht);
              g.setColor(getForeground());
              g.drawString(currentValue.toString(),0,ht/2);
    }

  • How do I view the Horizontal Scrolling bar and status bar at the bottom of the screen. I can only see the top menus, toolbars and vertical scroll bar?

    Before the most recent upgrade, the bottom horizontal scrolling bar and status bar appeared on my screen. Now since upgrading, I cannot see the. Anyone ideas how to restore them?

    If you haven't already, you could force-quit Quicktime by using the menu option from the desktop (finder) and choose Quicktime.
    Not sure what you have frozen on the screen, be it a failed movie, or some unusual screen shot. If you can find by date (created) you may be able to look for .mov or quicktime suffix name or other video file content to delete it.
    And you may have to restart your computer and perhaps run repair disk permissions from Disk Utility's first aid on the hard disk drive in your computer.
    Not sure if all that would help now, but it is something a few days late...!
    Good luck & happy computing!

  • How to make the knob of a horizontal Scroll Bar stay at right

    Hi I need some advise to achieve this:
    I have a chart continuously deploying towards the right side (think on an electro cardiogram that is continuously feeding data). All the chart information is kept available inside a JScrollPane. What I want to achieve is:
    1. if the horizontal scroll bar knob is at the right end of the scroll bar make the end part of the chart be displayed continuously (view is scrolling to the right, the knob stays at the right end)
    2. if the user moves the knob left from the right end freeze the motion and just show the selected portion (meanwhile data keeps being fed and stored but not displayed)
    3. when the user decides to drag the knob again to the right end the behavior of point # 1 resumes.
    The basic swing structure I'm using for this is the following:
    public class Electro extends JPanel {
    public Electro() {
    JFrame f = new JFrame();
    JScrollPane sp = new JScrollPane(this);
    f.getContentPane().add(sp);
         f.pack();
         f.setVisible(true);
    I would highly appreciate any feedback from fellow members. Thank you.

    hi friend
    try this in ur code
    public class Electro extends JPanel {
    public Electro() {
    JFrame f = new JFrame();
    JScrollPane sp = new JScrollPane(this);
    sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    f.getContentPane().add(sp);
    f.pack();
    f.setVisible(true);
    i think it will be help full to you
    thanks
    waiting for reply

  • Horizontal Scroll Bar does not show

    I have a method which creates a table with values and displays it in a dialog. However, the horizontal scroll bars do not appear, even though there is are columns that are not seen in the view. Here is my code:
         private void setTable()
              Object columns[] = headerLST.toArray(),
                        rows[][] = new Object[rowLST.size()][headerLST.size()];     
              for(int x = 0; x < rowLST.size(); x++)
                   java.util.List list1 = (java.util.List)rowLST.get(x);
                   for(int y = 0; y < list1.size(); y++)
                        rows[x][y] = (String)list1.get(y);     
              DefaultTableModel tValues = new DefaultTableModel(rows, columns);
    JTable tableA = new JTable(tValues);
         tableA.setRowHeight(27);
                   tableA.setRowSelectionAllowed(false);
                   tableA.setColumnSelectionAllowed(false);
                   tableA.setFont(new Font("Dialog", Font.BOLD, 12));
              int minColWidth = 120, maxColWidth = 200;
              for(int y = 0; y < tableA.getColumnCount(); y++)
                   TableColumn tbc = tableA.getColumnModel().getColumn(y);
                   tbc.setPreferredWidth(minColWidth);     
                   tbc.setMinWidth(minColWidth);
                   tbc.setMaxWidth(maxColWidth);
              scrollA = new JScrollPane(tableA);
              this.getContentPane().add(scrollA, BorderLayout.CENTER);
    Can someone tell me what I am missing?
    Thanks
    Augustine

    You need this
    tableA.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    otherwise it will always try and fit the table to the space available

  • Horizontal scroll bar on JTextPane

    Hey everyone! I need to know how I can add a horizontal scroll bar to a jTextPane. I can NOT use a jTextArea though because I need to be using a StyledDocument. Right now, when I add it to a jScrollPane, it only scrolls vertically, but it wordwraps. Thanks for reading!

    Override getScrollableTracksViewportHeight() method to return false and at the same time, override setSize() method to adjust size of text pane. Following example shows this:
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    * TextPane without wrap.
    * @author mrityunjoy_saha
    * @version 1.0
    * @since Apex 1.2
    public class NoWrapTextPaneTest {
        private JTextPane editor;
        public NoWrapTextPaneTest() {
            JFrame frame = new JFrame("NoWrapTextPaneTest");
            frame.setSize(new Dimension(300, 400));
            //frame.setResizable(false);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.editor = new JTextPane() {
                @Override
                public boolean getScrollableTracksViewportWidth() {
                    return false;
                @Override
                public void setSize(Dimension d) {
                    Dimension pSize = getParent().getSize();
                    if (d.width < pSize.width) {
                        super.setSize(pSize.width, d.height);
                    } else {
                        super.setSize(d);
            frame.getContentPane().add(new JScrollPane(editor,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
            frame.setVisible(true);
        public static void main(String[] args) {
            NoWrapTextPaneTest textPaneTest = new NoWrapTextPaneTest();
    } Thanks,
    Mrityunjoy

  • Urgent!!!!Add a Horizontal Scroll Bar for Table Control

    Hi Experts,
    I want to have a Horizontal Scroll Bar on my Table control.
    I tried with few properties for the Table UI Element but not able to solve it.
    If any one who had already done this please help me out.
    Thanks in advance..
    Regards, Kishore K

    HI Koen,
    Thanks for early Reply.
    When I use this I get
    Page Down ( ->!!, Arrown with lines pointing Down)
    Page UP
    Page Top    ( ->, Arrown with lines pointing Top)
    Page Down ( ->, Arrown with lines pointing Down)
    But I need only Page top and Page down for this Table UI .
    I think my question is clear enough.
    Please let me know this also.
    Thanks & Regards,
    Kishore K

  • Horizontal scroll bar in 1024x768 resolution

    I working in a older type HP notebook. ( Windows XP 32bit) This notebook max screen resolution is 1024x768
    A few days ago i update my Firefox.In the new version the websites wider than my screen and Firefox show the horizontal scroll bar, which is very annoying!
    There is a solution?
    Than you!
    Gab.

    Wow. Firefox 10 is terribly insecure and you should update to the latest version ASAP. Windows 7 is capable of handing 29.
    Also, I notice that in your original post you said you had Windows XP but your System Details (the computer you posted this question from) shows you running Windows 7 with Firefox 10.0.4. Which operating system are you using. I know an easier way to know.
    Can you start by giving us the troubleshooting information <b>from the Firefox installation that's having problems. </b>This is an essential step in troubleshooting.<br>
    *Click the Firefox button at the top left, then click the ''Help'' menu and select ''Troubleshooting Information'' from the sub-menu. If you don't have a Firefox button, click the Help menu at the top and select ''Troubleshooting Information'' from the menu.
    Now, a new tab containing your troubleshooting information should open.
    *At the top of the page, you should see a button that says "Copy text to clipboard". Click it.
    *Now, go back to your forum post and click inside the reply box. Press Ctrl+V to paste all the information you copied into the forum post.

  • Horizontal scroll-bar on folder view

    This is a big problem for me, my folder structure is very complex and has lots of nested, long-named folders. Even maximizing the left sidebar size, I still can't view the most nested ones!!
    2 solutions:
    - add a horizontal scroll-bar
    - (Picasa like), make some folder temporarily the top one (don't like this one personally)
    and by the way, the nesting margin should really be reduced!
    thanks
    Luca

    I agree, but in the mean time, Jeffrey's Configuration manager allows you to make the panels arbitrarily wide:
    http://regex.info/Lightroom/Config/

  • Horizontal Scroll Bar Appear?

    How can I make a horizontal scroll bar appear so when the web page is resized the content wont moved around or get compacted? Example: http://www.techrepublic.com/ (resize thebrowser and youll notice that after a certain amount of resizing a horizontal scroll bar appears)
    All my width values in my CSS are in percentages and when the page is shrunk the sontent gets compacted.

    heres the page: http://tyharo.x10.mx/
    I'm just tinkering with some layouts so it looks terrible.
    and heres my css:
    @charset "utf-8";
    /* CSS Document */
    body {
              margin:0;
              padding:0;
              height:100%;
    .menublock {
              height:50px;
              width:52.6%;
              margin-bottom:0;
              margin-top:0;
              margin-left:23.7%;
              margin-right:23.7%;
              background-color:#CCC;
              overflow:hidden;
              position:relative;
    .windowblock {
              width:100%;
              height:50px;
              background-color:#3399FF;
              border-bottom:inset;
              border-top:inset;
              border-bottom-color:#999999;
              border-top-color:#FFFFFF;
    .bodyblock {
              height:50px;
              width:52.6%;
              height:250px;
              margin-bottom:0;
              margin-top:0;
              margin-left:23.7%;
              margin-right:23.7%;
              background-color:#CCC;
              overflow:hidden;
              position:relative;
    #line1 {
              float:left;
              width:26.8%;
              height:250px;
              border-width:3px;
              margin-top:3px;
    #line2 {
              float:left;
              margin-top:0;
              width:45%;
              height:250px;
              min-width:45%;
              position:relative;
    #line3 {
              float:left;
              width:26.8%;
              height:250px;
              margin-top:3px;
    #sectiongap {
              width:100%;
    #menu {
              margin-left:30%;
              margin-top:3%
    #footer {
    ul.horizontal{
              margin:0;
              padding:0;
              list-style-type:none;
              text-align:center;
    ul.horizontal li{
              display:block;
              float:left;
              padding:0 10px;

  • TextArea horizontal scroll bar?

    Is it possible to have horizontal scroll bars in TextAreas? In html, the horizontal and vertical scroll bars automatically render themselves when needed. But that is not happening with the TextArea dropped on the design page from Creator's JSF Standard Components palette. Is there a setting somewhere to make the horizontal scroll bar show?

    Hi,
    This problem has been noticed earlier too and a bug exists for the same. In the meanwhile the following workaround is available which has been suggested by one of the engineers:
    1. Add a "div" tag enclosing "select" tag.
    2. Move the style attribute from "select" tag on "div" tag
    3. In addition, add an "overflow" attribute to "style" attribute on "div" tag and set it to "auto".
    <div style="left: 168px; top: 96px; overflow: auto; position: absolute; height: 192px; width: 192px">
    <ui:listbox binding="#{newPage.listbox1}" id="listbox1" items="#{newPage.listbox1DefaultOptions.options}" />
    </div>
    Please be warned that once you do, your page will not render well in designer. So this should be done once the app has been rendered and is ready for deployment.
    Hope this helps
    Cheers
    Giri

  • Getting a horizontal scroll bar in the DHTML_SHUTTLE

    Hello,
    We are currently using Carl's DHTML_SHUTTLE procedure to display some shuttles.
    I have a problem where the data is longer than the width of the shuttle and was wondering if it is possible to implement a horizontal scroll bar so that the user can see it?
    Thanks,
    Paul

    alisadri wrote:
    Hi there,
    I have created a JScrollPane object for a JTable. Using the code below, I am trying to create a horizontal scroll pane for the JTable object but the horizontal
    bar doesn't move at all. this is the code. Also when I create the horizontal bar as "AS_NEEDED" the horizontal bar does not appear. The vertical bar works
    properly. Can someone help me with this please.
    This is the Code:
    loadTableScrollPane = new JScrollPane(getLoadTable()); //"getLoadTable()" return a JTable object.
    loadTableScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    loadTableScrollPane.setViewportView(getLoadTable());
    loadTableScrollPane.setBounds(new Rectangle(5, 149, 1135, 232));
    Just a wild guess ... because you do need to post a real example - but get rid of the setBounds and setPreferredSize and use pack() on the frame.

  • Horizontal scroll bar not showing in PO

    Hi Experts,
    I'm unable to see the Horizontal scroll bar in PO item overview..so unable to see all the columns..is there any setting for that ???so that I can use it again ...

    Hi,
    Click 'Table Control Settings' icon (press the button on the top-right
    hand of the item details area you're referring to - the icon is 3
    columns with a a yellow first column)
    In the 'Administrator' area there is a setting here in the section
    'Further settings', with a field 'No. of fixed columns'.
    Check the value here.Make it to 2 and activate.You should be able to see the scroll bar now.
    Regards,
    Ashwini.

  • Horizontal scroll Bars not coming in JTable

    Hi,
    If a user streches any column of the jtable to the right such that its values are not visible properly. Then should the horizontal scroll bar come in the scrollpane in which table is there.??
    If Yes then how can I do it?
    I have seen when no of rows becomes more than the display area of the table then vertical scrollbar are coming automatically. but not Horizontal scroll bars.
    Please help

    sorry for my previous mistype, here is the right solutions to your problem.
    As default the JTable will auto resize your column width, if you want horizon scrollbar
    you must do following below steps:
    JTable tableview = new JTable (model) ;
    tableview.setAutoResizeMode (JTable.AUTO_RESIZE_OFF) ;
    JScrollPane scrollpane = new JScrollPane (tableview,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED) ;
    JPanel p ;
    p.add (scrollpane) ;
    This can works for you !

  • Set the horizontal scroll bar for the OOTb document library view

    hi all,
     Am facing an issue in my sp portal.We have designed and developed the portal with OOTB document library views for site columns also. Going to enable the doc lib view. but  we have some  35 columns in eeacha nd every document
    library within our sub site. But if an end user wants to see the last column then he needs to scroll. but, since  then my master page has fixed width, the top corner will be seen as blank. would like to know how can we set horizontal scrolling
    in this doc lib view .
    Das

    Hi,
    According to your description, my understanding is that you want to set the horizontal scroll bar for the document library when the last column postion exceed the fixed width.
    I suggest you can try to use Jquery to set the width attribute of the menu bar dynamically if the document library width exceeded. You can add the Jquery or CSS style using SharePoint Designer under the PlaceHolderMain tag of document
    library page. Also, you need to find the div id in your environment using Internet Explorer.
    More information:
    http://sharepointpromag.com/sharepoint-development/sharepoint-branding-101-branding-master-pages
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

Maybe you are looking for