JTable without headers - column resizing

I have a simple problem: a JTable with 3 columns, and NO HEADERS.
I want the middle column ONLY to be resized when the WINDOW is resized. The other two columns should remain of fixed size.
Is there a simple answer?
Many thanks for any help,
george33

Thank you Thomas for your prompt reply. I have eliminated the headers and automatic resizing using:
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
JTableHeader th=myTable.getTableHeader();
th.setReorderingAllowed(false);
th.setResizingAllowed(false);
jth.setPreferredSize(new Dimension(0, 0)); //remove headers
This works fine as far as eliminating resizing of all columns and removing the headers.
What I cannot work out is how to ensure that only the middle column is resized when the window is resized.
You refer to a component listener. Which componenent should I attach the listener to?
How can I make two columns of fixed size and one of variable size, and only when the window is resized?
thanks for your help
George33

Similar Messages

  • JTable without column headers?

    I want a JTable without the column headers.
    How can i do this?
    Cheers?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame {
        public Test() {
         String[] head = {"","",""};
         String[][] data = {{"0-0","0-1","0-2"},
                       {"1-0","1-1","1-2"},
                       {"2-0","2-1","2-2"}};
         JTable myTable = new JTable(data,head);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container content = getContentPane();
         content.add(new JScrollPane(myTable), BorderLayout.CENTER);
         setSize(200,200);
         show();
        public static void main(String[] args) { new Test(); }
    }

  • Resize column width for JTable without column headers?

    Hi,
    I find that for me to resize columns of a JTable by using
    mouse dragging, I MUST have column headers and then drag
    column headers to resize them. Is my understanding correct?
    Actually, I need to have a table without header columns.
    How can I use mouse to resize column width by dragging?
    The background for this request is that I am putting a
    complex table as another table's column header and I hope to
    be able to resizing the complex table by mouse dragging.
    Thanks very much,
    David

    Hi,
    I think you have mistake there. Try
    <style type="text/css">
    table.apexir_WORKSHEET_DATA td {
    white-space:nowrap !important;
    td[headers="DESCR"] {
    width:300px !important;
    max-width:300px !important;
    #apexir_DESCR {
    width:10px;
    max-width:300px !important;
    </style>And you can try add
    table.apexir_WORKSHEET_DATA {
    width: 100% !important;
    table-layout: fixed !important;
    }Regards,
    Jari
    My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai

  • JTable in JPanel last Column resize clips JTable doesnt repaint JPanel

    I have a JTable in a JPanel, when I drag the last column of the JTableHeader (u can see the column resizing as the text of the Table HeaderColumn moves with the drag) the JTable is outside the JPanel. Only when u click on another component and then click back on the JTableHeader does it repaint.
    I have tried jPanel.revalidate(); in the mouseDragged event of MouseMotionListener on the JTableHeader and all manner or repaints and fireTableStructureChanged. But I dont understand the order of events.
    The last bug to fix!!!
    NB I dont want to use scrollpane as its not necessary and as many tables are synchronized with one table it makes repaints less smooth
    Thanks Paul

    Well, I didn't find an answer but I did find a solution.
    The JPanel is the problem. I use it to help with layout which is not obvious in this example.
    As you can see in the code the JTable is placed in a JScrollPane which is place in a JPanel which is placed in a JTabbedPane.
    If I use Box instead of JPanel the JTable in the JScrollPane in the Box in the TabbedPane in the JFrame resizes correclty.
    So although JPanel is resizable with setSize it does not get resized when it's JFrame gets resized.
    I would still like to know why?
    ////////KBS
    JTabbedPane myTP = new JTabbedPane();
    Box myOne = Box.createHorizontalBox();
    Box myTwo = Box.createHorizontalBox();
    myOne.add(pane);
    myTP.add("One", myOne);
    myTP.add("Two", myTwo);
    ////////KBS

  • JTable: Easy groupable column headers with hideable columns

    Hi All,
    I have a requirement to make a JTable which displays
    columns with 2 values - a current value and an old one.
    The old value can be hidden or shown by user preference.
    The values are not editable. The 2 values have a single
    heading.
    I've been mucking about with GroupableTableHeader and
    HideableTableColumnModel and all that. This way of
    solving the problem requires siginificant coding.
    Then I had an idea - just use the TableCellRenderer to
    make it look like 2 columns ! This fits my requirements
    and is much simpler.
    So for anyone who has the same requirement, here is
    some sample code. I think you'll all agree that in my
    specific case it is a very good way of providing the needed
    functionality.
    Here is the sample code:
    import javax.swing.*;
    import javax.swing.border.AbstractBorder;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.DefaultTableCellRenderer;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    public class DoubleColumnTable extends JTable {
        private boolean secondValueVisible = true;
        public DoubleColumnTable() {
            super();
            setModel(new AbstractTableModel() {
                public String getColumnName(int column) {
                    return column + "";
                public int getColumnCount() {
                    return 5;
                public int getRowCount() {
                    return 5;
                public Object getValueAt(int rowIndex, int columnIndex) {
                    return new Integer[]{new Integer(rowIndex), new Integer(columnIndex + 10)};
            setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                    Integer[] twoValues = (Integer[])value;
                    JPanel panel = new JPanel();
                    if (secondValueVisible) {
                        panel.setLayout(new GridLayout(0, 2));
                        JLabel firstLabel = new JLabel(twoValues[0].toString(), JLabel.CENTER);
                        JLabel secondLabel = new JLabel(twoValues[1].toString(), JLabel.CENTER);
                        secondLabel.setBackground(Color.lightGray);
                        secondLabel.setOpaque(true);
                        secondLabel.setBorder(new LeftBorder());
                        panel.add(firstLabel);
                        panel.add(secondLabel);
                    } else {
                        panel.setLayout(new GridLayout(0, 1));
                        JLabel firstLabel = new JLabel(twoValues[0].toString(), JLabel.CENTER);
                        panel.add(firstLabel);
                    return panel;
        private void toggle() {
            secondValueVisible = !secondValueVisible;
            repaint();
        class LeftBorder extends AbstractBorder {
            public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
                g.setColor(Color.gray);
                g.drawLine(x, y, x, height);
        public static void main(String[] args) {
            JFrame frame = new JFrame();
            frame.setSize(300, 300);
            frame.setLocation(300, 200);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container contentPane = frame.getContentPane();
            final DoubleColumnTable table = new DoubleColumnTable();
            contentPane.add("North", new JButton(new AbstractAction("Toggle") {
                public void actionPerformed(ActionEvent e) {
                    table.toggle();
            contentPane.add("Center", new JScrollPane(table));
            frame.setVisible(true);
    }Message was edited by:
    NY_Consultant
    Message was edited by:
    NY_Consultant
    Message was edited by:
    NY_Consultant

    This should read
    "I have a table with column headers and a row headers using a single column from a second table."

  • JTable:  resizing all columns as 1 column resizes

    I have a JTable with 480 columns inside of a JScrollPane (AUTO_RESIZE_ALL_COLUMNS needs to be off for the JTABLE to display correctly in the JScrollPane). When the user resizes one column I would like the rest of the columns to resize too, so that the column widths of each column are equal.
    Thank you in advance,
    Brent

    [...] I
    I have the JScrollPane listening to a histogram of the
    balances so the user can click on a month in the
    histogram and the JScrollPane (actually JViewport)
    will move to display the appropriate column in the
    JTable. If the column sizes are not uniform then I
    cannot be sure that I'm moving the JViewport to
    display the correct JTable column(s).
    I thing the GUI is a great design for what must be
    done. And thank you for your help and comments.That still sounds pretty klunky. I don't see any user navigating around a 480 column table. They click in your histogram to go to a column, they click somewhere or do keyboard navigation and the display scrolls them a few columns/rows away... they are now lost in a sea of cells and have to go back to the histogram again to try and get back, etc. Having delt with similar situations, there are better ways. Read the last two days dilbert cartoons carefully. :-)
    But anyway...
    You don't have to have all the columns the same width to make a column visible in the viewport. You can just get the appropriate column's rect by either of these methods:Rectangle r = myTable.getTableHeader().getHeaderRect( col );
    Rectangle r = myTable.getCellRect( row, col, true );And then tell the viewport to make sure that rect is visible:myViewport.scrollRectToVisible( r );Much easier than hacking around with custom column resizing logic.

  • JTable - Updating TableModel does not increase num rows until column resize

    Hi all,
    I'm developing an application which includes a JTable with a TableModel implementation.
    The table model consists of 2 columns - Property and Value.
    * A table model for server properties
    * Created on 09-May-2005
    package com.jc.editor.model;
    import java.util.Iterator;
    import java.util.LinkedHashMap;
    import javax.swing.table.AbstractTableModel;
    * @author crossja
    public class PropertyTableModel extends AbstractTableModel {
      private String[] columnNames = {"Property", "Value"};
      private String[][] data;
      public PropertyTableModel(LinkedHashMap p_propertiesMap)
        setProperties(p_propertiesMap);
      public void setProperties(LinkedHashMap p_propertiesMap){
        data = new String[p_propertiesMap.size()][2];
        // Insert data from hashmap into data array
        Iterator props_iterator = p_propertiesMap.keySet().iterator();
        String curr_property;
        for(int i=0 ; props_iterator.hasNext(); i++){
          curr_property = (String)props_iterator.next();
          data[0] = curr_property;
    data[i][1] = (String)p_propertiesMap.get(curr_property);
    * Get the number of columns in the table model
    public int getColumnCount() {
    return columnNames.length;
    } // getColumnCount()
    * Get the column name at the given index
    public String getColumnName(int p_index){
    return columnNames[p_index];
    }// getColumnName(int)
    * Get the number of rows in the table model
    public int getRowCount() {
    return data.length;
    } // getRowCount()
    public Object getValueAt(int rowIndex, int columnIndex) {
    return data[rowIndex][columnIndex];
    } // getValueAt()
    } // end PropertyTableModel
    When another method updates the table model, it calls the setProperties method. However, this doesn't update the JTable fully until I resize a column in the table. Here's the strange behaviour:
    If the table initially has 2 rows, and the new table model has 5 rows, then the two visible rows in the table JTable will be updated to the new values, but the three new rows do not appear. However, if I resize a column, they suddenly appear, and with the correct values.
    I've tried calling repaint on the JTable, and JPanel, but that doesn't solve the problem.
    The JTable is displayed within a JScrollPane.
    Regards,
    Jim

    change the following two lines in your program...
          data[0] = curr_property;
    data[i][1] = (String)p_propertiesMap.get(curr_property);
    // double-check the row & col indices are correct
    setValueAt(curr_property, i, 0);
    setValueAt(curr_(String)p_propertiesMap.get(curr_property), i, 1);

  • Jtable without column header

    Hi all,
    I have searched for jtable without column header... and if it´s possible how can I make?
    thanks

    Override JTable#configureEnclosingScrollPane() to do nothing or remove the table header manually ( jScrollPane.setColumnHeader(null) ) after you added the table to the scroll pane.

  • JTable - make first column not scrollable

    I like to know using one JTable and JScrollPane to make it generically not scroll for the first column.
    Do you set the viewport to start at the second column, if so how?
    Thanks
    Abraham

    Heres a test to run with the renderers and editors for fixed table columns
    See source for FixedColumnScrollPane
    // import libraries required, no space
    public class SimpleTable extends JFrame {
       private static class MyTableCellRenderer extends DefaultTableCellRenderer {
          public MyTableCellRenderer() {
             super();
             setOpaque(true);
             noFocusBorder = new EmptyBorder(1, 2, 1, 2);
             setBorder(noFocusBorder);
          public Component getTableCellRendererComponent(JTable table, Object value,
                                                         boolean isSelected, boolean hasFocus,
                                                         int row, int col) {
             JLabel renderer = (JLabel) super.getTableCellRendererComponent(table, value,
                   isSelected, hasFocus, row, col);
             String cellValue = value.toString();
             renderer.setHorizontalAlignment(SwingConstants.LEFT);
             renderer.setToolTipText(cellValue);
             String headerValue = table.getColumnModel().getColumn(col).getHeaderValue().toString();
             // Use header value for renderers when splitting table columns, dont check by column index
             if (headerValue.length() == 0) {
                renderer.setText("Row " + (row+1));
             if (cellValue.startsWith("a")) {
                renderer.setForeground(Color.blue);
             } else if (cellValue.startsWith("b")) {
                renderer.setForeground(Color.green);
             } else if (cellValue.startsWith("c")) {
                renderer.setForeground(Color.blue);
             } else if (cellValue.startsWith("d")) {
                renderer.setForeground(Color.magenta);
             } else if (cellValue.startsWith("e")) {
                renderer.setForeground(Color.ORANGE);
             return this;
       public class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor {
          private JComponent component = null;
          public Component getTableCellEditorComponent(JTable table, Object value,
                                                       boolean isSelected,
                                                       int row, int col) {
             this.component = new JTextField(value.toString());
             return this.component;
          public Object getCellEditorValue() {
             if (component instanceof JTextComponent) {
                String text = ((JTextComponent) component).getText();
                return text;
             return null;
       public SimpleTable() {
          super("Simple JTable Test");
          setSize(300, 200);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          TableModel mainTableModel = new AbstractTableModel() {
             private static final int ROWS = 1000;
             String colValues[] = {"", "a", "b", "c", "d", "e"};
             String data[][] = new String[ROWS][colValues.length];
             String headers[] = {"", "Column 1", "Column 2", "Column 3", "Column 4", "Column 5"};
             public int getColumnCount() {
                return colValues.length;
             public int getRowCount() {
                return ROWS;
             public String getColumnName(int col) {
                return headers[col];
             // Synthesize some entries using the data values & the row #
             public Object getValueAt(int row, int col) {
                String val = data[row][col];
                if (val == null) {
                   val = colValues[col] + row;
                   data[row][col] = val;
                return val;
             public void setValueAt(Object value, int row, int col) {
                data[row][col] = value.toString();
             public Class getColumnClass(int column) {
                return getValueAt(0, column).getClass();
             public boolean isCellEditable(int row, int col) {
                return (col > 0);
          JTable mainTable = new JTable(mainTableModel);
          TableColumnModel mainColumnModel = mainTable.getColumnModel();
          for (int i = 0; i < mainColumnModel.getColumnCount(); i++) {
             TableColumn tableColumn = mainColumnModel.getColumn(i);
             tableColumn.setCellRenderer(new MyTableCellRenderer());
             tableColumn.setCellEditor(new MyTableCellEditor());
          FixedColumnScrollPane fixedColumnScrollPane
                = new FixedColumnScrollPane(mainTable, 1);
          setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
          JLabel fixedLabel = new JLabel("Fixed Column Table");
          fixedLabel.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 11));
          getContentPane().add(fixedLabel);
          getContentPane().add(fixedColumnScrollPane);
       public static void main(String args[]) {
          SimpleTable st = new SimpleTable();
          st.setVisible(true);
    }

  • JTable without JScrollPane behavior crippled

    I want column width of JTable t1 goes parallel with the width resizing on
    JTable t2. If tables are put in JScrollPanes, this has no problem. But if I put
    those tables in simpler container, which is JPanel in this case, t2 shows a
    funny behavior -- with user's mouse operation on t2 column, their width
    never changes but t1 column width changes properly. Could I have
    succeeded in communicating the funniness with these sentences?
    Please try this code and give cause and solution if you could:
    import java.awt.*;
    import java.beans.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    public class TableColumnWidthResize{
      JFrame frame;
      JTable t1, t2;
      TableColumnModel tcm1, tcm2;
      Enumeration columns1, columns2;
      String[] t1h = {"Road", "Length", "City"};
      String[][] t1c
       = {{"NW2", "800", "Dora"},
         {"Iban", "600", "Weiho"},
         {"ENE2", "500","Porso"}};
      String[] t2h = {"Flower", "Curse", "Priest"};
      String[][] t2c
        = {{"Fang", "7.00", "EggChar"},
          {"Shaoma", "5.00", "ScaCra"},
          {"Jiao", "4.00", "PorCabb"}};
      public TableColumnWidthResize(){
        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container con = frame.getContentPane();
        con.setLayout(new GridLayout(2, 1));
        t1 = new JTable(t1c, t1h); //target table -- 'resized from t2'
        t2 = new JTable(t2c, t2h); //source table -- 'initiate resize'
        t1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        t2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        /* you can compare two methods of table placement*/
        useScrollPane(t1, t2, con); //works fine
    //    nouseScrollPane(t1, t2, con); //resize behavior weird
        frame.pack();
        frame.setVisible(true);
        tcm1 = t1.getColumnModel();
        tcm2 = t2.getColumnModel();
        columns2 = tcm2.getColumns(); // all columns of t2
        TableColumnListener tcl = new TableColumnListener();
        while (columns2.hasMoreElements()){
          TableColumn tc = (TableColumn)(columns2.nextElement());
          tc.addPropertyChangeListener(tcl);
      class TableColumnListener implements PropertyChangeListener{
        // achieve 'interlocking-column-resizing' from t2 to t1
        public void propertyChange(PropertyChangeEvent pce){
          TableColumn tc = (TableColumn)(pce.getSource());
          int i = tc.getModelIndex();
          tcm1.getColumn(i).setPreferredWidth(tc.getWidth());
      void useScrollPane(JTable ta, JTable tb, Container c){
        JScrollPane jsc1 = new JScrollPane(ta);
        ta.setPreferredScrollableViewportSize(new Dimension(225, 50));
        JScrollPane jsc2 = new JScrollPane(tb);
        tb.setPreferredScrollableViewportSize(new Dimension(225, 50));
        c.add(jsc1); c.add(jsc2);
      void nouseScrollPane(JTable ta, JTable tb, Container c){
        JPanel p1 = new JPanel(); JPanel p2 = new JPanel();
        p1.setLayout(new BorderLayout());
        p2.setLayout(new BorderLayout());
        p1.add(ta.getTableHeader(), BorderLayout.PAGE_START);
        p2.add(tb.getTableHeader(), BorderLayout.PAGE_START);
        p1.add(ta, BorderLayout.CENTER);
        p2.add(tb, BorderLayout.CENTER);   
        c.add(p1); c.add(p2);
      public static void main(String[] args){
        new TableColumnWidthResize();
    }

    Hey hiwa,
    I don't see anything mysterious going on. If you think about it, how many components can we resize at run-time/dynamically with a mouse - none, except for the columns in a JTable, Frames and Dialogs. Note the latter two are top level and answer to no-one (except the screen i guess).
    If you have ever implemented a component that can be 'dragged' and manipulated by the mouse, have you ever done so outside, that is, not using a JScrollPane? I doubt it.
    I do not think it has anything to do with mouse precision. Maybe you are just experiencing undefined behaviour, unreliable behaviour. I imagine the Swing team didn't bother themselves with a usage scenario that would yield lesser results for a simple task. Using AUTO_RESIZE_OFF and requesting more room than the Container has to offer may upset that containers LayoutManager i.e. their algorithms may contain code that will shrink child components to fit, or nab space from sibling components.
    Basically, in my experience, how ever long it takes me to realise it, when Swing goes on the blink it is usually a programming error.
    BTW, did my suggestion work ok?
    Sorry if I come across forceful. I'm glad I read and tested your code - the synchronization effect will be very useful.
    Warm regards,
    Darren

  • Option to Copy (without headers) gone??

    I am using SSMS 2008 R2 (Version 10.50.4000.0). As of this week, I can no longer copy my results without headers. My settings are Results to grid and I have double-checked that under Tools -> options my Query Results, Results to Grid does
    NOT have the option "Include column headers when copying or saving the results" checked.
    When I right click in my result set, I still see both options; "Copy" and "Copy with Headers". No matter which when I use, I get column headers when I paste into Excel. I do this every week and this is the first time this has happened.
    (I did get updates this morning.)
    Is this happening to anyone else??

    Hi,
    According to your description, I do a test in SQL Server 2008 R2 (version 10.50.4000.0), everything works well. I copy my query results without headers, and paste the data into Excel successfully. Below is my setting of Tools/options in SQL Server. Please
    restart the SQL Server Management Studio (SSMS) after you change the following settings.
    Thanks,
    Lydia Zhang

  • How to open iWork 08 blank file without headers?

    Hi, couldn't find an answer for my question on the forms, so here it goes...
    Is there a way to set Numbers '08 to open new files without Column and Row Headers? I know how to remove and/or delete them, but this is not what I'm looking for. I want to start all new documents without the headers. Is it possible?
    Thanks, Vlad.

    Hello Vlad,
    Whenever you begin a new document, you are opening a Template. Often we use the blank template provided with Numbers, but we are free to make our own templates without Headers and with any settings we find convenient. Prepare a document that is just the way you would always like to begin your work and then File > Save as Template.
    When you want to start a new document, File > New from Template > My Templates, choose your special template.
    Regards,
    Jerry

  • How can you use the Keyboard for a JComboBox within a JTable without F2

    I am brand new to Java and I can't seem to figure this out. I have a JTable with 4 columns. The first column is a jCheckBox which is working fine. The other three are JComboBoxes. They work fine when you click them and select from the list, but our end users only want to navigate with the keyboard. They want to be able to tab to the column and just start typing the first letter of the item that they want to choose from the list and have that pop up the list and scroll to the first item in the list that starts with the letter the typed. Does anyone know how to do this? I have been playing with this for a week now and I can't seem to make it work. Please help. Below is the code for my table. Any help would be appreciated greatly. Thanks,
    Lisa
         private void LoadSTCGTable(){
         //Connect to database
            try {
                    connection = ConnecttoDB.connect();
                    // Tell me why I couldn't connect
                } catch (ClassNotFoundException ex) {
                    ex.printStackTrace();
                } catch (SQLException ex) {
                    ex.printStackTrace();
         try {
                // Get listing of Squad Types
                tblSTCG.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {new Boolean(false), null, null, null},
                new String [] {
                    "SELECT", "SQUAD TYPE", "SQUAD CLASS", "SQUAD GROUP"
              //Add Checkbox column
               tblSTCG.getColumnModel().getColumn(0).setCellEditor(tblSTCG.getDefaultEditor(Boolean.class));
               tblSTCG.getColumnModel().getColumn(0).setCellRenderer(tblSTCG.getDefaultRenderer(Boolean.class));      
               tblSTCG.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
               Whichquerytoread = 1;
               GetSql();
               sql = textfileinfo;
               stmt = connection.createStatement();
               rs = stmt.executeQuery(sql);
               md = rs.getMetaData();
               typelist = new ArrayList();
               // Loop Through Results
               typelist.add(new PairedDescriptionCodeDesc("",""));
               while (rs.next())
                  int i = 1;
                 typelist.add( new PairedDescriptionCodeDesc(rs.getString(2),rs.getString(1)));
              s1 = new TreeSet(typelist);
              typelist = new ArrayList(s1);
              AllTypeList = new PairedDescriptionCodeDesc[typelist.size()];
              for (int i = 0; i<typelist.size(); i++)
                 AllTypeList=(PairedDescriptionCodeDesc)typelist.get(i);
    rs.close();
    catch (SQLException ex) {
    ex.printStackTrace();
    Vector typedata = new Vector();
    for (int i=0;i<typelist.size();i++)
    typedata.addElement((PairedDescriptionCodeDesc)typelist.get(i));
    cmboType = new JComboBox();
    cmboType.setModel(new DefaultComboBoxModel(typedata));
    cmboType.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    cmboType = new JComboBox(AllTypeList);
    cmboType.setBorder(BorderFactory.createEmptyBorder());
    squadcol = tblSTCG.getColumnModel().getColumn(1);
    DefaultCellEditor cmboTypeEditor = new DefaultCellEditor(cmboType);
    cmboTypeEditor.addCellEditorListener(new NewRowCellEditorListener(tblSTCG));
    squadcol.setCellEditor(cmboTypeEditor);
    try {
    // Get listing of Squad Class
    Whichquerytoread = 2;
    GetSql();
    sql = textfileinfo;
    stmt = connection.createStatement();
    rs = stmt.executeQuery(sql);
    md = rs.getMetaData();
    classlist = new ArrayList();
    // Loop Through Results
    classlist.add(new PairedDescriptionCodeDesc("",""));
    while (rs.next())
    classlist.add(new PairedDescriptionCodeDesc(rs.getString(2),rs.getString(1)));
    s1 = new TreeSet(classlist);
    classlist = new ArrayList(s1);
    AllClassList = new PairedDescriptionCodeDesc[classlist.size()];
    for (int i = 1; i<classlist.size(); i++)
    AllClassList[i]=(PairedDescriptionCodeDesc)classlist.get(i);
    rs.close();
    catch (SQLException ex) {
    ex.printStackTrace();
    Vector classdata = new Vector();
    for (int i=0;i<classlist.size();i++)
    classdata.addElement((PairedDescriptionCodeDesc)classlist.get(i));
    cmboClass = new JComboBox();
    cmboClass.setModel(new DefaultComboBoxModel(classdata));
    cmboClass = new JComboBox(AllClassList);
    classcol = tblSTCG.getColumnModel().getColumn(2);
    DefaultCellEditor cmboClassEditor = new DefaultCellEditor(cmboClass);
    classcol.setCellEditor(new DefaultCellEditor(cmboClass));
    cmboClassEditor.addCellEditorListener(new NewRowCellEditorListener(tblSTCG));
    try {
    // Get listing of Squad Group
    Whichquerytoread = 3;
    GetSql();
    sql = textfileinfo;
    stmt = connection.createStatement();
    rs = stmt.executeQuery(sql);
    md = rs.getMetaData();
    grouplist = new ArrayList();
    // Loop Through Results
    grouplist.add(new PairedDescriptionCodeDesc("",""));
    while (rs.next())
    int i = 0;
    grouplist.add( new PairedDescriptionCodeDesc(rs.getString(2), rs.getString(1)));
    s1 = new TreeSet(grouplist);
    grouplist = new ArrayList(s1);
    AllGroupList = new PairedDescriptionCodeDesc[grouplist.size()];
    for (int i = 0; i<grouplist.size(); i++)
    AllGroupList[i]=(PairedDescriptionCodeDesc)grouplist.get(i);
    rs.close();
    catch (SQLException ex) {
    ex.printStackTrace();
    Vector groupdata = new Vector();
    for (int i=0;i<grouplist.size();i++)
    groupdata.addElement((PairedDescriptionCodeDesc)grouplist.get(i));
    cmboGroup = new JComboBox();
    cmboGroup.setModel(new DefaultComboBoxModel(groupdata));
    cmboGroup = new JComboBox(AllGroupList);
    groupcol = tblSTCG.getColumnModel().getColumn(3);
    DefaultCellEditor cmboEditor = new DefaultCellEditor(cmboGroup);
    cmboEditor.addCellEditorListener(new NewRowCellEditorListener(tblSTCG));
    groupcol.setCellEditor(cmboEditor);
    tblSTCG.setShowHorizontalLines(false);
    tblSTCG.setShowVerticalLines(false);
    TableColumnModel columnModel = tblSTCG.getColumnModel();
    TableColumn column;
    tblSTCG.getColumnModel().getColumn(0).setPreferredWidth(5);
    tblSTCG.getColumnModel().getColumn(1).setPreferredWidth(100);
    tblSTCG.getColumnModel().getColumn(2).setPreferredWidth(100);
    tblSTCG.getColumnModel().getColumn(3).setPreferredWidth(100);
    scpSTCG.setViewportView(tblSTCG);
    private class NewRowCellEditorListener implements CellEditorListener
    JTable editingTable;
    public NewRowCellEditorListener(JTable table)
    editingTable = table;
    public void editingStopped(ChangeEvent e)
    if(editingTable.getRowCount() == editingTable.getSelectedRow() + 1)
    ((DefaultTableModel)editingTable.getModel()).addRow(new Object [] {null, null, null, null});
    public void editingCanceled(ChangeEvent e)

    Final Cut Pro menu > Audio / Video Settings... (Cmd Opt Q) will show you al the various presets currently loaded
    Sequence menu > Settings... (Cmd Zero) will show you the current sequence's settings
    Edit > Item Properties > Format... (Cmd 9) will show you the selected clip's properties

  • Add JTable Row Headers At The End Of The Rows(At Right)?

    hi all
    i got this example for adding JTable Row Headers,but it adds the headers at the left(beginning of the row)
    and i want to add the headers at the end of the row(at right),any ideas how to do that?
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.AbstractListModel;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListCellRenderer;
    import javax.swing.ListModel;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    * @version 1.0 11/09/98
    class RowHeaderRenderer extends JLabel implements ListCellRenderer {
      RowHeaderRenderer(JTable table) {
        JTableHeader header = table.getTableHeader();
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setHorizontalAlignment(CENTER);
        setForeground(header.getForeground());
        setBackground(header.getBackground());
        setFont(header.getFont());
      public Component getListCellRendererComponent(JList list, Object value,
          int index, boolean isSelected, boolean cellHasFocus) {
        setText((value == null) ? "" : value.toString());
        return this;
    class RowHeaderExample extends JFrame {
      public RowHeaderExample() {
        super("Row Header Example");
        setSize(370, 150);
        ListModel lm = new AbstractListModel() {
          String headers[] = { "Row1", "Row2", "Row3", "Row4"};
          public int getSize() {
            return headers.length;
          public Object getElementAt(int index) {
            return headers[index];
        DefaultTableModel dm = new DefaultTableModel(lm.getSize(), 4);
        JTable table = new JTable(dm);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setRowHeight(18);
        JList rowHeader = new JList(lm);
        rowHeader.setFixedCellWidth(50);
        rowHeader.setFixedCellHeight(18);
        rowHeader.setCellRenderer(new RowHeaderRenderer(table));
        JScrollPane scroll = new JScrollPane(table);
        scroll.setRowHeaderView(rowHeader);
        getContentPane().add(scroll, BorderLayout.CENTER);
      public static void main(String[] args) {
        RowHeaderExample frame = new RowHeaderExample();
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
        frame.setVisible(true);
    }

    fixed by:
    list.setBackground(table.getTableHeader().getBackground());here's the full code:
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.ComponentOrientation;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.DefaultListModel;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListCellRenderer;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    * @version 1.0 11/09/98
    class RowHeaderRenderer extends JLabel implements ListCellRenderer {
      JTable table;
      RowHeaderRenderer(JTable table) {
        this.table = table;
        JTableHeader header = table.getTableHeader();
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setHorizontalAlignment(CENTER);
        setForeground(header.getForeground());
        setBackground(header.getBackground());
        setFont(header.getFont());
      public Component getListCellRendererComponent(JList list, Object value,
          int index, boolean isSelected, boolean cellHasFocus) {
        list.setBackground(table.getTableHeader().getBackground());
        setText((value == null) ? "" : value.toString());
        return this;
    class RowHeaderExample extends JFrame {
      public RowHeaderExample() {
        super("Row Header Example");
        setSize(370, 150);
        setLocationRelativeTo(null);
        DefaultListModel lstModel = new DefaultListModel();
        lstModel.addElement("Row 1");
        lstModel.addElement("Row 2");
        lstModel.addElement("Row 3");
        lstModel.addElement("Row 4");
        DefaultTableModel dm = new DefaultTableModel(lstModel.getSize(), 4);
        JTable table = new JTable(dm);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setRowHeight(18);
        JList rowHeader = new JList(lstModel);
        rowHeader.setFixedCellWidth(50);
        rowHeader.setFixedCellHeight(18);
        rowHeader.setCellRenderer(new RowHeaderRenderer(table));
        JScrollPane scroll = new JScrollPane(table);
        scroll.setRowHeaderView(rowHeader);
        table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        getContentPane().add(scroll, BorderLayout.CENTER);
      public static void main(String[] args) {
        RowHeaderExample frame = new RowHeaderExample();
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
        frame.setVisible(true);
    }

  • Finder Column Resize Field is missing - whitespace instead

    Hi,
    I noticed that the little column resize field on the vertical dividers in Finder (the one with the two vertical lines on it) has gone missing. There's now a whitespace instead, which I can still use to resize the column. So the problem is more of a cosmetic nature, yet those dangling scrollbars look a bit irritating.
    here's a screenshot of it: www.sfu.ca/~msteger/scr1.png
    Somewhat related, the gradient in Safari's title bar is not continuous but has a sudden step just above the bookmarks. www.sfu.ca/~msteger/scr2.png
    I don't recall any particular event after which this issue came up. I recently installed the 10.6.2 Combo Update but that didn't make any difference.
    Thanks for any suggestions.
    Mike

    Hmm... There are some simple troubleshooting steps you can take.
    Be sure you drive is not overly full. Rule of thumb would be over 85%.
    Create a new User go to System Preferences >> Accounts >> "+" (make it an admin acct) and test the apps in this new account, if they work the problem is isolated to your User and not systemwide.
    If the issue is limited to your user account try starting up Safe Mode (It will take more time to startup in Safe Mode because it runs a directory check.)
    If your apps functions correctly that way, go to System Preferences >> Accounts >> Login Items, and remove them. Boot normally and test. If not go to ~(yourHome)/Library/Contextual Menu Items and move whatever is there to the desktop. Then do the same with /Library/Contextual Menu Items. Lastly, try moving ~(yourHome)/Library/Fonts to your desktop and restarting.
    Log out/in or restart, if that sorts it start putting items back one at a time until you find the culprit.
    If the issue is systemwide then, you may be able to repair this with the The 10.6.2 Combo Update This is a fuller install, as opposed to an incremental "delta" update so it should overwrite any files that are damaged or missing. It does not matter if you have applied it before.
    Remember to Verify Disk before update and repair permissions after update from /Applications/Utilities/Disk Utility.
    -mj

Maybe you are looking for

  • ADVICE ON IMPORTING LARGE QUANTITY OF PHOTOS FROM CAMERA

    I am planning a European trip this summer and anticipate taking a very large number of photos.  I have purchased a 16GB memory card as I was advised this was simpler than attempting to upload to a cloud server or IPAD while travelling.  My question i

  • Host: suppress DOS command window

    hi, i have programmed the host command statement in a *.pll for running a batch file my.pll host('c:\test\my.bat'); my.bat rwrun60.exe report=c:\test.rdf desname=c:\xyz\01.pdf ... rwrun60.exe report=c:\test.rdf desname=c:\xyz\02.pdf ... Windows opens

  • Language Conversion in Smartform

    Hi Gurus, I have a little problem with a Smartform... I need to show differents languages in the same Form, depends on the client language. Can somebody help me? Many thanks for all Rakesh R

  • How to do the page menu effect

    I am  a newcomer I would like to create my menu with a rollover effect just like on this page.    http://designova.net/simple/index-animated.html

  • Gradient background not aligned correctly

    i have some photo pages and the gradient background is not aligned correctly - generally below where I want it - like on iweb shows correctly - but on web - it is below the navbar..... .... how do I control this? is this something to do with layout?