Jtable not scrollable

My app pops up a new JFrame in which I create and add a JPanel with a scrollable JTable as follows, however no vertical scrollbar appears.
frame.getContentPane().add(new ResultsPanel(),BorderLayout.CENTER);
frame.setVisible(true);
public class ResultsPanel extends JPanel {
    private void jbInit() throws Exception {
       JTable table = new JTable(data, cols);
       table.setPreferredSize(new Dimension(300,200));
       JScrollPane pane = new JScrollPane(table);
       this.add(pane);
}

Set the preferred size of the scrollpane, not the table.

Similar Messages

  • How to set special rows in jtable not selectable

    Hello programmers,
    anybody knows how to set special rows(p.E. row 0) in jtable not selectable.
    in advance thanks for your answers

    table = new JTable(...)
         public void changeSelection(int row, int column, boolean toggle, boolean extend)
              if (row == 0)
                   return;
              else
                   super.changeSelection(row, column, toggle, extend);
    };

  • How to create table that is not scrollable but shown as pages?

    Hi,
    I'm using JDeveloper 11.1.1.3 and working on Fusion Web application (ADF BC and ADF Faces).
    My client is demanding that tabels looks similar to those in ADF 10.1.3 with pages not scrollable.
    Is it possible to create such tables in Fusion? How would I do that?
    Best regards

    Yes I have tried that but only found answers that explaining tunning query of VO with how much records are going to be fetched at one time.
    I was thinking about option that you could actually chose to which page do you want to go and not with scroller.

  • Pop up windows are not scrollable?

    I have noticed that comparing to other browsers when there's a popup window, for example when using PrintFriendly to print the page I'm visiting - that popup window is not scrollable at all, making it impossible to decide what to print or not.
    Let me know if you'd like me to clarify the problem more or provide an example of an issue?

    Of course, if you wouldn't mind taking a look in Firefox and for example in Chrome this website's in development page - http://www.zarasplanet-v3.abbott-dev.com/about-us/
    Down the bottom, there are sharing icons, one of them being 'PrintFriendly'.
    If you click on that you should notice the difference in both mentioned browsers.
    Thanks.

  • 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 not working in JDK 1.6

    Hi
    In my Application I am using JTable for diplay and sorting purpose.Its properly working with JRE 1.5.
    But When i try to run the same application in JRE 1.6 the sorting functionality is not working properly.
    plz let me know what is the difference between running the application in JRE 1.5 and JRE 1.6?
    Thanks in Advance
    Kumar

    Pls. post the SSCCE program.

  • Timestamp in JTable not displaying correctly

    Hi,
    I have a JTable with a custom TableModel in which one of the columns is a timestamp. When I occupy the table, all the dates show up as 1970-jan-01. They change to their proper values if they are selected or if the column is resized. Simply doing a table.selectAll(); table.clearSelection(); or setting the preferred size of the column back and forth after the data is changed does not help.
    Any ideas?

    aznan wrote:
    Any ideas?If you need further help lets start by showing us your Short, Self Contained, Compilable Example or SSCCE so that we can determine the problem.

  • JTable not displaying column Heads

    The following JPanel was constructed using JBuilder 7 (a horrendous piece of software) and is in GridBagLayout. I'm attempting to display the contents of a table using JTable, and whilst it displays the rows it doesn't display the columnHeads! What am I doing wrong?
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.text.*;
    public class BeginTask extends JPanel implements ActionListener{
    private boolean dbupdated;
    private MainFrame main;
    private JLabel jLabel1 = new JLabel();
    private JLabel jLabel2 = new JLabel();
    private JTable jTable1 = new JTable();
    private JButton jButton1 = new JButton();
    private JButton jButton2 = new JButton();
    private GridBagLayout gridBagLayout1 = new GridBagLayout();
    private Connection connection;
    private String url = "jdbc:odbc:bapers";
    private String username = "";
    private String password = "";
    public BeginTask(MainFrame ma) throws SQLException{
    main = ma;
    logon();
    drawTable();
    try {
    jbInit();
    catch(Exception ex) {
    ex.printStackTrace();
    void jbInit() throws Exception {
    jLabel1.setFont(new java.awt.Font("Dialog", 1, 18));
    jLabel1.setText("Begin Task");
    this.setLayout(gridBagLayout1);
    jLabel2.setText("Select Task, and press OK.");
    jButton1.setText("OK");
    jButton2.setText("CANCEL");
    jButton1.addActionListener(this);
    jButton2.addActionListener(this);
    this.add(jButton1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(12, 117, 14, 0), 94, 8));
    this.add(jButton2, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(19, 43, 7, 119), 62, 8));
    this.add(jTable1, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0
    ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 25, 0, 22), 522, 281));
    this.add(jLabel2, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 181, 0, 226), 13, 6));
    this.add(jLabel1, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(29, 202, 0, 251), 19, 17));
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == jButton1) {
    if (dbupdated == true)
    JOptionPane.showMessageDialog(null, "The database has been updated to show that the user has begun the task selected.");
    else if (dbupdated == false)
    JOptionPane.showMessageDialog(null, "The database has not been updated.");
    else if (e.getSource() == jButton2) {
    BapProcMain bpm = new BapProcMain(main);
    main.redisplay(bpm);
    public void logon() {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection(url, username, password);
    catch (ClassNotFoundException cnfex) {
    System.err.println("Failed to load the JDBC/ODBC driver.");
    cnfex.printStackTrace();
    System.exit(1);
    catch (SQLException sqlex) {
    System.err.println("Unable to connect (SQL error)");
    sqlex.printStackTrace();
    public void logoff() {
    if (connection == null) return;
    try { connection.close(); }
    catch (SQLException sqlex) {
    System.err.println("Unable to disconnect (SQL error)");
    public void drawTable() {
    Statement stmt;
    ResultSet rset;
    try {
    String query = "SELECT * FROM SpecificTask";
    stmt = connection.createStatement();
    rset = stmt.executeQuery(query);
    displayResultSet(rset);
    stmt.close();
    catch (SQLException sqlex) {
    sqlex.printStackTrace();
    private void displayResultSet(ResultSet rs) throws SQLException {
    // position to first record
    boolean moreRecords = rs.next();
    // if there are no records, display a message
    if (! moreRecords){
    JOptionPane.showMessageDialog (this, "No Specific Tasks to begin.");
    return;
    Vector columnHeads = new Vector();
    Vector rows = new Vector();
    try {
    // get column heads
    ResultSetMetaData rsmd = rs.getMetaData();
    for (int i = 1; i <= rsmd.getColumnCount(); ++i)
    columnHeads.addElement (rsmd.getColumnName(i));
    //get row data
    // System.out.println("Got this far. Check getNextRow(...)");
    do { rows.addElement(getNextRow(rs, rsmd)); }
    while (rs.next());
    // display table with ResultSet contents
    jTable1 = new JTable (rows, columnHeads);
    JScrollPane scroller = new JScrollPane(jTable1);
    // validate();
    catch (SQLException sqlex) {
    sqlex.printStackTrace();
    private Vector getNextRow (ResultSet rs, ResultSetMetaData rsmd) throws SQLException {
    Vector currentRow = new Vector();
    for (int i = 1; i <= rsmd.getColumnCount(); ++ i)
    switch (rsmd.getColumnType(i)) {
    case Types.VARCHAR:
    currentRow.addElement(rs.getString(i));
    break;
    case Types.INTEGER:
    currentRow.addElement(new Long (rs.getLong(i) ) );
    break;
    default: System.out.println ("Type was: " +
    rsmd.getColumnTypeName(i));
    return currentRow;
    }

    The table header is shown automatically when you add the table to a scrollpane and then display the scrollpane in a panel. You use the following code to build the table/scrollpane:
    // display table with ResultSet contents
    jTable1 = new JTable (rows, columnHeads);
    JScrollPane scroller = new JScrollPane(jTable1);
    but, you add the table to your panel NOT the scrollpane:
    this.add(jTable1, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0
    ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 25, 0, 22), 522, 281));
    You should be adding the scrollpane to you panel.

  • JTable not showing up....

    Hello,
    I'm working with a JTable and having a slight problem. The JTable never shows up and I'm not sure why because when I debug it, data[][] has all the correct values. If someone could just point me in the right direction it would be greatly appreciated. Here is my code. It is self contained.
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    public class FillingHistoryTable extends JPanel {
        JTable fhTable;
        JScrollPane tableHolder;
        public static void main(String[] args){
            JFrame f = new JFrame("FHTABLE");
            f.getContentPane().add(new FillingHistoryTable());
            f.setVisible(true);
        public FillingHistoryTable(){
            initComponents();
        private void initComponents(){
            fhTableModel model = new fhTableModel();
            model.initModel();
            fhTable = new JTable(model);
            fhTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
            fhTable.setFillsViewportHeight(true);
            tableHolder = new JScrollPane(tableHolder);
            buildComponents();
        private void buildComponents(){
            this.add(tableHolder);
            this.setVisible(true);
        class fhTableModel extends DefaultTableModel {
            private String[] columnNames = {"Year", "Waste in tons"};
            private Object[][] data;
            private int currentYear = 2008;
            private int openYear = 1998;
            private int yearsOpen = currentYear - openYear;
            public void initModel(){
                data = new Object[yearsOpen + 1][2];
                for(int row = 0; row <= yearsOpen; row++){
                    for(int col = 0; col < 2; col++){
                        if (col == 0){
                            data[row][col] = currentYear;
                        else{
                            data[row][col] = 0;
                    currentYear = currentYear - 1;
    }

    are you adding your scrollpane to itself?
    tableHolder = new JScrollPane(tableHolder);Something tells me that you need to add your JTable to a JScrollPane at some point or another.

  • ImageIcon loaded to JTable not displaying

    Hi!
    I have a JTable with my own table model based on a Vector of "MyRowType" class, wich has three components:
    String name;
    ImageIcon image;
    String comment;
    I fill the table with all that components and then i save the vector who is holding the information. What happens, is that when I load the vector I've saved, everything is displayed, in the table, the right way, but not the imageIcon.
    I know the saving and the loading of the file is correct, and I know the image is in the vector. All the needed classes implement Serializable.
    Can anyone tell me what do I have to do to make the image display?

    Hi!
    The problem is solved! Didn't use any of the suggestions.
    Because:
    -JTable has a default renderer for image Icons;
    -The images were displaying in the table correctly when I inserted the rows;
    -The problem was when I saved the vector and then loaded it from a file;
    -Images were loading correctly but not displaying;
    What I did was:
    for (int i = 0; i<myVector.size(); i++) {
    MyRowType row = (MyRowType)(myVector.elementAt(i));
    myRowType.setImage(new ImageIcon(etapa.getImage().getImage()));
    Witch means:
    -After I load the vector from file;
    -I recreate all the imageIcons in each row of the vector.
    This way it works!
    If there is a better way of doing this, please let me know, else if i've got no other answer in the next five days, I'm going to give the Dukes to gregory.smith that I think, it gave the best answer, although I didn't use it.

  • JTable not working with tableChanged

    Hi,
    I have a JTable and I use table model. I also use TableCellRenderer. Now when i use tableChange() method the method getValueAt(int nRow, int nCol) in the model is called recursively forever. It starts with row zero to row 7 and then starts again. I have spent quite some time on it and have been unable to solve it. Please help me.
    thanks.
    class StockTableData extends AbstractTableModel {}
    table.setModel(m_data);
              for (int k = 0; k < m_data.getColumnCount(); k++ ) {     
                   System.out.println("k is " + k);
                   TableCellRenderer renderer = new TextAreaCellRenderer();
                   TableColumn column = new TableColumn(k,     StockTableData.m_columns[k].m_width, renderer, null);
                   table.addColumn(column);
    class TextAreaCellRenderer extends JTextArea implements TableCellRenderer {
         protected static Border m_noFocusBorder = new EmptyBorder(1, 1, 1, 1);
         protected static Border m_focusBorder = UIManager.getBorder("Table.focusCellHighlightBorder");
         public TextAreaCellRenderer() {
              setEditable(false);
              setLineWrap(true);
              setWrapStyleWord(true);
              setBorder(m_noFocusBorder);
         public Component getTableCellRendererComponent(JTable table,
              Object value, boolean isSelected, boolean hasFocus,
              int nRow, int nCol)
              if (value instanceof ColorData) {
                   ColorData cvalue = (ColorData)value;
                   setText(cvalue.m_data.toString());
                   setBackground(isSelected && !hasFocus ?
                        table.getSelectionBackground() : table.getBackground());
                   setForeground(isSelected && !hasFocus ?
                        table.getSelectionForeground() : cvalue.m_color);
                   setFont(table.getFont());
                   setBorder(hasFocus ? m_focusBorder : m_noFocusBorder);
                   // Adjust row's height
                   int width = table.getColumnModel().getColumn(nCol).getWidth();
                   setSize(width, 1000);
                   int rowHeight = getPreferredSize().height;
                   System.out.println("-- ");
                   if (table.getRowHeight(nRow) != rowHeight)
                        table.setRowHeight(nRow, rowHeight);
              return this;
         // To fix JDK bug
         public String getToolTipText(MouseEvent event) {
              return null;

    viravan, you are right. You really think so?
    but am not sure how and when to set the table row height.I do it in the setValueAt method by adding the following:
         public void setValueAt(Object value, int row, int column) {
            TableCellRenderer renderer=getCellRenderer(row,column);
            Component c=renderer.getTableCellRendererComponent(this,value,true,true,row,column);
            Dimension size=c.getPreferredSize();   // the height is what you want hereYou can see my program at http://www.aokabc.com
    ;o)
    V.V.
    PS: If it helps, don't forget the dukes

  • Makignone column in jtable NOT sortable

    hi
    i am using a TAbleSorter that sun provides to sort my table
    JTable importsTable=new JTable();
    MyTableModel model = new MyTableModel(handler.getImportableObjects());
    MyTableSorter sorter = new MyTableSorter(model, 0);
    sorter.setTableHeader(importsTable.getTableHeader());
    importsTable.setModel(sorter);
    MyTableModel is an AbstractTableModel that does soem custom stuff for me, nothign major.
    MyTableSorter is a table sorter that overrides isCellEditable. i am doing this so that i can make the one column iwnat non-sortable not editable. it is however nto working. help?
    thank you

    Well.. u r using an abstractTableModel.. so the cells r anyways not editable.. U ve made all the columns except the first one editable by overriding the isCellEditable method.. It s not working?? There must be some other prob.. Post some more relevant part of the code wit tags

  • JTable not getting latest data (unless mouse is focussed out of the cell)

    Hi,
    I am using JDK 1.4.2. I am having a basic problem of reading the data present in a JTable.
    JTable table = new JTable(9, 9);
    JButton solveButton = new JButton("Solve");
    solveButton.addActionListener(new DumpListener(table));The dump listener just dumps the data in the table.
    I have a 6*6 jtable where each value is a number. Now i focus the mouse on say square (1,2) and enter some data, then on square (5,5) and enter data say "4". There is a button in this panel, and which on being clicked, gets the table data and does some operation on it.
    Problem is when i use the "getValueAt" API, it gives correct data for square(1,2) but not for (5,5). This is because the mouse focus is still on square (5,5). However if i focus out of square (5,5) using my mouse (to some other random square) then the data comes up properly. Am i missing something here?
    I understand it is to do with the data model getting altered only when the mouse if focussed out? But this seems to be very trivial. Is there a way of getting the data out without focusing the mouse out of the cell?

    My solution uses a JFrame instead of a JApplet.
    But I think the effect is the same.
    First of all, the setVisible(true) should be put after all components are added.
    Secondly, when you retrieve data in the table, you'd synchronized() the model.
    Thirdly, I didn't find any problem when I call stopCellEditing(). Perhaps I'm using Java 5. Anyway, please try whether the following code works.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.TableModel;
    public class DummyFrame extends JFrame {
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        DummyFrame frame = new DummyFrame();
                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        frame.pack();
                        frame.setVisible(true);
         public DummyFrame() {
              JTable table = new JTable(9, 9);
              JButton data = new JButton("DATA");
              data.addActionListener(new SimpleButtonListener(table));
              JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              panel.add(table, BorderLayout.CENTER);
              panel.add(data, BorderLayout.SOUTH);
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(panel);
    class SimpleButtonListener implements ActionListener {
         JTable table;
         public SimpleButtonListener(JTable table) {
              this.table = table;
         public void actionPerformed(ActionEvent e) {
              synchronized (table) {
                   if (table.isEditing()) {
                        System.out.println("Is Editing!");
                        table.getCellEditor(table.getEditingRow(), table.getEditingColumn()).stopCellEditing();
              printArray(getData());
         String[][] getData() {
              synchronized (table) {
                   TableModel model = table.getModel();
                   synchronized (model) {
                        String[][] question = new String[9][9];
                        for (int i = 0; i < 9; i++) {
                             for (int j = 0; j < 9; j++) {
                                  question[i][j] = model.getValueAt(i,j) == null ? null : model.getValueAt(i,j).toString();
                        return question;
         void printArray(String[][] question) {
              int rows = question.length, columns = question[0].length;
              for (int i = 0; i < rows; i++) {
                   for (int j = 0; j < columns; j++) {
                        System.out.println("[" + i + ", " + j + "] -> "
                                  + question[i][j]);
    }And ... please don't forget to give me the 5 Duke dollars if it works.
    Thank you!
    Asuka Kenji (UserID = 289)
    (Duke Dollars Hunting now ...)

  • JComboBox in JTable not refresh automatically

    Hi folks,
    I put a JComboBox in a JTable cell as editor and with a GlassPane over the whole frame. Initially, I got lots of problems in dispatching events to JComboBox. Eventually, comboBox.setLightWeightPopupEnabled(false) seems solve many of them. However, after I called the said API to prevent light-weighted popup in JTable, when I move mouse on popup list or navigate with scroll bar, the UI does not refresh at all. I am pretty sure that all the models except UI has been updated because when I switch to another application and back, the UI repaints with expected appearance.
    Any idea ? Thanks a lot.!

    I think you might be doing this to yourself. This block here:
        private void tblContactFocusLost(java.awt.event.FocusEvent evt)
            if (tbl.isVisible())
                TableCellEditor tce = tbl.getCellEditor();
                if (tce != null) tce.stopCellEditing();
        }What purpose does it serve? It seems to muck up your table cell editing, including the combobox editing. If you comment out the tce.stopCellEditing() like so:
        private void tblContactFocusLost(java.awt.event.FocusEvent evt)
            if (tbl.isVisible())
                TableCellEditor tce = tbl.getCellEditor();
                if (tce != null) ; //tce.stopCellEditing();
        }Things work better.

  • JTable not  working

    Hi,
    Sorry to ask again about JTable but i can't understand what's wong.
    The code above is well compiled but when running the computer frose without displaying the frame(not responding).
    public class ex extends JFrame
      JTable table;
      JTable tab;
      public static void main(String[] args)
         new ex();
      public ex()
        Object[][] A=new Object[][]{{"1","2"},{"!","@"}};
        String[] Col=new String[]{"col1","col2"};
        JTable tab=new JTable(new MyTableModel(A,Col));
        JScrollPane tablePanel;
        table=tab;
        tablePanel=new JScrollPane(table);
        this.getContentPane().add(tablePanel);
         this.setSize(500,300);
        this.show();
    class MyTableModel extends DefaultTableModel
      public MyTableModel(Object[][] cells, Object[] headers)
        super(cells, headers);
      public Class getColumnClass(int col)
        return getValueAt(0, col).getClass();
      public boolean isCellEditable(int row, int col)
         return false;
    }Pls help.

    Hi there,
    Here is the code:
    The getTable() is called from another class dealing the connection.
    Also askApotelesmata() sends a message to the server, which call getTable and send him to the client.
    Server:
    class Apotelesmata
      static String[] Col;
      static Object[][] A;
      static int max=100;
      static int counter=0;
      public static void addApotelesma(Point p,ImageIcon e,ImageIcon a,boolean s)
        Col=new String[]{"������� ��������","��������","��������","�������� �����"};
        A=new Object[max][4];
        A[counter][0]=new String(p.x+"."+p.y);
        A[counter][1]=e;
        A[counter][2]=a;
        A[counter][3]=new Boolean(s);
        counter++;
      public static JTable getTable()
        JTable tab=new JTable(new MyTableModel(A,Col));
        return tab;
    class MyTableModel extends DefaultTableModel
      public MyTableModel(Object[][] cells, Object[] headers)
        super(cells, headers);
      public Class getColumnClass(int col)
        return getValueAt(0, col).getClass();
      public boolean isCellEditable(int row, int col)
         return false;
    }Client:
    class StudentStats extends JFrame implements ActionListener
      StudentConnect sc;
      JTable table;
      JScrollPane tablePanel=new JScrollPane();
      public StudentStats(StudentConnect sctmp)
        try
          sc=sctmp;
          JButton load=new JButton("���� ������� ����������");
          JButton save=new JButton("���������� ������� ����������");
          load.addActionListener(this);
          save.addActionListener(this);
          JPanel panel=new JPanel();
          panel.setLayout(new GridLayout(1,2));
          panel.add(load);
          panel.add(save);
          sc.askApotelesmata();   
          table=(JTable)sc.in.readObject();
          tablePanel=new JScrollPane(table);
          this.getContentPane().setLayout(new GridLayout(2,1));
          this.getContentPane().add(tablePanel);
          this.getContentPane().add(panel);
          this.setSize(500,300);
          this.show(); 
       catch(IOException e)
          new AlertWin(e.toString());
       catch(ClassNotFoundException e)
         new AlertWin(e.toString());
       catch(Exception e)
         new AlertWin(e.toString());
      public void actionPerformed(ActionEvent e)
        String comand=e.getActionCommand();
        if (comand.equals("���� ������� ����������"))
          this.dispose();
          new StudentStats(sc);
        else if (comand.equals("���������� ������� ����������"))
           try
             ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(new File(sc.studentName)));
             oos.writeObject(table);
           catch(IOException ee)
             new AlertWin(ee.toString());
    }Here is the problem:
    It is well compiled.
    It is working fine when the table has only 1 row.
    When the table has more than 1 row the client freezes.
    Pls, i need some help.
    Thanx in advance

Maybe you are looking for

  • Error in access with Essbase Studio Console

    We get error to connect with Essbase Studio Console. "children for Root. Reason: Unknown package name 'drillthrough'.Line = 1." It is a new installation. EPM 11.1.2.2

  • Can't use phone in europe

    Got HTC Incred 2 and is great.  Now in Europe for first time and email works but not calling.  Any suggestions?  Can't find number to contact verizon from Europe either. thanks

  • Problem with Listing of Articles in Assortment Management

    Hi, I am new to SAP IS Retail. In fact new to SAP itself. I was working on Assortment Management. I created my own Merch. Category  and created products under them.  In Assort.Management I progressed in following way [ as mentioned in the Best Practi

  • Beginning of implementation

    Hi all, For a couple of days ago, I have decided to use Flex for my senior project which talking about remote learning. I have tried to learn about Flex as I can that will help me when I face any troubles. But I have a couple of questions that I hope

  • CS6 Copy and Paste issues

    I've gotten this slight problem with dreamweaver CS6 where I can copy but can't paste, also the paste function doesn't appear in the context menu, not sure what i've done however any help will be appreciated.