Horizontal scrolling in a JTable with fixed-size columns

Hello,
I have come to a roadblock concerning the following issue. Perhaps someone can share their ideas...
I have a JTable with three fixed-size columns. I implemented a JScrollPane with vertical and horizontal scrolling. However, the text inserted into the last column is too long to fit in the specified column width. I would like to be able to scroll the table so that I can view all of the text in the last column. Right now, the text cuts off and ends with three dots (...). Is there a way in which a horizontal scroll bar can be implemented to view all the text in the last column?
Here is a portion of my code:
num_of_rows_Table2 = (int) Math.pow(3, num_of_vars);
String[] colunmNames_Table2 = {"Decimal Identifier", "Ternary Identifier", "Cancellation of nonimplicants"};
dataModel2 = new DefaultTableModel(colunmNames_Table2, num_of_rows_Table2);
SpaceOfTermsTable = new JTable(dataModel2);
for (int z = 0; z < num_of_rows_Table2; z++)
SpaceOfTermsTable.setRowHeight(z, row_height);
SpaceOfTermsTable.setBounds(new Rectangle(x1_Table2, y1_Table2, width_of_pane2, height_pane2));
SpaceOfTermsTable.getTableHeader().setReorderingAllowed(false);
for (int i = 0; i < 2; i++)
TableColumn col = SpaceOfTermsTable.getColumnModel().getColumn(i);
col.setMinWidth(colwidth_Table2);
col.setMaxWidth(colwidth_Table2);
col.setPreferredWidth(colwidth_Table2);
TableColumn lastcol = SpaceOfTermsTable.getColumnModel().getColumn(2); lastcol.setMinWidth(lastcol_Table2);
lastcol.setMaxWidth(lastcol_Table2);
lastcol.setPreferredWidth(lastcol_Table2);
SpaceOfTermsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
scrollPanel2 = new JScrollPane(SpaceOfTermsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPanel2.setAutoscrolls(true);
scrollPanel2.setBounds(new Rectangle(x1_Table2, y1_Table2, width_of_pane2, height_pane2));
Thanks in advance for all of the help!

Hi, I hava a similar problem than yours - can you tell me how you sorted out yer's?

Similar Messages

  • CL_GUI_DOCKING_CONTAINER with fix size

    Hi!
    Is it possible to create instance of CL_GUI_DOCKING_CONTAINER with fix size?

    lv_style = cl_gui_control=>ws_child + cl_gui_control=>ws_border + cl_gui_control=>ws_visible.
        CREATE OBJECT docking
          EXPORTING
            repid                       = repid
            dynnr                       = dynnr
            side                        = docking->dock_at_top
            ratio                       = 80
            style                       = lv_style
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6

  • Horizontal Scroll does not work with Apple Magic Mouse

    Horizontal Scroll does not work with Apple Magic Mouse as it does with other Adobe software such as Photoshop.

    The system preferences window for the mouse has changed. The GUI elements are different.

  • Horizontal scrolling doesn't work with ItemsStackPanel in ListView(GridView)

    Hi,
    In Win 8.1 App Store Project I have a ListView with fixed width and listen for ContainerContentChanging event because of performance issues.
    When ListView width is less than content width, horizontal scrolling doesn't work. If we change ItemsStackPanel to VirtualizingStackPanel, horizontal scrolling works fine. But ContainerContentChanging doesn't work with VirtualizingStackPanel.
    Is it possible to make horizontal scrolling work with ItemsStackPanel?
    Here simple example to reproduce this problem:
    <Page
    x:Class="App8.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App8"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
    <DataTemplate x:Key="ContinuousViewItemTemplate">
    <Border Width="800"
    Background="Green"
    Margin="10"
    Padding="5">
    <Border x:Name="root" Height="800" Background="{Binding}"/>
    </Border>
    </DataTemplate>
    <Style x:Key="ListViewStyle1" TargetType="ListView">
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Visible"/>
    <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Enabled"/>
    <Setter Property="ItemTemplate" Value="{StaticResource ContinuousViewItemTemplate}"/>
    </Style>
    </Page.Resources>
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="100"/>
    <ColumnDefinition Width="500"/>
    <ColumnDefinition/>
    <ColumnDefinition Width="500"/>
    <ColumnDefinition Width="100"/>
    </Grid.ColumnDefinitions>
    <ListView Style="{StaticResource ListViewStyle1}" Grid.Column="1">
    <SolidColorBrush Color="Red"/>
    <SolidColorBrush Color="Cyan"/>
    </ListView>
    <ListView Style="{StaticResource ListViewStyle1}" Grid.Column="3">
    <ListView.ItemsPanel>
    <ItemsPanelTemplate>
    <VirtualizingStackPanel/>
    </ItemsPanelTemplate>
    </ListView.ItemsPanel>
    <SolidColorBrush Color="Red"/>
    <SolidColorBrush Color="Cyan"/>
    </ListView>
    </Grid>
    </Page>

    Hi Mikhail Maksyuta,
    Welcome back!
    Yes, you are right! I have reproduced it on VS 2013 professional.
    I will report it as bug, Thanks for your valuable suggestions!
    If you have any other questions about this, please feel free let me know!
    Thanks again!
    Regards! 
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Help with FIXED LENGTH columns - using spool command

    Hi guys,
    I have a view I am trying to spool using fixed length columns, and the spacing is off. Ive tried numerous things such as specifiying the column width before running the query, using the rpad command, but nothing seems to work. I have to spool it to a text file in order for the users to import this file into another system. I would welcome any and all suggestions. Thanks so much. The following is the view:
    SELECT "EMPLOYEE_ID","FIRST NAME","INITIAL","LAST NAME","SUFFIX","TRAINING DATE","Course ID","Class ID", "We", "Make / Model", "Cali", "Barrell", "Serial Number", "Qualification", "Application", "SCORE", "Status", "Add Time", "Record Add ID","Record Add Date","Record Change ID","Record Change Date","RN" FROM
    (SELECT
    UPPER(RPAD(tbl.ssn,10)) AS "EMPLOYEE_ID",
    UPPER(RPAD('',12)) AS "FIRST NAME",
    UPPER(RPAD('',1)) AS "INITIAL",
    UPPER(RPAD('',20)) AS "LAST NAME",
    UPPER(RPAD('',5)) AS "SUFFIX",
    UPPER(RPAD(to_char(QUALDATE, 'mmddyyyy'),8)) AS "TRAINING DATE",
    UPPER(RPAD('P123',8)) AS "Course ID",
    UPPER(RPAD('',6)) AS "Class ID",
    UPPER(RPAD('P',4)) AS "We",
    UPPER(RPAD('',4)) AS "Make / Model",
    UPPER(RPAD('',4)) AS "Cali",
    UPPER(RPAD('',7)) AS "Barrell",
    UPPER(RPAD('',15)) AS "Serial Number",
    UPPER(RPAD('A',4)) AS "Qualification",
    UPPER(RPAD('D',4)) AS "Application",
    to_char((RAWSCORE/250)*100, 'fm000.00') AS "SCORE",
    UPPER(RPAD('PASS',4)) AS "Status",
    UPPER(RPAD('',8)) AS "Add Time",
    UPPER(RPAD('',8)) AS "Record Add ID",
    UPPER(RPAD('',8)) AS "Record Add Date",
    UPPER(RPAD('',8)) AS "Record Change ID",
    UPPER(RPAD('',8)) AS "Record Change Date",
    row_number()over(partition by firearms_scores.ID_NUMBER order by QUALDATE desc ) rn
    FROM FIREARMS_scores, TBL
    where scores.id_number=tbl.id_number
    and qualyear='2010' and coursecode='SA'
    order by employee_id)
    where rn =1

    Hi,
    You RPAD doesn't do anything, since they are same as:
    SQL> SELECT NULL AS "Record Add ID",
      2         NULL AS "Record Add Date",
      3         NULL AS "Record Change ID",
      4         NULL AS "Record Change Date" FROM DUAL;
    R R R R
    SQL>Can't see why COLUMN command shouldn't do what you want. Maybe you forgot the double quotes?
    SQL> COL "Record Add ID" FOR a18
    SQL> COL "Record Add Date" FOR a18
    SQL>
    SQL> SELECT NULL AS "Record Add ID",
      2         NULL AS "Record Add Date",
      3         NULL AS "Record Change ID",
      4         NULL AS "Record Change Date" FROM DUAL;
    Record Add ID      Record Add Date    R R
    SQL>P.S: You probably shouldn't set a column width which is smaller than the header length
    Regards
    Peter

  • Ordering JTables with fixed column

    I have 2 JTable. The first one is not scrollable and the second one yes. I want to order both tables? How can I do??

    You haven't given any information which leads me to believe this is anything other than sorting a table. See [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting]here.

  • Need help on implementation of a circular queue with fixed size

    The constructor of the queue is as below:
    RingBufferNode[] element;
    RingBufferNode firstFree;
    RingBufferNode firstFilled;
    public RingBufferQueue (int n) {
              element = new RingBufferNode[n];
              for(int i=0; i<element.length-1; i++){
                   element.next = element[i+1];
              element[element.length-2].next = element[element.length-1];
              element[element.length-1].next = element[0];
              firstFree = element[0];
              firstFilled = firstFree;
         }class RingBufferNode {
         public Object value;
         public RingBufferNode next;
         public RingBufferNode (RingBufferNode n)
              { next = n; }
    }Each node in the queue are expected to have a pointer "next" pointing to the next node in the queue, where the last one will be pointing to the first. When I called the constructor to create a new RingBufferQueue, the following error occurs:Exception in thread "main" java.lang.NullPointerExceptionI've tried to throw the exception however it seemed to be a useless move.
    Edited by: ewrhgqerh on Dec 11, 2008 5:31 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Sorry don't quite get what you want me to post, I'm a starter. It's not using a stack, but a queue instead. And the place where the compiler flagged the error is this line:
    element.next = element[i+1];                                                                                                                                                                                                                                                                                                                                                                                                                                                   

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

  • Detecting clicked column in JTable (with JCheckBox in column)

    I am struggling with something that seems like it should be so simple, but it doesn't work as I expect;
    I have a table with 5 columns, the 5th column is a CheckBox. What I need to do is detect when the 5th column changes, ie. the check box is clicked;
    If I use a MouseListener on the table, and derive the table from the event, the column that I get back from getSelectedColumn() is -1, which is not conclusive. I assume this is because clicking the check box is not actually selecting the column.
    I implemented a TableModelListener as follow;
    tableModel.addTableModelListener(new TableModelListener()
    public void tableChanged(TableModelEvent e)
    System.out.println("Changed Column is " + e.getColumn() + " " + e.getFirstRow());
    This seems to do the same as before, and gives a first row of 0 and selected column of -1. Once again inconclusive.
    The cell as I say is rendered as a JCheckBox, the data in the table model obviously being Boolean.
    Can anyone suggest how I can determine if my column with a Check Box in has been clicked, and if so, which Row? (I have thought about overriding JCheckBox, but this seems more work than necessary)
    Thanks in anticipation

    You need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html]
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on
    the information provided.
    Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting] so the posted code retains its original formatting.

  • Horizontal scrolling with a table that is 100% width of window/container

    Hello,
    I'm a bit perplexed - it seems to me that the only way that I can have both fixed and scrollable columns in a table, with a table that resizes to the width of the user's screen, is to have percentage widths for all the entries.
    Warning imminent rant
    This seems to me to almost defeat the purpose. I want to be able to show more columns if the user has a large screen, and less if they have a small screen, keep certain key fields always showing and have the space avaliable for each column fixed to the size of the column contents. Having percentages of the screen for all columns just means that the column will get wider and thinner, not more or less!
    Is there any hope that this might come along with client side scrolling in NetWeaver EhP2? Or does anyone have a cunning solution to the problem?
    Now, I can sort of understand why this functionality has been build like this (the ABAP not having any real idea of how wide the screen actually is) - but why deliever such a solution at all? I can almost understand a fixed width situation, although all that code for a minimal improvement over just specifying the number of scrollable columns is suprising - but I struggle to see the use case for setting all the columns in a table to display as percentage widths.
    Rant over -
    If anyone does have any ideas how to have a 100% width table with fixed width columns - please do let me know.
    Cheers,
    Chris

    Can this work:
    Emebed your table UI element in Transparent Container UI element ( give it a fixed width ), now make table width as 100 % and make each column width as Width of Transparent Container / No of Columns.
    Although I'm suggesting this but in my opinion giving fixed width to any UI element height width property is not advisable and recommended. It is because when browser will be resized by the user then if there is a fixed width settings then scrollbars would appear and layout may also go haywire.
    If on the other hand if we are giving % (relative of window ) in width height of UI elements then layout will be adjusted automatically.
    Regards
    Manas Dua

  • Don't want horizontal scroll therefore want to reduce size of the report

    hi
    pls help me.I don't want horizontal scroll in my report.Some of the columns are going out of the window.
    therefore I want to reduce the size of the report.cant found any thing to do this.
    BHARAT THOSAR

    I had the same problem and found help here in the forum. I think it was Vikas who gave me the following tip:
    In the CSS Style of your column attributes type something like this:
    display:block;width:100px;overflow:hidden;
    in order to determine the width of your column. You got to play arround with this a bit to get
    the result you expect.
    Denes Kubicek

  • Creating a JTable with resizeable columns and Horizontal Scrollbar

    Hi,
    I would like to create a JTable with about 24 columns in it. The problem is, my ViewPort in my JScrollPane is about 3-400pixels wide, and the JTable tries to cram itself into the ViewPort. This makes the columns too tiny to read. I'd like it to do something a little more sensible, like use the PreferredSize of the columns. Can anyone point me in the right direction to keep JTable from creating scrunched up little columns, so that it creates columns that are at least partially readable? Thanks.
    BTW, I suppose I could set NO_AUTO_RESIZE but I would rather not do that. I like being able to resize columns. Basically what I want to do is control the JTable's width and not worry about the ViewPort's width.

    This made it impossible to resize columns. Works fine for me:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableHorizontal extends JFrame
        public TableHorizontal()
            JTable table = new JTable(5, 10);
            table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
            table.getColumnModel().getColumn(0).setPreferredWidth(10);
            table.getColumnModel().getColumn(1).setPreferredWidth(20);
            table.getColumnModel().getColumn(2).setPreferredWidth(30);
            table.getColumnModel().getColumn(3).setPreferredWidth(40);
            table.getColumnModel().getColumn(4).setPreferredWidth(50);
        public static void main(String[] args)
            TableHorizontal frame = new TableHorizontal();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setVisible(true);
    }

  • Unnecessary horizontal scroll bar in API

    PROBLEM .................
    Someone recently asked:
    When viewing the Java SE v1.4.1 docs
    http://java.sun.com/j2se/1.4.1/docs/api/index.html
    in frames in Internet Explorer v6.0, the right frame always has a horizontal scroll
    bar regardless of how I size the window. This results in the right or
    left edge of the docs to be clipped in the browser. I had the same
    problem with the v1.4.0 docs leading me to believe it is an issue in the
    HTML generation in the javadoc tool. I'm no fan of Microsoft, but your
    HTML docs should be viewable in the most popular browser on Windows
    IMHO.
    SOLUTION.................
    This is due to a bug in IE, for which there is a workaround that
    you can easily implement by making a small change to a single file.
    The horizontal scroll bar will go away if you change api/index.html
    from this:
    <FRAME src="overview-summary.html" name="classFrame"
    title="Package, class and interface descriptions">
    to this:
    <FRAME src="overview-summary.html" name="classFrame" scrolling="yes"
    title="Package, class and interface descriptions">
    However, this fix did not make it into 1.4.2.
    This is the bug report:
    http://developer.java.sun.com/developer/bugParade/bugs/4852280.html
    -Doug Kramer
    javadoc team

    Ohh... thanks. I was wondering about that.

  • Can we create JTable with multiple rows with varying number of columns ?

    Hi All,
    I came across a very typical problem related to JTable. My requirement is that cells should be added dynamically to the JTable. I create a JTable with initial size of 1,7 (row, columns) size. Once the 7 columns are filled with data, a new row should be created. But the requirement is, the new row i.e. second row should have only one cell in it initially. The number of cells should increase dynamically as the data is entered. The table is automatically taking the size of its previous row when new row is added. I tried by using setColumnCount() to change the number of columns to '1' for the second row but the same is getting applied to the first row also.
    So can you please help me out in this regard ? Is it possible to create a JTable of uneven size i.e. multiple rows with varying number of columns in each row ?
    Thanks in Advance.

    Well a JTable is always going to paint the same number of columns for each row. Anything is possible if you want to rewrite the JTable UI to do this, but I wouldn't recommend it. (I certainly don't know how to do it).
    A simpler solution might be to override the isCellEditable(...) method of JTable and prevent editing of column 2 until data in column 1 has been entered etc., etc. You may also want to provide a custom renderer that renderers the empty column differently, maybe with a grey color instead of a white color.

  • Horizontal Scrolling in JTextArea???

    Hi,
    I have disabled horizontal scrolling in a textarea with this command,
    scrollpane1 = new JScrollPane(ta,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    where ta is my textarea.
    But whenever i continue typing the text continues in the same line even if the end of the textarea is reached and does not automatically go to the second line. How do i make it continue to the next line as soon as the width of the textarea is reached. Please help.

    This is called wrapping. Check out the JTextArea API:
    setLineWrap(boolean wrap)
    setWrapStyleWord(boolean word)

Maybe you are looking for

  • WD scorpio black 500 7200rpm running very slow on MBP 8.1

    hi guys, recently change my hitachi 5400rpm in to WD scorpio black 7200rpm, but now my MBP (early 20111) running very slow and laggy, slower than the hitachi. it takes hours just to install mountain lion (system said 30minutes left but in reality it

  • How to use Application Designer with virtual box vm's

    hi all, I could use some help please. I have everthing installed and working on the VMs but now I want to use Application Designer but I must be doing something wrong. I installed the Oracle client on windows and created tnsnames.ora. I can't connect

  • Files no longer default to SRGB after processing

    I still have the ICC profile box checked when ave a Jpeg after processing. Noticed that there was a bit of color shift on some images viewed on my web site in firefox---- checked the color space---unassigned!!  That usually only happened the check bo

  • 3 double and time questions

    I have 3 questions regarding the double type an time 1. What is the maximum number of decimal places a double value can hold? 2. I have a time string as follows 01:30:21:19F30 which means 1hr 30 mins 21 seconds and 19/30 seconds. I wish to convert th

  • Error code -69 when trying to sync laptop to ipod

    Hey there, I just got my nano (2nd gen) and first time it sync'd just fine. I bought some itunes and set up some podcasts and now everytime (5+) I connect the two I get: Attempting to copy to disk 'My Ipod' failed. An error code occured (-69). I've r