Another JTable / Custom CellEditor question

I wish to install a custom cell editor on a per cell basis. The editor requires more real estate than the renderer.
I have tried to handle this by calling <i>setRowHeight</i> within <i>getCellEditor</>. Unfortunately, after the editor is installed, but before it is displayed, the framework calls <i>validate</i> which cascades down to <i>columnMarginChanged</i>. The first thing that <i>columnMarginChanged</i> does is to check if the cell is being edited and if it is then the editor is removed!
From this it appears that I need to adjust the height of the row before the editor is installed. But how? I've tried installing a handler for the MouseEvent but I see this after <i>getCellEditor</i> has been called.
The approach I haven't tried yet is to override <i>columnMarginChanged</i> but to me this does not seem the correct thing to do.
All suggestions welcome - I've been chasing this for a while now!

Thanks for your feedback. I'm working on the dialog solution as a backup mechanism. As to the cell size changing, I take your point. My view is taht this may depend on the item being edited - for example, a cell containing a date can easily be rendered using the default renderer for strings - but presenting a date picker within the cell for editing may not be unexpected - in this way validation occurs during editing rather than post editing. In these circumstances I'm not sure there is much difference between a dialog appearing versus the cell changing size (it is only the height changing). Indeed, some confusion may arise where some cells are edited in-cell and others pop-up a dialog.

Similar Messages

  • Another CME custom backgrounds question

    Hi all. I'm trying to upload a custom wallpaper onto a 7945, but I'm having issues. Getting the "Selections Unavailable" error, even though it's finding the List.xml file. Here's what I have:
    TFTP commands:
    tftp-server flash:Desktops/320x212x16/List.xml
    tftp-server flash:Desktops/320x212x16/TN-customimage.png
    tftp-server flash:Desktops/320x212x16/customimage.png
    MY-CME#sho flash | i Desktop
    260          0 Aug 26 2014 13:29:36 -07:00 Desktops
    303          0 Aug 26 2014 13:29:56 -07:00 Desktops/320x212x16
    304        159 Aug 26 2014 15:19:22 -07:00 Desktops/320x212x16/List.xml
    305       1557 Aug 26 2014 13:35:50 -07:00 Desktops/320x212x16/TN-customimage.png
    306       9037 Aug 26 2014 13:36:02 -07:00 Desktops/320x212x16/customimage.png
    Here's the List.xml file:
    <CiscoIPPhoneImageList>
    <ImageItem Image=”TFTP:Desktops/320x212x16/TN-customimage.png” URL=”TFTP:Desktops/320x212x16/customimage.png”/>
    </CiscoIPPhoneImageList>
    And here's the tftp events debug when I go to look for backgrounds on the phone.
    MY-CME#
    *Aug 26 15:37:15.618 PDT: TFTP: Server request for port 52351, socket_id 0x22080F18 for process 379
    *Aug 26 15:37:15.618 PDT: TFTP: read request from host 10.1.17.16(52351) via GigabitEthernet1/0.200
    *Aug 26 15:37:15.618 PDT: TFTP: Looking for Desktops/320x212x16/List.xml
    *Aug 26 15:37:15.618 PDT: TFTP: Opened flash0:Desktops/320x212x16/List.xml, fd 4, size 159 for process 379
    *Aug 26 15:37:15.618 PDT: TFTP: Sending block 1 (retry 0), len 159, socket_id 0x22080F18
    *Aug 26 15:37:15.618 PDT: TFTP: Received ACK for block 1, socket_id 0x22080F18
    *Aug 26 15:37:15.618 PDT: TFTP: Finished flash0:Desktops/320x212x16/List.xml, time 00:00:00 for process 379
    What am I missing? The spellings all seem right. It's getting the List.xml file, but doesn't try to get any other files after that. Any ideas?

    Thanks for your feedback. I'm working on the dialog solution as a backup mechanism. As to the cell size changing, I take your point. My view is taht this may depend on the item being edited - for example, a cell containing a date can easily be rendered using the default renderer for strings - but presenting a date picker within the cell for editing may not be unexpected - in this way validation occurs during editing rather than post editing. In these circumstances I'm not sure there is much difference between a dialog appearing versus the cell changing size (it is only the height changing). Indeed, some confusion may arise where some cells are edited in-cell and others pop-up a dialog.

  • Question about How to Use Custom CellEditors

    Hi:
    I have been trying to implement something like this: I have a JPanel, and when you double-click a particular spot on it, I want a textbox to appear. Currently, I am implementing it by using an undecorated JDialog that contains a JTextField in it (such that the text field occupies all the space in the dialog, i.e. you can't even tell that there is a dialog). This seems like a hack to me.
    Another alternative that I have been thinking about is using layered panes, and hiding the textfield below the jpanel, and only bringing it to the front when the user double-clicks.
    Then, I stumbled onto custom celleditors. Now, it seems that everyone is using them in JTables, JLists, JComboBoxes, etc. and I was wondering if it is something that I can use with a JPanel.
    Can anyone comment on the implementations I am considering, as well as using custom celleditors with a JPanel?
    Thanks in advance,
    LordKelvan

    Still don't understand your requirement. Does the text field stay there or disappear after the data is entered? If it disappears, then how do you change the value, do you have to click on the exact same pixel again?
    Maybe you could use a MouseListener and then display a JOptionPane or JDialog to prompt for the information. Or if you want to display a JTextField then add a JTextField to the panel and then when the user enters the data by using the enter key or by clicking elsewhere on the GUI you remove the text field from the panel.

  • Another Unlimited Data Upgrade Question

    (Yes, it's another one of those questions.  I'm sorry, but searching - on here, or on Google - only left me with conflicting information.)
    Here's my question:
    A friend of mine is interested in selling me his Galaxy Nexus phone.  Would I be able to keep my single-line, grandfathered, unlimited data plan if I buy his phone and switch to it, or is that only possible if I were to buy the phone new, directly from Verizon?
    Here's my story:
    I have an HTC Thunderbolt that I purchased when it launched.  A few months after buying it, it turned into the HTC Bad Dream, and now it's the HTC Nightmare.  Random heat issues, battery draining, random reboots... It's the same song and dance we've heard before.  These are design issues with the phone; not something a replacement or a repair would fix.
    The real annoyance, though, is the mobile hotspot.  I pay $30/month to use the hotspot legitimately, unlike the users who root their phones to use it without paying for the option, but ever since Verizon started blocking the third-party wireless tethering apps, I've had to choose between using the stock mobile hotspot app and unleashing the above-mentioned Phonemageddon, or simply going without.  I could drop the option from my plan, but seeing as the unlimited data plan no longer exists, I wouldn't be able to get it back without switching to a tiered or shared plan.
    Switching to a more stable phone would alleviate my issues, hopefully, but the difference between Verizon's retail prices and other retailers is hundreds of dollars.  Giving up my unlimited plan, however, wouldn't make the venture worth it.  A definite answer to the question of buying used - either from a Verizon representative, or a customer who's been in the same scenario before - would be very helpful.
    Thank you very much.

    Hi,
    If you provide your own equipment (your friend's Nexus or from ebay etc) then YES you can keep unlimited data. Another wayto keep unlimited would be to pay full retail for a new phone. But I'm sure your friend will give you a better deal than that
    Hope that helps!

  • Another Verizon customer used my email address

    Starting Feb 19th I began getting email for another account. I followed the link on the bottom of the page to tell Verizon this wasn't the correct email. Since then I have received 6 more emails including data usage alerts and important information.
    Today I called verizon and navigated their frustrating automated phone system. Finally got through, explained the situation, and got promptly dropped while being transferred to tech support. Second try I got through repeated the drill and was successfully transferred to tech support.
    Now here is the "fun" part":
    She verified that it was my email address I have been using on my account for years.
    She seemed at a loss in what to do.
    I helped her out by giving her the phone number of the other account holder "from one of the emails". She didn't even seem to have access to that through the email data base.
    She verified that they are a new account and have the same email address.
    She said there was nothing they could do until they contacted the other account.
    She put me on hold and tried to call them.
    No answer.
    She said they could not remove their use of my email address until she was able to contact them.
    Here is the "not so fun" part:
    I asked her how someone could open a new account with an email address already in use. She said it may have been entered manually by a verizon rep.
    I asked her, if she knew it has been mine for years then why can't they eliminate it on their account right now. She said they have to contact the other account holder first.
    I said if you are concerned about not being able to contact them through email if you eliminate it---you can't even do that now because it comes to me!
    I suggested that she text the other customer if she needed to contact them if they aren't answering their phone.
    I told her I am now concerned about their account security - now that their email comes to me I have all the info I need to reset their password and hack their account. She said there is nothing she can do until she contacts the other customer.
    I said this is frustrating, I am wasting my time trying to fix their error and I will just send all verizon email to my spam folder and when my contract is up in April I will no longer be a verizon customer. She explained how she understood my frustration, but there is nothing they can do until they contact the other customer.
    Question....Why in the hell do they need to contact the other customer to get permission to remove MY email address from their account? What if they say no? It is verified that this is my email address on my account for years and my area code is Oregon...theirs is Missouri.

    They should not have been able to use my email in the first place. So if they deny verizon permission does that mean I continue to get their email from verizon? The problem is obvious, just fix it verizon.
    BTW: One of the emails was a "Data Usage Alert" which said, "Your account has used approximately 50% of your data allowance for this month. Your monthly data allowance will reset on the 22nd."
    So he has had the account for 3 days and has already used up 50% of his data plan. The longer Verizon waits to correct this the more money they will make with data overage charges.
    Also I am not intentionally looking at his private email. It is all addressed [email protected], I have no way to know if it is for me or him until I open it. Maybe I will just do him a favor and reset his password, go into his account, and change his data plan to save him some money...J/K

  • Set JTable in another JTable Column

    Hai Java Experts
    Can we Set JTable in another JTable Column
    In jsp we add one table in a column of another table. Like the previous way can we do it in swing?
    Pls Help me with example..
    Thanks

    [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender]
    db
    edit And adding a table in a column of another table doesn't make any sense at all. Perhaps you meant showing a table in a cell of another table.
    Edited by: DarrylBurke

  • Oim 11g Custom Challenge questions

    hi,
    does oim 11g allows users to setup custom challenge questions.
    Sun Idm does have this feature..
    any idea on Oracle Idm..
    thank you.

    How to add custom challenge questions in OIM 11g
    Find below link for 11gR2
    http://srini-bellamkonda.blogspot.in/2012/11/adding-custom-challenge-questions-in.html

  • Adding custom challenge questions in OIM 11gR2

    Friends,
    Can you please let me know the process to add new custom challenge questions in OIM 11gR2?
    Thanks

    Detailed steps have been given in my blog at the below url.
    http://srini-bellamkonda.blogspot.com/2012/11/adding-custom-challenge-questions-in.html
    Have a look and let me know if you have any questions.

  • Custom challenge questions in OIM 11gR2

    Hi,
    Please let me know how to add custom challenge questions in OIM 11gR2?

    Follow the steps given in blog to add custom challenge questions.
    http://srini-bellamkonda.blogspot.com/2012/11/adding-custom-challenge-questions-in.html

  • Is it free to send and receive texts from another EE customer who is abroad?

    is it free to send and receive texts from another EE customer who is abroad?

    Hi 
    Welcome to the EE Community! Provided you're texting an 07 number, it won't cost you anything extra to text someone abraod (provided that's included in your package). It will cost the person abroad to reply (but not receive texts), unless again they have some sort of add on in the country they're present in. Cheers,
    Titanium
    Was my post helpful? Please take 2 seconds to hit the 'Kudos' button below

  • Problem while setting custom Challenge Questions in 11gR2

    Hi all,
    I am trying to add some custom Challenge Questions in 11gr2 but it is throwing error . For this first i added questions in Look up and then in customResources_en.properties and then i restarted OIM server.
    when a user is logging for the first time he has to set his challenge question there i am getting error like:
    JBO-29000: Unexpected exception caught: oracle.iam.ui.platform.exception.OIMRuntimeException, msg=JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find resource for bundle java.util.PropertyResourceBundle, key KEY_WHATTHEHELL
    JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find resource for bundle java.util.PropertyResourceBundle, key KEY_WHATTHEHELL
    Localized message not available. Error returned is: Can't find resource for bundle java.util.PropertyResourceBundle, key KEY_WHATTHEHELL
    Here My custom challenge question is:WHATTHEHELL.
    Its an urgent requirement, so reply ASAP.
    Thanks In Advance.

    If you are going for Localizing Challenge Questions and Responses
    http://docs.oracle.com/cd/E27559_01/admin.1112/e27149/app_localizing.htm#OMADM5054

  • Another "get album artwork" question

    another "get album artwork" question
    I notice that when I click "get album artwork" it seems to go through the whole library and look for cover jpegs. (in my case, that's going to take a long time!)
    here's my question: it's looking for artwork, yes, but it's NOT going to do anyything to the many, many albums for which I have already (manually) added artwork, is it? If it does - I am in trouble! Please, somebody, reassure me that the artwork I have painstakingly added manually to zillions of albums is safe!
    w

    Updade...
    So, as another test, I uninstalled iTunes, then checked the hard drive again.
    All the icons have now turned into Quicktime icons, which leads me to believe that when you look at your music in finder, it shows the icons related to your default music player.
    So, my next step is to find a new default player, and maybe my album covers will show up again.

  • Write custom cellEditor class

    Hi,
    is it possible to write a custom cellEditor class. I need this for a dynamically created table. The reason for this is that i need to display structured data in one column. I want to show 3 different IWDElements in one cell.
    Best regards,
    Christian

    No, that's not possible with the NW04 table. You could instead dynmically build a container with matrix layout.
    Armin

  • JFormattedTextField as CellEditor in JTable & Enter key question

    Hi all,
    I have a cell editor (quite complicated) containing JFormattedTextField; for the description of the problem we can simplify it as:
    class Editor extends AbstractCellEditor implements TableCellEditor {
            JFormattedTextField ftf = new JFormattedTextField();
            public Object getCellEditorValue() {
                return ftf.getText();
            public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
                return ftf;
        }The problem is when I use this cell editor in JTable, and change the value in formatted text field and try to confirm change by Enter key, nothing happens (cursor stays in formatted text field).
    Note when I use JTextField instead of JFormattedTextField in cell editor, Enter key "confirms" new value and jumps to following cell in table (according JTable binding). So I guess JFormattedTextField "consumes" the Enter stroke in some way.
    I want to achieve the same behavior on Enter key in case of JFormattedTextField as in case of JTextField in cell editor.
    I have searched the forum, tried a lot, but was unable to find solution for such a simple problem ... probably I missed something ...
    Thanks a lot, Pepek

    The cell editor is not applied in your code (the question is what my.setCellEditor() does but it is another topic - you can find it on this forum). Use e.g.:
    public class Untitled1 extends JFrame {
        public Untitled1() {
            JPanel panel = new JPanel();
            JTable my = new JTable(5,5);
            my.setDefaultEditor(Object.class, new Editor()); //or my.getColumnModel().getColumn(0).setCellEditor(new Editor()); //just for first column
            panel.add(my);
            this.add(panel);
            pack();
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setVisible(true);
        class Editor extends AbstractCellEditor implements TableCellEditor {
            JFormattedTextField ftf = new JFormattedTextField();
            public Object getCellEditorValue() {
                return ftf.getText();
            public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
                ftf.setBackground(Color.YELLOW); // just to visually confirm which editor is used
                return ftf;
        public static void main(String[] args) {
            Untitled1 untitled1 = new Untitled1();
    }Therefore you couldn't find any difference - you used the same cell editor in both cases.

  • JTable Custom Cell Editor "focus through keyboard" question (SSCCE included

    I was trying to use two components in a table cell. The first was JTextField and second the JButton. Everything works fine, except when it comes to editing the JTextfield using keyboard instead of mouse. When I use tab key to go to the custom cell, I can see that the focus is on the cell (as can be visible from background color). But when I try to edit the cell using F2 or directly entering text, nothing gets entered. If I use the mouse to go to particular cell, it works fine. Here is SSCCE. Try the following.
    1. Use mouse key to select first cell for editing. Edit the cell. Everything normal.
    2. Use the tab key to go to the first cell. Try to edit cell either by entering directly for after using F2. Can't get the typed text into the JTextfield.
    package com.ns;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Point;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.DefaultCellEditor;
    import javax.swing.JButton;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.UIManager;
    import javax.swing.WindowConstants;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    public class TextButtonCellFrame extends javax.swing.JFrame {
        // Variables declaration - do not modify
        private JScrollPane jScrollPane1;
        private JPanel testPanel;
        private JTable testTable;
        // End of variables declaration
        public TextButtonCellFrame() {
            initComponents();
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            testPanel = new JPanel();
            jScrollPane1 = new JScrollPane();
            testTable = new JTable();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            testTable.setModel(new 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"
            testTable.setRowHeight(20);
            testTable.getColumnModel().getColumn(0).setCellRenderer(new MyTableCellRenderer());
            testTable.getColumnModel().getColumn(0).setCellEditor(new MyTableCellEditor());
            testTable.getColumnModel().getColumn(0).setPreferredWidth(200);
            jScrollPane1.setViewportView(testTable);
            testPanel.add(jScrollPane1);
            getContentPane().add(testPanel, BorderLayout.CENTER);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-496)/2, (screenSize.height-330)/2, 496, 330);
        }// </editor-fold>
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new TextButtonCellFrame().setVisible(true);
        public class MyTableCellRenderer extends JPanel implements TableCellRenderer {
            Point point;
            JButton button1 = new JButton("Test 1");
            JTextField txtField = new JTextField();
            public MyTableCellRenderer() {
                setLayout(new BorderLayout());
                this.add(button1, BorderLayout.EAST);
                this.add(txtField,BorderLayout.CENTER);
            public Component getTableCellRendererComponent(JTable table, Object value,
                    boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
                if (isSelected) {
                    txtField.setBackground(testTable.getSelectionBackground());
                    txtField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
                else {
                    txtField.setBackground(testTable.getBackground());
                    txtField.setBorder(null);
                return this;
        public class MyTableCellEditor extends DefaultCellEditor
                                        implements ActionListener {
            JPanel panel = new JPanel();
            JButton button1 = new JButton ("Test 1");
            JTextField txtField = new JTextField();
            MyTableCellEditor() {
                super (new JTextField());
                button1.addActionListener(this);
                panel.setLayout(new BorderLayout());
                panel.add(button1, BorderLayout.EAST);
                panel.add(txtField,BorderLayout.CENTER);
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == button1)
                    JOptionPane.showMessageDialog(null, "Action One Successful");
            public Component getTableCellEditorComponent(JTable table, Object value,
                                        boolean isSelected, int row, int column) {
                txtField.requestFocusInWindow();
                return panel;
    }regards,
    nirvan.

    I don't know what's better:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.EventObject;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TextButtonCellFrame extends JFrame {
      JTable testTable = new JTable();
      public TextButtonCellFrame() {
        testTable.setModel(new DefaultTableModel(
          new Object [][] {
            {null, null, null, null},
            {null, null, null, null}
          new String [] { "1", "2", "3", "4" }
        testTable.setRowHeight(20);
        testTable.getColumnModel().getColumn(0).setCellRenderer(
          new MyTableCellRenderer());
        testTable.getColumnModel().getColumn(0).setCellEditor(
          new MyTableCellEditor(new JTextField()));
        testTable.getColumnModel().getColumn(0).setPreferredWidth(200);
        getContentPane().add(new JScrollPane(testTable));
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(480,320);
        setLocationRelativeTo(null);
      public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
            new TextButtonCellFrame().setVisible(true);
      public class MyTableCellRenderer extends JPanel
                    implements TableCellRenderer {
        JButton button1 = new JButton("Test 1");
        JTextField txtField = new JTextField();
        public MyTableCellRenderer() {
          setLayout(new BorderLayout());
          this.add(button1, BorderLayout.EAST);
          this.add(txtField,BorderLayout.CENTER);
        public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
          if (isSelected) {
            txtField.setBackground(testTable.getSelectionBackground());
            txtField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
          } else {
            txtField.setBackground(testTable.getBackground());
            txtField.setBorder(null);
          txtField.setText(value==null?"":value.toString());
          return this;
      public class MyTableCellEditor extends DefaultCellEditor
                      implements ActionListener {
        JPanel panel = new JPanel(new BorderLayout());
        JButton button1 = new JButton ("Test 1");
        JTextField txtField; // = new JTextField();
        MyTableCellEditor(JTextField txtField) {
          super (txtField);
          this.txtField = txtField;
          button1.addActionListener(this);
          panel.add(button1, BorderLayout.EAST);
          panel.add(txtField,BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
          if (e.getSource() == button1)
            JOptionPane.showMessageDialog(null, "Action One Successful");
        public Component getTableCellEditorComponent(JTable table, Object value,
                      boolean isSelected, int row, int column) {
          txtField.setText(value==null?"":value.toString());
          SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              txtField.requestFocusInWindow();
          return panel;
    }

Maybe you are looking for

  • DVD Player Brightness fine increase doesn't work

    When i increase the brightness in DVD Player 5.4, then there is no change visible while moving the slider until about one third to the right, where it immediately jumps to a too bright value. From there on the slider works as usual changing the brigh

  • PR Delivery Date Issue from Maintenance Order

    Hi All, We have a scenario - - Create Maintaince Order (IW31)/Assign Basic Start Date and Basic Finish Date. - Auto PR Generated from Maintenance Order but the delivery date in PR is Basic  Finish Date. My client's requirement is Auto PR will pick up

  • How to convert ut8-8 to unicode

    Hi guys, For instance, I got a textbox and a user enter some Chinese characters in it. My page will need to put this string as a parameter to the other page. how should I convert these chinese character to unicode? At my servlet side, how should I pu

  • Can someone explain to me what the history state slider does?

    Hi everyone! Why use the slider when I can easily click a previous state from the list in the history panel? Does the slider have some extra function that I may have overlooked? Thanks for your help, It's been bugging me for ages. Kelly (using Photos

  • Process dimensions and Applications after Restore

    We are using BPC 7.0MS.  We need to process dimensions and Applications after the database restore in case of any Optimization failures. It takes around 3 hours for us to do this process. Can we skip the BPC process by taking backup of Database and S