No edit with JTable ?

Hi All!
How can I NOT allow user edit in JTable's cell ???
Which method to use or the way to do that!
Thank for you help!
Long Ng

In your abstract table model return false from
public boolean isCellEditable(int row, int col) {return false;}
rykk

Similar Messages

  • Hex editing with jtable

    hi all, i'm trying to make a hex editor using jtable... i saw camickr's version and was very impressed with it. i'm just not very good with java yet and so i'm having a little difficulty tracing the code. anyway, camickr, if you're reading this, or anybody who knows the answer.. i just have a question. how do i limit the cell's size to just 2 positions? and if ever the user just inputs 1 hex digit, the cell will automatically pad a "0" before it? thank you very much!

    Wow thats some old code I wrote years ago while attempting to learn something about Swing. Assuming me version is the same as the one you are looking at:
    how do i limit the cell's size to just 2 positions? This is the way the code works. Look at the HexDocument in the HexCellEditor class.
    The new way to do this would be to use a DocumentFilter. See the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter]Text Component Features for a woring example.
    and if ever the user just inputs 1 hex digit, the cell will automatically pad a "0" before it?This is the way the code works. When you tab to a different cell the old cell will be renderer with a leading "0" is necessary. This is done by the byteToHex(...) method found in the HexTableModel.
    1. how can i make a cell selected with just one click on that cell? The DefaultCellEditor has a setClickCountToStart(...) method. In my version that line of code is commented out the the HexTable class.
    the user clicks on the left/right keys, the appropriate cel, the one on the left/right of the current selected cell will be selected.I don't understand the question. Selection is indicated by a special border around the cell. In my application I make the entire cell a different color. So the left/right arrow keys are working.
    If you are saying that you want the cells to be automatically placed in "edit" mode, so you can see the flashing caret in the text field, then you need to do something like this.
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=606900

  • How to stop Auto Edit in JTable With JComboBox or JTextField

    Hi everybody
    I'm working with JTable and having 5 columns last 3 are hidden. First contains a Combobox Editor and Second contens JTextbox for editing. Every thing working fine except that whenever i clik the table it automatically opens its editor either JComboBox or JTextField for editing.
    I want to remove this and want to allow editing whenever user press Enter key on that column.
    I am using class
    FeeAmtEditor extends JTextField implements TableCellEditor for Textbox editing and class FeeTypeEditor extends JComboBox implements TableCellEditor for combobox edition
    another promblem that I need to press 'Escape' key to deactivate combo box or text box after entering data. This also i want to avoid.
    thanks in advance

    public void setComboBox(JComboBox cb, int columnindex)
            if(columnindex < 0 || columnindex >= getColumnCount())
                return;
            DefaultCellEditor dce = new DefaultCellEditor(cb);
            dce.setClickCountToStart(2);
            TableColumn column = jtable.getColumn(getColumnName(columnindex));
            column.setCellEditor(dce);
        }hope this help you..

  • 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);
    }

  • Any body please can solve my problem that iam facing with JTable

    Dear sir,
    Iam doing an educational product using Swing as front end in that
    iam using JTables. And back end iam using sqlserver. With jtable iam
    facing very serious problem the problem is actually iam entering the values
    in all the columns after that iam pressing the save button its not
    saving but if i click on any of the columns and try to save its saving.
    please anybody can solve my problem.Please if a piece of code is there ill
    be very thankful to you. my mailid is [email protected]
    regards
    surya

    The problem is, the cellEditor does not know that editing has stopped and therefore has not updated the model (where the data actually resides). When you click off the cell to another cell, the first cell knows it must be done editing because you are leaving it. If you click a button (or anything other than another cell), the cell being edited has no knowledge of this. You need to call stopCellEditing() on the cell editor and your problem will be solved. To do this, put the following method into your code and call it when you click the button to clear, save or whatever you need to do.
    public void ceaseEditing() {    int row = this.getEditingRow();
      int col = this.getEditingColumn();
      if (row != -1 && col != -1)
        this.getCellEditor(row,col).stopCellEditing(); 
      }Hope this helped...

  • Edit a JTable cell, click save button, value isn't stored in JTable

    I'm editing a JTable cell, just using default editor provided by JTable
    I click a save button elsewhere in my GUI
    The value typed into the cell so far isn't stored in the TableModel yet and so doesn't get saved.
    How can I make sure the value gets stored in the JTable in the above scenario when the JButton is pressed but before saving.
    Preferably I'd like the code with the JButton not to have to know about the JTable at all.
    Cheers,
    D

    I the forums 100s of times.Many thanks. If they had a decent search on this forum I might have found it as I did try.
    Come to think of it - Sun have completely fcukd up this forum.

  • JComboBox With JTable as Editor

    Hi everybody
    I'm working with JTable and having a ComboBox as first CellEditor. for that purpose i used following code
            cmbFeeType.setModel(new javax.swing.DefaultComboBoxModel(DefaultFee.FeeTypeItemList()));       
            DefaultCellEditor DCEFeeType = new DefaultCellEditor(cmbFeeType);
            DCEFeeType.setClickCountToStart(2);here DefaultFee.FeeTypeItemList is a vector returns array. This is working fine except that the ComboBox remains visible till I dobule clik on a column for editing. Then It becomes invisible and works fine.
    my JComboBox is a seperate Control on a JFrame I do not want to use
    Class FeeTypeEditor extends JComboBox implements TableCellEditoras a ComboBox editor for JTable
    Please Help Me.

    Hi
    I am giving u a sample code which simulate the error
    * TestJTable.java
    * Created on August 5, 2008, 11:05 AM
    package TestJTable;
    import javax.swing.DefaultCellEditor;
    import javax.swing.table.TableColumn;
    * @author  yogi
    public class TestJTable extends javax.swing.JFrame {
        /** Creates new form TestJTable */
        public TestJTable() {
            initComponents();
            DefaultCellEditor ColumnEditor = new DefaultCellEditor(jComboBox1);
            ColumnEditor.setClickCountToStart(2);
            TableColumn column = jTable1.getColumnModel().getColumn(0);
            column.setCellEditor(ColumnEditor);       
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            jScrollPane1 = new javax.swing.JScrollPane();
            jTable1 = new javax.swing.JTable();
            jComboBox1 = new javax.swing.JComboBox();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(null);
            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null}
                new String [] {
                    "Title 1", "Title 2", "Title 3", "Title 4"
            jScrollPane1.setViewportView(jTable1);
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(10, 10, 340, 180);
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            getContentPane().add(jComboBox1);
            jComboBox1.setBounds(180, 220, 120, 20);
            pack();
        }// </editor-fold>//GEN-END:initComponents
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    TestJTable TJTable = new TestJTable();
                    TJTable.setExtendedState(MAXIMIZED_BOTH);               
                    TJTable.setVisible(true);
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JComboBox jComboBox1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTable jTable1;
        // End of variables declaration//GEN-END:variables
    }Above code is generated by Netbeans IDE 6.0
    My promblem is that when you run the code the combobox JComboBox1 remains visible till i starts to edit the Table after once started editing it disappears.
    I want to avoid this
    thanks in advance

  • Issue with JTable

    Hi,
    I have a issue with JTable. I am reading an array and populating the cells in the JTable. After editing the cell values, on clicking a button, I update the value in to an array. The probelm is that after editing the value in the cell, if I don't use tab or enter key and move the focus away from the cell, I dont get the updated value when using the getValueAt method. Pleease let me know if there is any workaround for this behaviour.
    Thanks,
    Baskar N

    Just so you understand why that code snippit works, you have to stop or cancel editing before you can get the updated value of a cell.

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

  • Editing with Photoshop Elements 4.0

    I'm sure the problem and solution are simple, but I'm missing something. Here goes.
    I'm using iPhoto 6.0.2. Just installed and started using Adobe Photoshop Elements 4.0. Have been editing about 1,100 photos from a recent trip to Africa, which were imported from my Canon. Wanted more editing tools, so stopped editing with iPhoto and started using PS Elements. So I open a photo from the iPhoto library using PS Elements. Let's say I open a photo from Roll 100, and call it the Monkey Photo. I edit the Monkey Photo in PS Elements, and then save (not save as, but save, using the same Monkey Photo file name). It saves the photo, but not back into Roll 100, but into a new Roll created somehow by the operating system, let's call it Roll 110, found in both the Originals and Modified folders (which seems odd).
    Just like importing directly into iPhoto, when I save from PS Elements, a thumbnail is created, called a Preview. So now I have two thumbnails/previews, one from the original photo and one from the PS edited version.
    So now I go to the Africa album in iPhoto. I double click on the thumbnail on the main screen to open Monkey Photo and I see a big gray blob with a large exclamation point in the middle. I go to the iPhoto library folders, and see that Monkey Photo is no longer in Roll 100, but now in Roll 110. But somehow iPhoto is not recognizing Monkey Photo in Roll 110 (and it's no longer in Roll 100, so as far as iPhoto is concerned, it doesn't exist...but it does).
    So back to iPhoto. I click on View and switch to Roll view. Now I see Roll 100 and Roll 110. I click on Monkey Photo thumbnail in Roll 100, big gray blob, but click on Monkey Photo preview in Roll 110, and now I see Monkey Photo, in all his/her wonderfully edited colors from PS Elements.
    How do I get the thumbnail in the iPhoto Library and the Africa album to work to recognize that Monkey Photo is now in a new roll? I did the rebuild stuff (control-option on opening iPhoto, click on first three choices, wait 30 minutes....nothing happened). I noticed the ColorSync profile was missing, and reinstalled it. Still the big gray blob following thumbnail clicking. I did a war dance. Still nothing.
    What am I missing here? If you tell me that I have to recreate the Library, then the next noise you hear will be iPhoto disc being used as a frisbee and smashing into the neighbor's window.

    Robert:L
    Are you accessing that file from the Finder to open in PSE or are you using iPhoto's preferences to use PSE when you double click a thumbnail? The latter is the way it should be done. Then as long as you do not create a layered or otherwise edited file that required the psd extension nor change the file name, iPhoto will recognize the edit update the thumbnail accordingly. If you access those files from the Finder, open in PSE, edit and save, the thumbnail will not be updated but when you go to the edit mode you'll see the edits.
    Go to iPhoto's preferences and under the General section select PSE under the Open photo with: menu.

  • Anyone using ms sqlserver standard edition with XI 3.0

    wondering if anyone is successfully using ms sqlserver standard edition (not enterprise edition) with XI 3.0. I would like to set up a dev/test XI system and the standard sqlserver edition is less expensive than enterprise edition. I would like to confirm that it works ok first.
    thanks-

    Henry,
    I haven't tried but I think it will be successful with mssql server standard edition also. The following link gives the key difference between standard and enterprise edition.
    http://www.databasejournal.com/img/RS_servereditions_code.html
    Best of luck!
    regards,
    Felix

  • To install Remote Desktop Services User CAL on Windows Server 2008 R2 Enterprise Edition with SP1

    Dear Sir,
    Presently we have installed Windows Server 2008 R2 Enterprise Edition with SP 1. And now i would like to install Remote Desktop Services User CAL on this server. I have 25 digit product key of Windows Server
    2008 R2 Remote Desktop Services User CAL (20). Downloaded this product key from our MSDN Subscriptions.
    Kindly suggest me how to install (CAL server with product key that i have) and configure remote desktop services on my above existing server also how to point other server with my CAL server.
    Thanks

    Hi,
    1. Install Remote Desktop Session Host and Remote Desktop Licensing Role Services using Server Manager.
    2. Open RD Licensing Manager (licmgr.exe), Activate your server, then install your license
    3. In RD Session Host Configuration (tsconfig.msc), set the Licensing mode to Per User and Specify your RD Licensing server name (itself).  If you want you may configure these two settings via group policy setting instead.  The path of the
    group policy settings is Computer Configuration\ Administrative Templates\ Windows Components\ Remote Desktop Services\ Remote Desktop Session Host\ Licensing
    4. You may point other RDSH servers to your RD Licensing server using RD Session Host Configuration or via group policy as mentioned above.
    5. Optionally you may consider installing other Remote Desktop Role Services such as RD Gateway, RD Web Access, RD Connection Broker, etc.
    -TP

  • Mouselistner is not working with jtable in the browser

    Hi
    I am having a problem with jTable.
    I added a mouselistener to table header to sort table but when i run that applet from my netbean ide it works fine but when i run that applet in my browser it doesn't work, i have tested, its not even generate mouseclick event .Please help me guys.
    I call this function after calling initComponents() method of JApplet.
    public void setTableAction()
    //set mouselistener to sort table on click of table header
    final JTableHeader head= jTable1.getTableHeader();
    head.addMouseListener(new java.awt.event.MouseAdapter()
    public void mouseClicked(java.awt.event.MouseEvent evt)
    Vector data= ((DefaultTableModel)jTable1.getModel ()).getDataVector();
    sortTable(data, head.columnAtPoint(evt.getPoint()));
    //set action map to change the default action performed for enter key pressed
    InputMap imap = jTable1.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke tabKey = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    final Action oldAction= jTable1.getActionMap().get(imap.get(tabKey)); // get map to set enter key.
    imap.put(enterKey, "enter"); // set enter key
    Action newAction = new AbstractAction(){
    public void actionPerformed(ActionEvent e) {
    oldAction.actionPerformed(e);
    JTable table= (JTable)e.getSource();
    table.changeSelection(0,0,false,false);
    if(table.isCellEditable(0,0))
    String sTemp= (String)table.getValueAt(0,0);
    if(sTemp.length()>0) {
    if(bRenewItem)
    retrieveRcodeDetails("",sTemp);
    else
    processRCodeDetails(sTemp, e);
    }else
    table.editCellAt(0,0);
    jTable1.getActionMap().put("enter", newAction);
    jTable1.setPreferredScrollableViewportSize(jTable1.getPreferredSize());
    }

    Hi,
    I also am using the Bépo layout with an encrypted drive and encountered the same problem: the Return key does not work.
    It seems to work fine if you use the fr-bepo-latin9 keymap.
    # /etc/vconsole.conf
    KEYMAP=fr-bepo-latin9
    But I also looked at the files /usr/share/kbd/keymaps/i386/bepo/fr-bepo.map.gz and /usr/share/kbd/keymaps/i386/bepo/fr-bepo-latin9.map.gz (you can open gzipped files in vim directly). fr-bepo-latin9.map.gz defines keycode 28 (Return) but fr-bepo.map.gz does not.
    I modified fr-bepo.map.gz:
    # vim /usr/share/kbd/keymaps/i386/bepo/fr-bepo.map.gz # Append that line : "keycode 28 = Return".
    # mkinitcpio -p linux # Rebuild the initramfs.
    The Return key now works, but the Backspace (14, "Delete") and Shift (54) keys don’t work. I found that both the cf.map.gz (french canadian layout) and fr-bepo-latin9.map.gz files define those keycodes as well as other non-printing keys so I copied the following lines from fr-bepo-latin9.map.gz to fr-bepo.map.gz:
    keycode 1 = Escape Escape
    keycode 14 = Delete Delete
    keycode 15 = Tab Tab
    keycode 28 = Return
    keycode 29 = Control
    keycode 42 = Shift
    keycode 54 = Shift
    keycode 56 = Alt
    keycode 58 = Caps_Lock
    keycode 97 = Control
    It works! Don’t forget to rebuild the initramfs after you change the keymap file.
    # mkinitcpio -p linux
    I will send a message to the kbd and bépo projects mailing lists and report back.

  • Unable to edit document using "Edit with Word" option

    Hi All,
    i am having an issue with Office web apps. i am using SharePoint 2013 and Office web apps 2013. all the configurations have been done successfully. but i have a different kind of issue.
    i am able to open documents in browser
    i am able to edit document using " edit with word/excel web" option
    but i am unable to edit document using "edit with word/excel" option
    i have Office 2010 installed on my local machine.
    do we need to have MS office of 2013 version? or is there anything missing from configuration part.
    Please help me.
    Thank You,
    Bhaskar.

    Hi,
    According to your post, my understanding is that you could not use the "edit with word/excel" option.
    I had tested the issue with the Office 2010, the option worked well.
    You don’t need to install the Office 2013 to use this option.
    What did you mean “but i am unable to edit document using "edit with word/excel" option
    Did you mean the option gray out? Did the issue occur in other browsers?
    You can use compatibility mode to check whether it works.
    Open IE->Tools->Compatibility View Settings
    You can also add the site into Trusted sites.
    Open the IE->Internet Options->Security->Sites->add the site into the Websites, then check whether it works.
    What's more, you can also use other browsers to check whether it works, such as Firefox, Chrome.
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Questions about editing with io HD or Kona 3 cards

    My production company is switching from Avid to Final Cut Pro. I have a few editing system questions (not ingesting and outputting, just questions about systems for the actual editors - we will have mac pros with either kona 3 or io HD for ingest and outputs)
    1) Our editors work from home so they most likely will be using MacBook Pros - Intel Core 2 Duo 2.6GHz 4GB computers with eSata drives to work on uncompressed HD, will they be able to work more quickly in FCP if they are using the new Mac Pro 8-Core (2 Quad-Core 2.8GHz Intel Xeon) or will the mac book pro's be able to hold their own with editing hour long documentaries, uncompressed HD
    2) Will having an AJA Kona 3 (if we get the editors mac pros) or io HD (for the mac book pros) connected be a significant help to the editor's and their process, will it speed up their work, will it allow them to edit sequences without having to render clips of different formats? Or will they be just as well off without editing with the io HD?
    I'm just trying to get a better understanding of the necessity of the AJA hardware in terms of working with the editors to help them do what they have to do with projects that have been shot on many formats- DVCPro tapes, Aiptek cameras that create QTs and P2 footage.
    Thanks

    1. with the IoHD, laptops become OK working with ProRes and simply eSata setups. Without the Io, they can't view externally on a video monitor (a must in my book). It will not speed up rendering a ton, nor will it save renders of mixed formats. The idea is to get all source footage to ProRes with the Io, and then the Io also lifts the CPU from having to convert ProRes to something you can monitor externally on a video monitor, and record back to any tape format you want... all in real time.
    2. Kona 3's on Towers would run circles around render times on a Laptop... no matter what the codec, but the Kona does not really speed renders up. That's a function of the CPU and just how fast is it. (lots of CPU's at faster speeds will speed up render times).
    I'd recommend you capture to ProRes with Io's or the Kona 3 and don't work in uncompressed HD. You gain nothing doing it quality wise at all. And you only use up a ton of disk space (6 times the size in fact) capturing and working in uncompressed HD, which from your post, you're not shooting anyway. The lovely thing about ProRes is that it's visually lossless, efficient, and speeds up the editing process. Mixing formats can be done, but it's better to go to ProRes for all source footage, and edit that way.
    With either the Kona or the Io, you then can output to uncompressed HD tape... that's what they do for you no matter what codec you've edited in. ProRes is designed to be the codec of choice for all HD projects when you're shooting different formats especially... Get them all singing the same tune in your editing stations, and you'll be a much happier camper. Only reason to buy laptops is portability... otherwise you're much better off with towers and the Kona 3 speed wise.
    Jerry
    Message was edited by: Jerry Hofmann

Maybe you are looking for

  • Supplier User Management- Register Supplier User

    Supplier User Management > Register Supplier User I do this on the form and it sets up a supplier user with no problem. It even sets up the securing attribute for the user with the iSupplier Portal id. Is there a way to do this registering on the bac

  • No "Portlet Producer Application" in JDeveloper 11G

    Hi Everyone; I have been asked do some WSRP portlet development for Weblogic. following this tutorial, I donwloaded JDeveloper 11g. However there is no "Portlet Producer Application" option under "New Application". What am I doing wrong? Regards Gerh

  • My illustrator CS3 saved file icon shows as a blank white square?

    This is really odd. I store all my AI files in one folder. When I first open the folder, the lovely orange AI icons representing each file all change to white squares (actually they're in portrait or landscape view depending on how the file was saved

  • Early 2008 MacPro/UPS shutting down too quickly?

    apologies in advance, as I'd bet this has been covered before - just couldn't find it with Search? the problem is - in broad, general terms - I have an early 2008 8-core hooked up to an APC UPS XS 900 battery backup. The Mac Pro's a couple of years o

  • Crystal Report 11 Server License Problem

    Hello, We installed Crystal Report 11 server, In CMC we the license information is displayed as Gesamtzahl der lisenzen - 5 Does this mean we have 5 licenses? We tried to excute our application (which was working fine with Crystal Report X) , but we