Problem with JTable checkbox

In my table I have a column of checkboxes. If user clicks any checkbox, the program will first check for some condition and pop out a warning dialog saying that "the action will change the current mode. are you sure you want to continue?". If user select "yes", some action are taken and the checkbox should be selected. Now the problem is that after user select "yes", the checkbox is not selected. (Same as when you press your mouse at a checkbox and then drag it out the checkbox cell, the actions are taken but the checkbox is not selected.)
The code for the cell editor is as follows:
public Component getTableCellEditorComponent(JTable table, Object value,
           boolean isSelected, int row, int column) {
         if (value instanceof ComboString) { // ComboString
           flg = COMBO;
           String str = (value == null) ? "" : value.toString();
           System.out.println("+++++++ " + row+" : "+column+"  flg: "+flg);
           return cellEditors[COMBO].getTableCellEditorComponent(table, str,
               isSelected, row, column);
         else if (value instanceof Boolean) {                    
           flg = BOOLEAN;
           Boolean check = Boolean.getBoolean(value.toString());
                      // promptContinue returns true for continue, false for return; inside it a dialog box is popped for user selection "continue or not"
                      if(!promptContinue()){
                            return null;
           return cellEditors[BOOLEAN].getTableCellEditorComponent(table,
               value, isSelected, row, column);
         

Thanks. But my problem is not with stopping the editor, but with continuing the editor. Following is the code of getCellEditorValue()
public Object getCellEditorValue() {
         switch (flg) {
         case COMBO:
           String str = (String) comboBox.getSelectedItem();
           return new ComboString(str);
         case BOOLEAN:
         case STRING:
           return cellEditors[flg].getCellEditorValue();
         default:
           return null;
            }I am not very sure whether it is the problem of cell editor or cell renderer, because it seems the code for continue condition is actually executed which is supposed to make the checkbox checked, but the result turns to be that the checkbox is not checked.

Similar Messages

  • Selection Problem with JTable

    Hello,
    i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
    I preffered the style from MS Outlook Express where you can select the email accounts to edit.
    It is a table like this:
    Account name  |   Type  |   ...
    --------------|---------|---------------------
    Hotmail       |   POP3  |
    GMX           |   IMAP  |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
    Please help me!
    Thanks.
    Warlock

    Maybe this will helpimport java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        String[] head = {"One", "Two"};
        String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
        JTable jt = new JTable(data, head);
        jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.setCellSelectionEnabled(true);
        jt.setRowSelectionAllowed(false);
        jt.setColumnSelectionAllowed(false);
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    class MyTableSelectionModel extends DefaultListSelectionModel {
      public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(0, 0);
    }

  • Another problem with JTable

    Hi,
    I have encountered a problem with JTable, i am trying to display some 15 columns and their values , one of the columns value is null, then the JTable is not displaying its value from this column(which is with null value) onwards.
    Can anybody assiss me in this matter.
    Regards
    khiz_eng

    I don't know If I can fix your problem, but
    I know just that it works on my PC.... It's very very
    slow... I don't know how to insert PageSetUp option... I have to study the problem.....
    However I don't think it's a hard problem....
    I want ask to you if you have found some problems when you are in Editing mode in a cell.....
    in the jdk1.2 version I could save while was in editing mode using the editingStopped method.
    It permit to update all data .... also the data in the cell I was editing.
    in the jdk 1.3 if I use this method It doesn't work properly... It maybe destroy the content object in the Cell..... because I'm able to print all the table except the editing cell (it throw an exception...)
    What's changed????
    I don't know...
    Can u help me?

  • A problem with JTable

    Hi !
    I have a problem with JTable - would like to use this component as a simple list of rows taken from a database : don't want to be able select or set a focus to a column - want only to be able select and set focus to a row ( just like in the menus). How to disable "focusability" for a cell with JTable ? Could You help me ?
    thnx in advance

    The Border is changed by the renderer, depending on whether the cell has focus or not. So you will need to create custom renderers without a Border. Something like:
    class NoBorderRenderer extends DefaultTableCellRenderer
         public Component getTableCellRendererComponent(
              JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
              super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
              setBorder(null);
              return this;
    }

  • Problem with JTable and JPanel

    Hi,
    I'm having problems with a JTable in a JPanel. The code is basicly as follows:
    public class mainFrame extends JFrame
            public mainFrame()
                    //A menu is implemeted giving rise to the following actions:
                    public void actionPerformed(ActionEvent evt)
                            String arg = evt.getActionCommand();
                            if(arg.equals("Sit1"))
                            //cells, columnNames are initiated correctly
                            JTable table = new JTable(cells,columnNames);
                            JPanel holdingPanel = new JPanel();
                            holdingPanel.setLayout( new BorderLayout() );
                            JScrollPane scrollPane = new JScrollPane(holdingPanel);
                            holdingPanel.setBackground(Color.white);
                            holdingPanel.add(table,BorderLayout.CENTER);
                            add(scrollPane, "Center");
                            if(arg.equals("Sit2"))
                                    if(scrollPane !=null)
                                            remove(scrollPane);validate();System.out.println("ScrollPane");
                                    if(holdingPanel !=null)
                                            remove(holdingPanel);
                                    if(table !=null)
                                            remove(table);table.setVisible(false);System.out.println("table");
                            //Put other things on the holdingPanel....
            private JScrollPane scrollPane;
            private JPanel holdingPanel;
            private JTable table;
    }The problem is that the table isn't removed. When you choose another situation ( say Sit2), at first the table apparently is gone, but when you press with the mouse in the area it appeared earlier, it appears again. How do I succesfully remove the table from the panel? Removing the panel doesn't seem to be enough. Help is much appreciated...
    Best regards
    Schwartz

    If you reuse the panel and scroll pane throughout the application,
    instantiate them in the constructor, not in an often-called event
    handler. In the event handler, you only do add/remove of the table
    on to the panel. You can't remove the table from the container
    which does not directly contain it.
    if (arg.equals("Sit2")){
      holdingPanel.remove(table);
      holdingPanel.revalidate();
      holdingPanel.repaint(); //sometimes necessary
    }

  • Problem with Matrix/Checkbox/Datasource

    Hi, i have a problem with a Matrix.
    There are 3 Columns on this Matrix, one of those is a Checkbox. I fill the Columns with data, the Checkboxes where just added (no Checkbox is selected), the user has to select the value (Checkbox)he want's to by hand.
    After i filled the Matrix i can see all the data on the Form, it's OK, but then i loose all entries after SBO is doing some work. There where shown only the empty rows and the checkboxes.
    I guess it has something to do with the databinding. My problem is that i don't have the Data for this form on a db-table. I fill in the matrix the result of some querys. It looks like i need at least a DB-Field for the checkboxes, otherwise there are not working (not selectable)
    Somebody knows a solution how i can keep the Data in the Matrix after SBO is doing some work? What could be the reason that i loose the data after filling it in the Matrix? Is there an easy way?
    Thanks Andreas

    Almost every item on a form need a datasource... If the item reprecents some data in a table the databinding must be a dbds... If the data does not reflect any data in a table (Calulated value, user-decision, ect.) a userdatasource need to be created...
    Add a userdatasource
    oForm.DataSources.UserDataSources.Add(UID,type,length);
    Databind to DBDS
    col.DataBind.SetBound(true,”TABLE”,”FIELD”);
    Databind to UDS
    col.DataBind.SetBound(true,””,UID);

  • Problem with clicking CheckBox eswith eCATT recording

    Hi All,
    Iam using SAP GUI 640,ECC500.
    Am trying to set some default setting in Finance Transaction FB00 with clicking some checkboxes.
    So,After i recorded with clicking checkboxes,For testing that recording i unchecked the check boxes manually and executed the script .but i dont see any boxes checked after i execute the script.I checked in the debugging mode,it is showing in the screen that the checkboxes are checked.but at the end of the script when i open the transaction manually the checkboxes are unchecked.
    Is their anything to be cautious when recording Checkboxes.If so please pass your comments.
    Thanks in Advance,
    Sarapu

    HI Rajender,
    Are you using TCD or SAPGUI for the recording.
    In either cases make sure that you are passing value "<b>X</b>" to the checboxes in your recording or passing value "<b>X</b>" to the variable you have assigned to the checkboxes.
    In general you donot need to take any special care for handling Check boxes and they are identified with both TCD and SAPGUI as part of the standard eCATTS.
    Hope this solves your problem. DO get back to me if you still have the same problem.
    -Harsha
    PS: Award points if this answers your questions.

  • Scrollbar problem with JTable.

    Hi,
    I have 45 columns in a JTable. Please remember this is customize, we can change the number of columns dynamically, at max they can be 2 columns.
    i was having a problem with display the columns names in my Frame. I posted at http://forum.java.sun.com/thread.jspa?threadID=5167358&messageID=9641265#9641265
    I got the solution. Thanks for that.
    But as i said these columns are customized.
    when i am having 2 columns in my JTable, table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF ); is behaving differently, it's not occupying the complete JFrame. Lots of space is left out beside these 2 columns.
    When i comment this line, then those 2 columns are occupying my complete Frame.
    these two colmns should occupy my complete Frame and if i select 45 columns i should get scroll bar at botton with complete column NAMES.
    Hope i am clear.
    My Snippet
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.util.*;
    public class SimpleTable extends JPanel {
        private boolean DEBUG = false;
        public SimpleTable() {
            super(new BorderLayout());
                        String[][] values = new String[10][];
            String[] columnNames = {
                                                                                    "First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian","First Name","Last Name","Sport","# of Years","Vegetarian"
            Object[][] data = {
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)},
                {"Mary", "Campione",
                 "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new Integer(10), new Boolean(false)}
                        DefaultTableModel defaulttablemodel = new DefaultTableModel(data,columnNames);
            final JTable table = new JTable(defaulttablemodel)
                 public boolean isCellEditable(int row,int column)
                                  return false;
                        table.setPreferredScrollableViewportSize(new Dimension(500, 70));
                        //table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
                        JScrollPane scrollPane = new JScrollPane(table);
                        add(scrollPane);
        private static void createAndShowGUI() {
            JFrame frame = new JFrame("SimpleTable");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            SimpleTable newContentPane = new SimpleTable();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    Thank You camickr, it's serving my purpose.
    Just for a clarrification :
    table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
    table.setAutoscrolls(false);without using these lines also my purpose is serving.....then y do we need above two lines of code. r they necessary
    i mean, this snippet is sufficient.
    public boolean getScrollableTracksViewportWidth()
         return getPreferredSize().width < getParent().getWidth();
    }

  • Problems with JTable Renderer

    I have a problem with applying a custom renderer. I know the renderer works so thats not the problem. If I do like this:
    DefaultTableModel aDefaultTableModel = new DefaultTableModel(data, columnNames);
    it works. But if I do like this:
    DefaultTableModel aDefaultTableModel;
    aDefaultTableModel.setDataVector(data, columNames);
    is doesn't, why?

    I think maybe it's not the renderer at all. It may be my custom TableModel thats causing problems. Now this doesn't work:
    private JTable aTable;
    private CustomTableModel aTableModel;
    public MyProgram() {
    aTableModel = new CustomTableModel();
    aTable = new JTable(aTableModel);
    aTableModel.setData(data, columnNames);
    private class CustomTableModel {
    private String[] columnNames = null;
    private Object[][] data = null;
    public CustomTableModel() {
    columnNames = new String[0];
    data = new Object[0][0];
    ... snip
    public void setData(Object[][] data, String[] columnNames) {
    this.data = data;
    this.columnNames = columnNames;
    fireTableDataChanged();
    ... snip
    Now, why doesn't that setData method work??

  • Problems with JTable

    Hi All,
    I am facing some problems in JTable :
    1) How to remove all lines between cells, neither i should have column nor row lines....there should not be any lines between any cell at all.
    2) If i select a perticular cell, complete row is getting selected with a blue background, that should not happen at all.....row should not get select....
    3) How to make a cell non editable.
    Regards,
    Ravi

    1) Read the API. Check out the set??? methods until you fine what you want
    2) Read the API. Check out the methods that deal with row and column selection
    3) Override isCellEditable(...) method of JTable or DefaultTableModel

  • Problem with JTable in a JScrollPane

    Hello all,
    I have a problem using JTable, that the number of columns is very big,
    and the JScrollPane shows only vertical ScrollBar, isn't there any way to show a horizontal ScrollBar, to show the other columns without being bunched.
    Thanks in advance.

    table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );

  • Problem with JTable with JCheckBox as Header

    Hi,
    We have a JCheckBox as JTable Header. And respective data in that column also check boxes. For data check boxes, just i am sending Boolean object to object[][] data array. I am getting check Boxes as data components.
    For Header, i have create a TableRender object which is returning JCheckBox.
    Here my problem is,
    1) When i select a Header check box, all the check boxes are getting selected.
    2) Now we can reselect an data Check Box. When i reselect any data checkBox, Header CheckBox should be reselected. This is not happening. I was tried lot. Can any body give a solution to solve this problem.
    Please .... Please ...
    Thanks
    Mohan

    just call this method with null param on the JTable
    table.setTableHeader(null);
    cheers
    krishna

  • Problem with a checkbox -pls help

    I have a tabular form with checkbox for all rows and I want to update all the rows where checkbox is checked .
    select
    APEX_ITEM.CHECKBOX(1,ID) as " ",
    "ID",
    "ID" ID_DISPLAY,
    other records ...
    from
    below the code
    declare
    vROW number;
    begin
    if :REQUEST = 'SUBMIT' then
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
    vROW := TO_NUMBER(APEX_APPLICATION.G_F01(i));
    update table ... where id = vROW
    END LOOP;
    end if;
    end;
    when testing I observed that vROW has ID value even I did not tick any checkbox .
    How can I check if checkbox is ticked in this case ???
    thanks
    solo

    "In order to do that, you don't need to use a checkbox. Building a tabular form on your table, using APEX wizard, will give you an updatable form, in which you can update any of the displaying cells, and submitting the form will update them automatically. The standard tabular form uses the checkboxes only for deleting records."
    I'm affraid it is not possible. I have a complex view and I need a PL/SQL code to update the modified rows in another table ..
    "If you want to construct your tabular form yourself, and use checkboxes as part of a self-developed update process, you should use the "SQL Query (updatable report)" for your report type. This type of report allows you to use a built-in component called "Row Selector" – in the tasks box of the report attribute tab. This is a built-in checkbox component, which the report generator can use with your other report component, and synchronize all of them with the APEX_APPLICATION.G_F arrays, in order to avoid the problem Scott pointed out to you. "
    It's incredible .
    When I do Page->Tabular Form->Query ( update only ) the checkbox does not appear .
    IF I do Page->Tabular Form->Query ( update/insert/delete ) the checkbox the checkbox appear .
    ... I spend a lot of time becuase of this ...... ( I don't want to say )
    Now , my tabular form has 67 columns .. how can I manage all this columns values ( if remember well ..limit is 50 ) . Any , tricks ???
    what's wrong with this code ?
    declare
    v number;
    pk varchar2(50);
    c1 varchar2(50);
    c2 varchar2(50);
    c9 varchar2(50);
    begin
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
    v := to_number(APEX_APPLICATION.G_F01(i));
    pk := APEX_APPLICATION.G_F02(v);
    c1 := APEX_APPLICATION.G_F03(v);
    c9 := APEX_APPLICATION.G_F04(v);
    insert into test_1 values ( pk );
    insert into test_1 values ( c1 );
    insert into test_1 values ( c2 );
    insert into test_1 values ( c9 );
    END LOOP;
    end;
    I expected to have value of field 2 , field 3 , filed 4 , of the checked row .. but it's working .
    PS: I want to thank everybody who help me until now !
    solo

  • Problem with WHEN-CHECKBOX-CHANGED and ON-POPULATE-DETAILS

    I have a detail block with a relationship set up to a second block. In my first block, if I cause an error but the next action I take is to press a checkbox on another record, my error will display and the raise form trigger failure is triggered but the checkbox changes it's value and the cursor is displayed on the record with the error. I didn't want the checkbox to change if an error occurred. I tracked this through the trace and saw the on-populate-details is fired between the error and the when-checkbox-changed trigger. I went through debug and saw because of the erorr, the system will do a 'return' back to the sending action. I beleive this return is causing the when-checkbox-changed to fire. I'm just guessing here. I tried a similar action on another form without a relationship set up. That would eliminate the on-populate-details trigger. When I did a similar error, I got exactly what I was looking for. I caused the error but pressed the checkbox on another record. The error displayed but the checkbox did not change and the cursor returned to the error record. I need the record to have this relationship. Consequently, I need the on-populate-details trigger. Can anyone think of a solution? I'm currently on Forms 6I. We are going to forms 10G in the next few months. But I really need a solution on my current set up. Thanks.

    The getNextDatabankRecord() call is at the beginning of my run code. I use one step just for this line code.
    Code :
    public void run() throws Exception {
              beginStep("CHARGEMENT DES DONNEES SUIVANTES");
                   info("Chargement des prochaines données...");
                   getDatabank("NouvellesIA").getNextDatabankRecord();
              endStep();
    Stop the user after this step and goto the finish section should not be a problem...
    If I use the "When out of records" option, does it jump directly to the finish section ?
    Thanks,
    Benoit.

  • Urgent :problem with JTable on server program

    hi all i am writing an internet cafe timer.there is a table with the following colums:PC Name,IP Address,Status,Time Left, Time Login. ,on the server GUI. Whenever a client connects,a new row having the clients details is added to the table model, which reflects on the table.but if a client disconnects and reconnects, i want it to search thru the rows in the model, if there is a row with its information already,it shouls simply update the status column to "Reconnected", and not add an entirly new row, but if there is no row with its information, it can then add a new row with its information.
    Simply put, when a client connects,it should check
    1)if the table is empty, add a new row;
    2)else, check if tabe already has a row for the client, then update the row,else add a new row.
    its not working this way.it only works for the first client to connect,if other clients connect and disconnect,it still adds a new row, instaed of updating.
    the method doTable() in class ClientThread is what i use .please check it out and help me.
    i have a thread for each client.when a client connects, the server starts the thread and passes an instance of the server ui to the thread, so the threads acess the tablemodel thru this instance.
    Here is a simple run down of my classes
    CafeServer.java
    * @(#)CafeServer.java
    * @author obinna
    * @version 1.00 2007/3/10
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import java.sql.*;
    public class CafeServer {
         int serverPort;
         int serverLimit;
         //ServerSocket serversocket;
         private static int rownum = -1;
         private static Connection conn;
         private static CafeServerUI serverUI;
    * Creates a new instance of <code>CafeServer</code>.
    public CafeServer() {
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              conn = DriverManager.getConnection("jdbc:odbc:cafetimer","","");
              System.out.println("connection established with cafetimer database");
         }catch(Exception ex){
              JOptionPane.showMessageDialog(null,"Cannot find database");
              serverUI = new CafeServerUI( this,conn );
    public void closeServer(){
         System.exit(0);
    public static void main(String[] args) throws IOException{
    // TODO code application logic here
    try{
         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
         new CafeServer();
    catch(Exception ex){
         JOptionPane.showMessageDialog(null,"Could Not Find System Look and Feel.\nDefault L&F Loaded.");
         JFrame.setDefaultLookAndFeelDecorated(true);
    ServerSocket serverSocket = null;
    boolean listening = true;
    try {
    serverSocket = new ServerSocket(4444);
    } catch (IOException e) {
    System.err.println("Could not listen on port: 4444.");
    System.exit(-1);
    while (listening)
         new ClientThread(serverSocket.accept(),serverUI,conn).start();
    serverSocket.close();
    CafeServerUI.java
    //import statements.......................................
    public class CafeServerUI extends JFrame{
         public Vector pins = new Vector<String>();
         public DefaultTableModel model;
         public JTable table;
         protected JTextArea msgarea;
         protected JScrollPane scrpane;
         protected JPanel mainp,northp,leftp,rightupp,rightp;
         protected String[] colnames = {"Computer Name","IP Ad
    .............................................................constrctor follows
    ClientThread.java
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    public class ClientThread extends Thread{
         private Socket socket = null;
         private String pin, timeleft, pin3,timeleft3,tleft;
         private CafeServerUI csui = null;
         private Ticket ticket;
         private RemainingTime remtime;
         private String hostname,ipadd;
         private int rownum;
         private Connection conn;
         private Statement stmt;
         private ResultSet rs;
         private boolean found;
         public ObjectOutputStream outputStream;
         public ObjectInputStream inputStream;
         private Admin admin;
         boolean found2 = false;
         //private String[] newrow = new String[5];
    public ClientThread(Socket socket,CafeServerUI csui,Connection conn) {
              super("Client Thread");
              this.socket = socket;
              this.csui = csui;
              this.conn = conn;
              try{
                   stmt = this.conn.createStatement();
              }catch(Exception ex){
                   System.out.println(ex.getMessage() + " : " + ex);
              //this.rownum = rownum;
              hostname = this.socket.getInetAddress().getHostName();
              ipadd = this.socket.getInetAddress().getHostAddress();
              //sString[] newrow = {hostname,ipadd,"Connected","",""};
              doTable();
              //System.out.print("table row " + this.rownum);
              this.csui.oos.addElement(ClientThread.this);
    public void doTable(){
         String[] newrow = {hostname,ipadd,"Connected","",""};
         if(this.csui.model.getRowCount() == 0){
                   this.csui.model.addRow(newrow);
              }else{
                   for(int i=0; i < this.csui.model.getRowCount(); i++ ){
                        String hname = (String)this.csui.model.getValueAt(i,0);
                        if(hname.equalsIgnoreCase(hostname)){
                             this.csui.model.setValueAt("Re Connected",i,2);
                             break;
                        }else{
                             this.csui.model.addRow(newrow);
                             break;
    .....public void run()....

    In the UI is defined the InputMap/ActionMap pair to respond to keys. There is defined an action for ENTER. I have had the same problem, and the only thing that worked for me was to clear the actionMap, and reassign some keys to their original action, and some (e.g. ENTER, TAB) to my actions. This worked. With TAB is harder beacuse i guess it's deeper in the JVM implemented, but after a while i've managed to overwrite that too.

Maybe you are looking for