Making a JTable autoscroll

I have a JTable with drag and drop functinality implemented. The problem is the user can only drag to a row that's visible on the screen. I know I have to implement the autoscroll interface in the java.awt.dnd package. How do you get the Insets for the JTable? Also how do you implement the autoscroll method? If there is another way to implement autoscrolling that would be helpful also.
Thanks,
William

I guess the method you need is "scrollbarsWhenNeede" or sth. like that, can't remember the exact name.

Similar Messages

  • Making a jtable row noneditable based on a value in a certain cell.

    I have a jTable (based on a database table) and one of the columns is OWNER. Is there a way to make an entire row noneditable based on the value in the OWNER column of the currently selected row?
    Here is the listener code that I have on the jTable. I want to be able to make the entire row noneditable if the value (of the currently selected row) of the OWNER column is "SYSTEM". If it is anything other than "SYSTEM" then the user would be able to change the values on the row.
    I can't override the isCellEditable method, because I only want the rows with the value of "SYSTEM" in the OWNER column to be noneditable.
    jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel rowSM = jTable2.getSelectionModel();
    rowSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) return;
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
    if (lsm.isSelectionEmpty()) {
    //no rows are selected
    } else {
    int selectedRow = lsm.getMinSelectionIndex();
    if (jTable2.getValueAt(selectedRow, 1).equals("SYSTEM"))
    System.out.println("Selected Row: " + selectedRow);
    System.out.println("Owner Value: " + jTable2.getValueAt(selectedRow, 1));
    //Make all cells in this row non-updateable???
    //Need code to make the currently selected row noneditable
    disableRetailerAddToList();
    } else
    enableRetailerAddToList();
    Any direction for this problem would be greatly appreciated.

    I've resolved it with some help by using the following:
    NOT ([<plCall_Back_Required_ITAG>]=LookupValue("OCC_CUST_LOV_SR_3", "Yes") AND [<stCall_Back_Number_ITAG>] IS NULL)

  • Making a jtable auto updates itself from a mysql table

    Pretty much what the title says. How can i auto update the jtable for every time my mysql table is updated in anyway? i am implementing this auto update function in my admin program which displays a list of users who are online etc. from the moment a user is offline/online or changes other details displayed in my jtable, i want it to auto update the jtable as soon as the actual mysql table has been updated with new data...
    I was thinking of re doing the whole jtable i made and create a thread for that table that has a infinite while loop that keeps repainting the jtable with the new updated data from a mysql table query eg select * from table and store the data into a resultset which then gets transferred into a vector. Load the vector into the jtbale and their ya go�.
    what you think of this approach? Is their a better way to do this?
    at the moment, as soon as my application opens, the jtable views all the data from my sql table, however if it doesnt auto updates itself, cheers

    i am implementing this auto update
    function in my admin program which displays a list of
    users who are online etc. from the moment a user is
    offline/online or changes other details displayed in
    my jtable, i want it to auto update the jtable as
    soon as the actual mysql table has been updated with
    new data...Well you can make some changes to make implementation easy
    Ex: Create a table to keep a log of the changes in the system the dmin program read the log and replicate the changes as specified in the log on the table model.
    When reading the log the admin program keep track of the sequence no of the last read log entry and it reads ony the entries which has larger seq numbers than the last read seq no
    I dont think that it is critical to make this to be cloase to real time. An Update once a 1 or 2 secs should be sufficient.

  • Making some JTable cells nonfocusable

    I have a JTable in which the TAB keys moves focus from cell to cell. Fine, but how can certain columns (or individual cells) be disabled from recieving focus ?? For "normal" JComponent-derived objects on a panel then I could call component.setFocusable(false); on the components I do not want to receive focus. What is the equivalent for a JTable cell given that it isn't a normal component: it is rendered via a TableRenderer ?

    I suppose you are using JDK 1.4 beacuse I am using it now. :-)
    I override the method:   protected boolean accept(Component aComponent) {
      } which is in the class LayoutFocusTraversalPolicy.

  • Making non-movable columns in a JTable

    I'm working on making a JTable and I don't want the user to be able to rearrange the columns. Does anyone know if this is possible and if so, how to do it? Thanks so much! :)
    Adrienne

    I'm working on making a JTable and I don't want the
    user to be able to rearrange the columns. Does anyone
    know if this is possible and if so, how to do it?
    Thanks so much! :)
    AdrienneYes it is possible.
    Reading in the 1.4 specification (this should also work in 1.2 and 1.3...)
    JTable aTable = new JTable();
    aTable.getTableHeader().setReorderingAllowed(false);Hope this helps...
    Nate

  • Nested sub-header (Groupable Header) JTable Example and JDK 1.5

    There is an old Nobuo Tamemasa example of making a JTable with grouped column headers at:
    http://www.codeguru.com/java/articles/124.shtml
    I made a couple of minor mods to get it to run under JDK 1.4. It works like a charm. If I run the same code under JDK 1.5.1, only the lowest level column headers are painted.
    Has anyone noticed this and come up with a fix?
    Here are the 4 classes (with my minor mods) required to run the test...
    package GroupableColumnTable;
    //File: ColumnGroup.java
    * (swing1.1beta3)
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
      * ColumnGroup
      * @version 1.0 10/20/98
      * @author Nobuo Tamemasa
    public class ColumnGroup {
      protected TableCellRenderer renderer;
      protected Vector v;
      protected String text;
      protected int margin=0;
      public ColumnGroup(String text) {
         this(null,text);
      public ColumnGroup(TableCellRenderer renderer,String text) {
         if (renderer == null) {
           this.renderer = new DefaultTableCellRenderer() {
             public Component getTableCellRendererComponent(JTable table, Object value,
                        boolean isSelected, boolean hasFocus, int row, int column) {
               JTableHeader header = table.getTableHeader();
               if (header != null) {
              setForeground(header.getForeground());
              setBackground(header.getBackground());
              setFont(header.getFont());
               setHorizontalAlignment(JLabel.CENTER);
               setText((value == null) ? "" : value.toString());
               setBorder(UIManager.getBorder("TableHeader.cellBorder"));
               return this;
         } else {
           this.renderer = renderer;
         this.text = text;
         v = new Vector();
       * @param obj    TableColumn or ColumnGroup
      public void add(Object obj) {
         if (obj == null) { return; }
         v.addElement(obj);
       * @param c    TableColumn
       * @param v    ColumnGroups
      public Vector getColumnGroups(TableColumn c, Vector g) {
         g.addElement(this);
         if (v.contains(c)) return g;     
         Enumeration enum = v.elements();
         while (enum.hasMoreElements()) {
           Object obj = enum.nextElement();
           if (obj instanceof ColumnGroup) {
             Vector groups =
               (Vector)((ColumnGroup)obj).getColumnGroups(c,(Vector)g.clone());
             if (groups != null) return groups;
         return null;
      public TableCellRenderer getHeaderRenderer() {
         return renderer;
      public void setHeaderRenderer(TableCellRenderer renderer) {
         if (renderer != null) {
           this.renderer = renderer;
      public Object getHeaderValue() {
         return text;
      public Dimension getSize(JTable table) {
         Component comp = renderer.getTableCellRendererComponent(
             table, getHeaderValue(), false, false,-1, -1);
         int height = comp.getPreferredSize().height;
         int width  = 0;
         Enumeration enum = v.elements();
         while (enum.hasMoreElements()) {
           Object obj = enum.nextElement();
           if (obj instanceof TableColumn) {
             TableColumn aColumn = (TableColumn)obj;
             width += aColumn.getWidth();
             width += margin;
           } else {
             width += ((ColumnGroup)obj).getSize(table).width;
         return new Dimension(width, height);
      public void setColumnMargin(int margin) {
         this.margin = margin;
         Enumeration enum = v.elements();
         while (enum.hasMoreElements()) {
           Object obj = enum.nextElement();
           if (obj instanceof ColumnGroup) {
             ((ColumnGroup)obj).setColumnMargin(margin);
    package GroupableColumnTable;
    //File: GroupableHeaderExample.java
    /* (swing1.1beta3)
    * |-----------------------------------------------------|
    * |     |     Name       |         Language          |
    * |     |-----------------|--------------------------|
    * |  SNo.     |      |       |        |       Others     |
    * |     |   1      |    2   | Native |-----------------|
    * |     |      |       |        |   2    |     3    |     
    * |-----------------------------------------------------|
    * |     |      |       |        |         |          |
    //package jp.gr.java_conf.tame.swing.examples;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    * @version 1.0 11/09/98
    public class GroupableHeaderExample extends JFrame {
      GroupableHeaderExample() {
         super( "Groupable Header Example" );
        DefaultTableModel dm = new DefaultTableModel();
         dm.setDataVector(new Object[][]{
           {"119","foo","bar","ja","ko","zh"},
           {"911","bar","foo","en","fr","pt"}},
         new
    Object[]{"SNo.","1","2","Native","2","3"});
        JTable table = new JTable( dm ) {
           protected JTableHeader createDefaultTableHeader() {
             return new GroupableTableHeader(columnModel);
         TableColumnModel cm = table.getColumnModel();
         ColumnGroup g_name = new ColumnGroup("Name");
         g_name.add(cm.getColumn(1));
         g_name.add(cm.getColumn(2));
         ColumnGroup g_lang = new ColumnGroup("Language");
         g_lang.add(cm.getColumn(3));
         ColumnGroup g_other = new ColumnGroup("Others");
         g_other.add(cm.getColumn(4));
         g_other.add(cm.getColumn(5));
         g_lang.add(g_other);
         GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
         header.addColumnGroup(g_name);
         header.addColumnGroup(g_lang);
         JScrollPane scroll = new JScrollPane( table );
         getContentPane().add( scroll );
         setSize( 400, 120 );  
      public static void main(String[] args) {
         GroupableHeaderExample frame = new GroupableHeaderExample();
         frame.addWindowListener( new WindowAdapter() {
           public void windowClosing( WindowEvent e ) {
             System.exit(0);
         frame.setVisible(true);
    package GroupableColumnTable;
    //File: GroupableTableHeader.java
    * (swing1.1beta3)
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
      * GroupableTableHeader
      * @version 1.0 10/20/98
      * @author Nobuo Tamemasa
    public class GroupableTableHeader extends JTableHeader {
      private static final String uiClassID = "GroupableTableHeaderUI";
      protected Vector columnGroups = null;
      public GroupableTableHeader(TableColumnModel model) {
         super(model);
         setUI(new GroupableTableHeaderUI());
         setReorderingAllowed(false);
      public void setReorderingAllowed(boolean b) {
         reorderingAllowed = false;
      public void addColumnGroup(ColumnGroup g) {
         if (columnGroups == null) {
           columnGroups = new Vector();
         columnGroups.addElement(g);
      public Enumeration getColumnGroups(TableColumn col) {
         if (columnGroups == null) return null;
         Enumeration enum = columnGroups.elements();
         while (enum.hasMoreElements()) {
           ColumnGroup cGroup = (ColumnGroup)enum.nextElement();
           Vector v_ret = (Vector)cGroup.getColumnGroups(col,new Vector());
           if (v_ret != null) {
             return v_ret.elements();
         return null;
      public void setColumnMargin() {
         if (columnGroups == null) return;
         int columnMargin = getColumnModel().getColumnMargin();
         Enumeration enum = columnGroups.elements();
         while (enum.hasMoreElements()) {
           ColumnGroup cGroup = (ColumnGroup)enum.nextElement();
           cGroup.setColumnMargin(columnMargin);
    package GroupableColumnTable;
    //File: GroupableTableHeaderUI.java
    * (swing1.1beta3)
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.plaf.basic.*;
    public class GroupableTableHeaderUI extends BasicTableHeaderUI {
      public void paint(Graphics g, JComponent c) {
         Rectangle clipBounds = g.getClipBounds();
         if (header.getColumnModel() == null) return;
         ((GroupableTableHeader)header).setColumnMargin();
         int column = 0;
         Dimension size = header.getSize();
         Rectangle cellRect  = new Rectangle(0, 0, size.width, size.height);
         Hashtable h = new Hashtable();
         int columnMargin = header.getColumnModel().getColumnMargin();
         Enumeration enumeration = header.getColumnModel().getColumns();
         while (enumeration.hasMoreElements()) {
           cellRect.height = size.height;
           cellRect.y       = 0;
           TableColumn aColumn = (TableColumn)enumeration.nextElement();
           Enumeration cGroups = ((GroupableTableHeader)header).getColumnGroups(aColumn);
           if (cGroups != null) {
             int groupHeight = 0;
             while (cGroups.hasMoreElements()) {
               ColumnGroup cGroup = (ColumnGroup)cGroups.nextElement();
               Rectangle groupRect = (Rectangle)h.get(cGroup);
               if (groupRect == null) {
              groupRect = new Rectangle(cellRect);
              Dimension d = cGroup.getSize(header.getTable());
              groupRect.width  = d.width;
              groupRect.height = d.height;     
              h.put(cGroup, groupRect);
               paintCell(g, groupRect, cGroup);
               groupHeight += groupRect.height;
               cellRect.height = size.height - groupHeight;
               cellRect.y      = groupHeight;
           cellRect.width = aColumn.getWidth() + columnMargin;
           if (cellRect.intersects(clipBounds)) {
             paintCell(g, cellRect, column);
           cellRect.x += cellRect.width;
           column++;
      private void paintCell(Graphics g, Rectangle cellRect, int columnIndex) {
         TableColumn aColumn = header.getColumnModel().getColumn(columnIndex);
         TableCellRenderer renderer = header.getDefaultRenderer ();
         Component component = renderer.getTableCellRendererComponent(
           header.getTable(), aColumn.getHeaderValue(),false, false, -1, columnIndex);
         rendererPane.add(component);
         rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y,
                            cellRect.width, cellRect.height, true);
      private void paintCell(Graphics g, Rectangle cellRect,ColumnGroup cGroup) {
         TableCellRenderer renderer = cGroup.getHeaderRenderer();
         Component component = renderer.getTableCellRendererComponent(
           header.getTable(), cGroup.getHeaderValue(),false, false, -1, -1);
         rendererPane.add(component);
         rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y,
                            cellRect.width, cellRect.height, true);
      private int getHeaderHeight() {
         int height = 0;
         TableColumnModel columnModel = header.getColumnModel();
         for(int column = 0; column < columnModel.getColumnCount(); column++) {
           TableColumn aColumn = columnModel.getColumn(column);
           TableCellRenderer renderer = header.getDefaultRenderer();
           Component comp = renderer.getTableCellRendererComponent(
             header.getTable(), aColumn.getHeaderValue(), false, false,-1, column);
           int cHeight = comp.getPreferredSize().height;
           Enumeration enum = ((GroupableTableHeader)header).getColumnGroups(aColumn);       
           if (enum != null) {
             while (enum.hasMoreElements()) {
               ColumnGroup cGroup = (ColumnGroup)enum.nextElement();
               cHeight += cGroup.getSize(header.getTable()).height;
           height = Math.max(height, cHeight);
         return height;
      private Dimension createHeaderSize(long width) {
         TableColumnModel columnModel = header.getColumnModel();
         width += columnModel.getColumnMargin() * columnModel.getColumnCount();
         if (width > Integer.MAX_VALUE) {
           width = Integer.MAX_VALUE;
         return new Dimension((int)width, getHeaderHeight());
      public Dimension getPreferredSize(JComponent c) {
         long width = 0;
         Enumeration enumeration = header.getColumnModel().getColumns();
         while (enumeration.hasMoreElements()) {
           TableColumn aColumn = (TableColumn)enumeration.nextElement();
           width = width + aColumn.getPreferredWidth();
         return createHeaderSize(width);
    }

    To anyone interested
    I came across this example today, and had the same problem too.
    The solution is very simple:
    The main problem is that GroupableTableHeader UI is set on its constructor, and it should be on the overriden method for that purpose.
    Here is the solution:
    1. remove
    setUI (new GroupableTableHeaderUI ());from the constructor
    2. override the method
    public void setUI (javax.swing.plaf.TableHeaderUI ui) {
    super.setUI (new GroupableTableHeaderUI ());
    }in this class.
    Now it is only need to get column width fixed because of borders in the header, as the example dun take this into account...
    Hope this helps, the same way as many other posts had help me to solve other problems;) and sorry for any spelling or grammar error.

  • Problem with CheckBox as table cell renderer

    i m making a JTable having three columns.
    i m also making a cellRenderer of my own MyRenderer
    extending Jcheckbox and implementing TableCellRenderer
    now i m setting MyRenderer as renderer for third column in my table and
    DefaultCellEditor with jcheckbox as parameter as cell editor for this column
    the code is like this--------------------
    ****making of JTable****
    table= new JTable(3,3);
    JScrollPane scrollPane = new JScrollPane(table);
    TableColumn tableColumn = table.getColumn("Male"); // let us suppose that this gives third column
    tableColumn.setCellRenderer(new MyRenderer ());
    tableColumn.setCellEditor(new DefaultCellEditor(new JCheckBox()));
    *****The classs implementing TableCellRenderer is given below******
    class MyRenderer extends JCheckBox implements TableCellRenderer{
    public MyRenderer(){
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus,
    int row, int column){
    if(value != null){
    Boolean booleanValue = (Boolean)value;
    setSelected(booleanValue.booleanValue());
    return this;
    ***********************************Problem****************************
    The problem is that when we click on the cell of that column first time,
    all the cells are selected.
    I don't want to use getColumnClass() method for this problem .
    If possible , please give some other solution.
    what is the problem behind this,If anybody can help us.
    Thanks in advance.

    I think the problem is, when the value is null the checkbox return with the selected state, b'coz u r
    returning the checkbox (as it is). so pl'z try with below code (ADDED).
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus,
    int row, int column){
    if(value != null){
    Boolean booleanValue = (Boolean)value;
    setSelected(booleanValue.booleanValue());
    else /// ADDED
    setSelected(false);/// ADDED
    return this;
    Nediaph.

  • Customized menu item

    For work I'm making a JTable bean that has Sort/Search/Filter functionality. I currently have achieved all three. Right clicking in a column brings up a popup menu where you can choose "Sort Ascending", "Sort Descending", "Search...", "Filter...". Search and filter currently bring up a separate window where you can type in a string and choose other advanced options.
    What I would like to do is in addition to the "Search..." and "Filter..." options on the JPopupMenu
    I want a MenuItem similar to what you would find in Microsoft Access's Filter option when you right click on the table. The MenuItem looks like a JLabel with text "Filter: " next to a blank JTextField.
    When I type in a string this will perform my search/filter using the string I typed.
    I have attempted to write my own MenuItem as a JavaBean using IBM's VisualAge For Java 4.0 without any success.
    Please Help!
    Joshua Doerring

    Hello Aruna,
    As far as I know you cannot remove the default items for the menu.
    Sophie

  • Making border of cell  invisible in JTable

    Hi i want to make border of cell invisible in JTable
    any help appreciated
    thanks in advance

    Create a renderer with no border - http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender .

  • Making some Custom Column Renderers for a JTable

    Hello People
    I've been playing around with a JTable by following the tutorial "How to Use Tables". (I am using netBeans 4.1 to "sculpt" my swing objects onto the nice palette in the IDE. I don't know if this has anything to do with the errors but, it seems like netBeans requires some Gui components be initialized via this abovementioned "palette")
    I believe that I need to somehow tell the JTable about what kinds of objects are in it so that it can render itself properly. I have a table set up with some default values in it
    ->Strings both Editable and Not-Editable
    -> Integers both Editable and Not-Editable
    -> Boolean rendered as a check box Editable
    So upon startup, my progarm renders the table correctly. I have a button to clear all of the elements in the table, which works fine. It is only when I switch to another window, then switch back to an empty table ... the JTable needs to redraw itself. This is when I'm getting the error:
    java.lang.NullPointerException
            at ElementHelp.PrimitiveManager$MyVectorTableModel.getColumnClass(PrimitiveManager.java:93)
            at javax.swing.JTable.getColumnClass(JTable.java:1752)
            at javax.swing.JTable.getCellRenderer(JTable.java:3700)
            at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1148)
            at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
            at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
            at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
            at javax.swing.JComponent.paintComponent(JComponent.java:541)
            at javax.swing.JComponent.paint(JComponent.java:808)
    ...blah blah more exception stack.....
           I think that because there are no elements in the table that the call to "getClass" for an element in the table returns a NullPointerException. I think I can avoid this via telling the JTable about the types of objects each column will contain. The tutorial suggests one of two solutions: (neither of which I can get to work)
    1) Use a class that extends the DefaultTableCellRenderer
    2) I should write somthing that ...extends JLabel and implements TableCellRenderer.... such as the tutorials ColorRenderer example. Which solution should I work out if I want my table to add/delete rows and be able to have a few cells edited. (It will never be restructured .. the column types won't change)
    Also, I've created my own TableModel for it ... a class that extends AbstractTableModel ... (although not declaired, it also implemnts/overwrites functions from the TableModel interface)
    Any suggestions on avoiding the abovementioned error?
    thanks and happy holidays to everyone

    I think that because there are no elements in the table that the call to "getClass" for an element in the table returns a NullPointerExceptionWell, if you have no data in the table then your TableModel should be returning "0" for the number of rows in the table and it won't be a problem.
    Also, I've created my own TableModel for it ... Why? Use the DefaultTableModel it supports String, Integers and Booleans without any need for custom coding.

  • Making JTable columns 2- n scrollable, not the first column, how?

    Id like for my JTable's first column to always be visible, and columns 2->n to be scrollable. The table also follows the sortable table model found from the swing examples...so if the user sorts any of the columns, all the other columns should sort accordingly.
    is there anyway i can separate the first column with the others, so that i can put them in their own scrollpanes (first column just scrolls up/down, and 2->n can scroll either way)?

    I only glanced at the example at the posted link... if memory servers, the trick was to create one JTable but with two different TableModels. To link the two models, you can simply make the getValueAt method in the fixed model call the getValueAt method of the non-fixed model. It's a bit tricky for beginner, but doable.
    ;o)
    V.V.

  • Making executable jar file the database using JTable

    How can i make an executable jar file if I will use a JTable on my database?Can you tell me how?
    Thank you !!

    dantte wrote:
    in truth, ur question is not clear enough. elaborate on what exactly it is u want, and what u ar truin to achieve.You don't seem to know enough English, let along Java, to be answering questions here.
    %

  • Making a single column horizontally scrollable for JTable

    Hello Everyone and thank you for reading my post.
    I have been trying for the last 3 days to make a single column horizontally scrollable on my JTable but for some reason I can not get it to work.
    I simplyfied my example to 2 columns and 5 rows where
    the rows in the first column have long text and it will have a horizontal scroll bar to scroll to the end of the text, similiar to split in Excel.
    The second column it doesn't matter
    Thanks again and have a great time,
    Al

    Friend you use table cell renderer for your problem.
    The solution would be like:
    1. Write cell renderer that displays textfield contained in scrollpane.
    2. Apply cell renderer to separate column where you require horizontal scroller.

  • Making a few rows in jTable uneditable

    Hi
    I have a simple problem :)
    1) i send some data, read from jTable, to sever and wait for reply
    2) i recieve data from server.. have to put that data to jtable in a specific column
    3) now i have to make the whole row in jtable uneditable
    1) and 2) are done
    i need help with only 3)
    Thanks

    ok
    Create a separate class in your netbeans project, this is the minimum requirements:
    import javax.swing.table.DefaultTableModel;
    import java.util.Vector;
    public class MyTableModel extends DefaultTableModel{
         private Vector<Integer> uneditableIndices;
         public MyTableModel()
            uneditableIndices = new Vector<Integer>();
         public boolean isCellEditable(int row, int column)
              for (int index : uneditableIndices)
                   if (row == index)
                        return false;
              return true;
         public void addUneditableRowIndex(int rowIndex)
              uneditableIndices.add(rowIndex);
         public int removeUneditableRowIndex(int rowIndex)
              uneditableIndices.remove(rowIndex);
    }I did not check the previous code, so it needs to be checked.
    In the Table Properties window select the previous class to be the default model for your table.
    then you can handle adding new indexes to the indexes vector while run-time.
    PLEASE FEED ME BACK.
    Good Luck.
    Ahmad Elsafty

  • Urgent: Making JTable detect a JButton event

    The GUI I'm working on displays a JTable along with an "Add" JButton. Upon launching the program there is already a list of things in the table. When "Add" is pressed a dialog box comes up. This dialog box has a JTextField, and the user enters the name of the new item s/he wishes to add. How can I "refresh" the table to add one more row, with the item added, when the "Confirm" button is pressed? The examples in the JTable tutorial seem to deal only with direct editing of cells. But this is sort of an indirect way of adding data...please help!
    James

    Work with the table's model (myTable.getModel()). In the default case, your working with an instance of DefaultTableModel. That class has all the modification methods you will need. Any changes to the model will cause the appropriate event to be thrown up to the table to cause it to change.

Maybe you are looking for

  • Error Messages in ESS

    Hi ESS Gurus, I have a query regarding the ESS - errors not displaying. In detail, Suppose if i am trying to apply leave from R/3 and if the quota is not available our r/3 system will throw an error saying that no sufficient quota.  In the same if i

  • How to modify a VAC in a standard FPM Application

    Hello All, I have a requirement in the project where I have to modify the standard SAP delivered FPM application. But this does not involve any creation of new webdynpro iview , but to modify a VAC in the application. It is related to essbensap.com,

  • When using "Database diff" selecting other schemas only for compare own objects are shown too!

    Hi! For comparing lot of objects I use a priviliged account z, which can read Schema a and b. In the compare dialog I set different from the Defaults following Options: - step 1 - option "Maintain" - step 3 - button "More" - select schema a - button

  • Onedrive (Skydrive) Sync issues through TMG

    We are having a ton of issues when using Onedrive (skydrive) to sync document libraries with our SharePoint 2013 server behind Forefront TMG. Users will randomly stop syncing (with no errors on skydrive), or files will just sit there trying to upload

  • Overwrite Local Copy Prompt

    Has anyone found a way to bypass the prompt which asks you every time you download a remote file whether you'd like to overwrite the local file?  Saw some issues posted a while ago, but none with fixes...Thanks!