Horizontal scroll bar in AWT List

I need to shrink the width of my list by putting a horizontal scroll bar. Does anyone know how to add one onto my list component

The code looks like this. I can really use some help here.
Label grp = new Label("Group By:");
     buildConstraints(constraints, 0, 2, 1, 1, 1, 1);
     gridbag.setConstraints(grp, constraints);
     add(grp);
     grplist = new List(4, false);
buildConstraints(constraints, 1, 2, 1, 1, 1, 1);
     gridbag.setConstraints(grplist, constraints);
     for(i = 0; i <= number_of_fields; i++){
          grplist.add(data[0]);
add(grplist);
     data6 = new Checkbox("6 sigma data",false);
     buildConstraints(constraints, 1, 12, 1, 1, 1, 1);
     gridbag.setConstraints(data6, constraints);
     add(data6);
     show = new Checkbox("Show values",false);
     buildConstraints(constraints, 1, 13, 1, 1, 1, 1);
     gridbag.setConstraints(show, constraints);
     add(show);
     aver = new Checkbox("Plot Average",false);
     buildConstraints(constraints, 1, 14, 1, 1, 1, 1);
     gridbag.setConstraints(aver, constraints);
     add(aver);
     remove(aver);

Similar Messages

  • Problem with Horizontal Scroll on java.awt.List

    I use the same code for a General Application as a CDC Application.
    I have no problem at all with the General Application but on the CDC I can't scroll to the right (horizontal).
    Why do I get this problem on the CDC application and not on a regular application?
    I use the PP-1.0 Profile for the CDC application. Does it not support horizontal scroll on java.awt.List?
    This is the code:
    * Main.java
    * Created on den 22 augusti 2007, 10:52
    package cdcapplication6;
    * @author  Erik Rothman
    public class Main extends java.awt.Frame {
        /** Creates new form Main */
        public Main() {
            initComponents();
              for (int i = 0; i < 10; i++) {
                   list1.add("Short text");
                   list1.add("Some very long text indeed. Some very long text indeed.");
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            list1 = new java.awt.List();
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            add(list1, java.awt.BorderLayout.CENTER);
            pack();
        }// </editor-fold>                       
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {                         
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Main().setVisible(true);
        // Variables declaration - do not modify                    
        private java.awt.List list1;
        // End of variables declaration                  
    }

    I use the same code for a General Application as a CDC Application.
    I have no problem at all with the General Application but on the CDC I can't scroll to the right (horizontal).
    Why do I get this problem on the CDC application and not on a regular application?
    I use the PP-1.0 Profile for the CDC application. Does it not support horizontal scroll on java.awt.List?
    This is the code:
    * Main.java
    * Created on den 22 augusti 2007, 10:52
    package cdcapplication6;
    * @author  Erik Rothman
    public class Main extends java.awt.Frame {
        /** Creates new form Main */
        public Main() {
            initComponents();
              for (int i = 0; i < 10; i++) {
                   list1.add("Short text");
                   list1.add("Some very long text indeed. Some very long text indeed.");
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            list1 = new java.awt.List();
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            add(list1, java.awt.BorderLayout.CENTER);
            pack();
        }// </editor-fold>                       
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {                         
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Main().setVisible(true);
        // Variables declaration - do not modify                    
        private java.awt.List list1;
        // End of variables declaration                  
    }

  • Horizontal Scroll bar in a list Box?

    Hi,
    I have a requirement in Adobe Designer where my List Box should also show Horizontal Scroll bar in it.
    Is it possible?
    Thanks.

    Thanks Debadas,
    But i need both (Horizontal & Vertical) the scroll bars and depending on the data length either or both should be visible, without changing the data visiblity or text rotation.
    Regards,

  • Horizontal scroll bar muti select list

    Hi,
    I have a multi select list the size of which is restricted doe to other items on the page but some of the values in the lov are wider that the display area, is it possible to get a scroll bar at the bottom so users can scroll alaong and see the few values that are too big.
    Thanks Andy

    The code looks like this. I can really use some help here.
    Label grp = new Label("Group By:");
         buildConstraints(constraints, 0, 2, 1, 1, 1, 1);
         gridbag.setConstraints(grp, constraints);
         add(grp);
         grplist = new List(4, false);
    buildConstraints(constraints, 1, 2, 1, 1, 1, 1);
         gridbag.setConstraints(grplist, constraints);
         for(i = 0; i <= number_of_fields; i++){
              grplist.add(data[0]);
    add(grplist);
         data6 = new Checkbox("6 sigma data",false);
         buildConstraints(constraints, 1, 12, 1, 1, 1, 1);
         gridbag.setConstraints(data6, constraints);
         add(data6);
         show = new Checkbox("Show values",false);
         buildConstraints(constraints, 1, 13, 1, 1, 1, 1);
         gridbag.setConstraints(show, constraints);
         add(show);
         aver = new Checkbox("Plot Average",false);
         buildConstraints(constraints, 1, 14, 1, 1, 1, 1);
         gridbag.setConstraints(aver, constraints);
         add(aver);
         remove(aver);

  • 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);
    }

  • My horizontal scroll bar went missing when I maximise the window. How do I fix them?

    My horizontal scroll bar went missing when I maximise the window. How do I fix them? I tried everything; such as auto hide the task bar. Even with this, I still can't see the horizontal scroll bar. I even tried the following and I still can't see the horizontal scroll bar.
    1) In a new tab, type or paste about:config in the address bar and press Enter. Click the button promising to be careful.
    (2) In the search box above the list, type or paste dom and pause while the list is filtered
    (3) Double-click the dom.disable_window_open_feature.scrollbars preference to switch it from false to true. By choosing true, you disable sites from deciding whether there can be scrollbars on a window, and Firefox uses its standard behavior for the page.
    If you want to always get other bars, here are the corresponding settings:
    Menu Bar: dom.disable_window_open_feature.menubar
    Navigation Toolbar: dom.disable_window_open_feature.toolbar
    Bookmarks Toolbar: dom.disable_window_open_feature.personalbar
    Please help.

    Can you post a screen shot?
    Taking a Screen shot; '''''Windows > Start >''''' search box '''''> Snipping Tool'''''.
    Save the picture(s) to your desktop. Now look at the '''Reply''' box below.
    Do you see the button under it that says '''Browse'''? Click it and then select
    the screen shot(s) from the desktop.

  • 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

  • Horizontal scroll bar to a shuttle

    How can I display a horizontal scroll bar in a shuttle? I'm hoping it's as simple as adding an attribute to the form element attribute box.
    Regards.

    Hi,
    AFAIK its not possible to add horizontal scroll bar to shuttle/select list. You need to use workaround...or try jQuery..
    Regards,
    Shijesh

  • I have a problem with interactive report in  horizontal scroll bar

    hi all,
      in my interactive report the horizontal scroll bar is not visible and i have created a scroll bar with the html code and i have a problem in that scroll bar when ever i will click the select list and if i will move the scroll bar and the select list is also moving but it the select list dont have to move .pls give me a solution for this urgent.
    thanks in advance 

    Kishore suresh wrote:
    hi all,
      in my interactive report the horizontal scroll bar is not visible and i have created a scroll bar with the html code and i have a problem in that scroll bar when ever i will click the select list and if i will move the scroll bar and the select list is also moving but it the select list dont have to move .pls give me a solution for this urgent.
    thanks in advance
    Hi,
    How you think anybody can help if you do not post single line how you have try create that scrolling report ?
    And if your issue is urgent, you are seeking help from wrong place.
    Regards,
    Jari

  • Annoying Finder Horizontal Scroll Bar

    I have an annoying Finder issue with Mountain Lion OS X 10.8 and maybe someone knows how to fix.  When I have a folder displayed, like the Applicaitons folder, with View opton set to "as List" the Finder displays a long horizontal scroll bar at the bottom that is active. How can I lock or anchor the horziontal scroll bar to the left side. It really gets to be annoying as you mouse scroll up and down the list.  I have the same issue in with Excel and Numbers. If it cannot be locked to the left, can it be disabled or deleted?

    I just made each item listed the min width and this let me resize the window to ditch the horziontal scroll bar. This helped but did not solve the issue on how to lock it to the left or turn it OFF.
    Thanks

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

  • Lost Finder Horizontal Scroll Bar

    I can't seem to find my finder horizontal scroll bar. Even when I set scroll bars as show "all the time".
    Please see the screen shot.
    There is no horizontal scroll bar. Any suggestions? Thanks!

    I just made each item listed the min width and this let me resize the window to ditch the horziontal scroll bar. This helped but did not solve the issue on how to lock it to the left or turn it OFF.
    Thanks

  • Help with code for inserting horizontal scroll bar in photo gallery in Business Catalyst site?

    Hi,
    I am using Business Catalyst and Dreamweaver to create a trial site.
    I am not sure if this is the correct forum to post this request but anyway I have inserted a photo gallery module at the bottom of the sidebar in the homepage of my test site.
    Can anyone advise on whether jquery or any other code can be inserted into the page or module code that will replace the "next" hyperlink below the first 4 photos with a horizontal scroll bar at bottom of the gallery so users can just scroll through all 12 images ?
    Kind Regards, Matt.
    http://craftime-bs6.businesscatalyst.com/

    Alyssa,
    Have you tried putting this rule back as it was originally:
    /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to auto so it comes onto the screen below its parent menu item */
    ul.MenuBarHorizontal ul.MenuBarSubmenuVisible
        left: auto; /*was 9px*/
        color: #EF9CCF;
        background-color: #FFF;
    That is, changing your 9px back to auto.
    And giving  us a link (as you did) is much better than printing out the code for us! Thanks!
    Beth

  • How to get the Horizontal Scroll Bar for a Table?

    Hi All,
    As per my requirement, I am displaying several records in a Screen in a Tabular Format. But here I have to show 21 Columns in that table which is too high. I am able to display it but due to it I am getting a Horizontal scroll bar for the whole screen since all the columns are not getting displayed in the normal window screen space. But its looking too odd since once I am scrolling it to right the columns are getting displayed but the above Header Bar and Global buttons are not displaying, they are bound to the normal screen space.
    Is there a way to have a Horizontal scroll bar only for that table instead of the entire screen so that on scrolling that bar only the table rows will beshifted ant got displayed?
    With Thanks
    Kumar Gautam

    try this approach.
    include a raw text item before and table item.
    include the appropriate HTML tags in raw text item to enable horizontal scroll
    --Prasanna                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for