Using two editor instances within JTable

Hello,
I'm struggling around using component editors within JTable. E.g. selectAll text on entering a JTextField cell or immediately raising the popup while entering a JComboBox cell.
In my analysis most of these problems arises due the re-use of the cell editor.
The event sequence is doing things in the context of the old cell while preparing the editor for the new cell has already been started.
Because it is the same component and some things are bound deep inside the L&F it seems not easy to handle them properly.
Just an idea from me is to avoid such problems by working with two instances for the editors in general. This should avoid all problems coming out of overlapping event processing. (To provide each cell with an own component is of course no solution)
Any comment on such an approach?
Thanks in advance
Wolfgang R.

No, it wasn't the custom JTable extension.
By entering a cell a popup will be shown for a short moment. This is only by using Windows L&F (not Metal). Within the L&F a togglePopup() is called which may cause this problem.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.util.EventObject;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
public class JTableExt extends JTable {
     public static class ComboBoxEnumRenderer extends JComboBox implements
               TableCellRenderer {
          public ComboBoxEnumRenderer() {
               setEditable(false);
               setBackground(Color.WHITE);
          public Component getTableCellRendererComponent(JTable table, Object value,
                    boolean isSelected, boolean hasFocus, int row, int column) {
               this.removeAllItems();
               this.addItem(value);
               return this;
     public static class ComboBoxEnumEditor extends DefaultCellEditor {
          private static String[] values = null;
          public ComboBoxEnumEditor() {
               super(new JComboBox());
               values = new String[50000];
               for (int i = 0; i < values.length; i++) {
                    values[i] = "row_" + i;
          public Component getTableCellEditorComponent(JTable table, Object value,
                    boolean isSelected, int row, int column) {
               JComboBox combo = (JComboBox) getComponent();
               combo.removeAllItems();
               for (int i = 0; i < values.length; i++) {
                    combo.addItem(values);
               combo.setSelectedIndex(0);
               return super.getTableCellEditorComponent(table, value, isSelected, row,
                         column);
     public JTableExt() {
          super();
          init();
     // invoke editor on cell entry
     public void changeSelection(final int row, final int column, boolean toggle,
               boolean extend) {
          super.changeSelection(row, column, toggle, extend);
          if (editCellAt(row, column))
               getEditorComponent().requestFocusInWindow();
     private void init() {
          setDefaultEditor(Object.class, new ComboBoxEnumEditor());
          setDefaultRenderer(Object.class, new ComboBoxEnumRenderer());
     private static void setUI() {
          String lnfName = "";
          //lnfName = "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel";
          lnfName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
          try {
               UIManager.setLookAndFeel(lnfName);
          } catch (Exception exc) {
     public static void main(String args[]) {
          try {
               setUI();
               javax.swing.JFrame frame = new javax.swing.JFrame();
               frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
               frame.getContentPane().setLayout(new BorderLayout());
               final JTableExt demo = new JTableExt();
               Object[][] data = new Object[30][1];
               demo.setModel(new DefaultTableModel(data, new String[] { "first column" }));
               frame.getContentPane().add("Center", new JScrollPane(demo));
               frame.setSize(600, 600);
               frame.setVisible(true);
          } catch (Throwable t) {
               System.exit(0);
//end

Similar Messages

  • Hi, I use two email addresses within one account with gmx.  I created one account with the first email address now. How do I add the second one to this account? Now it looks like this. One account was opened with address A. I receive in this account email

    Hi, I use two email addresses within one account with gmx.
    I created one account with the first email address now. How do I add the second one to this account?
    Now it looks like this.
    One account was opened with address A.
    I receive in this account emails for address A and B.
    But I can only write and answer with address A.

    Hi Rudegar,
    Sorry for my late reply.
    It s not the amount of accounts I'm struggling with.
    When I create now for both email addresses one account, then I receive the same emails two times.
    That is not what I want.
    Because on gmx the two email addresses have the same inbox and outbox.
    E.g. I can login to my gmx account either with email A or B. It doesn't matter.
    Now I want to have the same on my ipad.
    One account with both email addresses.

  • How to split presentation level and business level using two ATG instances

    Hello All!
    We are investigating possibility of splitting ATG presentation (web store with jsp pages and other presentation components) and business (ATG components such as Pricing, Catalog, etc.) levels. The first idea that we have is simply start two instances of ATG. One instance will serve client requests (presentation level) and communicates with another ATG instance (business level) where all ATG components are situated.
    The main problem is a Nucleus container which is used for accessing all ATG components. And we don't know right solution how to point to a Nucleus container that is situated on a remote ATG instance. Right now we have two ideas how to establish communication between two ATG instances:
    - try to replace local Nucleus container by remote one using RMI;
    - do not replace Nucleus container by implementing some custom filter that can redirect all servlet requests to another ATG instance. In that case we will have two Nucleus containers.
    What do you think about all this? Do you have any other solutions how to solve the task? Maybe we lost something? Can we deploy a cluster of ATG instances that will communicate between each other?
    Thanks in advance.
    Andrey.
    Edited by: 945758 on Jul 11, 2012 7:00 AM

    Yes ATG system can have multiple nodes grouped in one or more clusters managed by load balencer
    If the services you are talking about are inherently ATG services like login, add to cart, checkout then its better to implement it with ATG.
    ATG provides and support both REST and SOAP based Webservice and allows you to expose any ATG component as service thus making it available outside ATG space.
    To be able to manage load better you can split your servers to page serving servers and services oriented servers and place them into multiple clusters.
    Though I haven't seen anyone using this kind of topology so not sure whether it's there is any challenge in setting up this topology.

  • Its is possible to use two embedded instances of OC4J at the same time?

    Hi,
    I need to run two web apps at the same time in JDeveloper. Each on must run in its own OC4J instance, in different ports. I don't want to run a remote OC4J instance, I want two embedded instances and JDeveloper 10g comes just with one.
    Wny ideas?
    Thanks in advance,
    Brian

    Brian,
    no, there is only one embedded OC4J instance possible. The option is to install OC4J stand alone locally.
    Frank

  • Simulating one column using two columns in a JTable

    What I need to do is "join" the two first columns of a JTable...
    What do I mean by saying "join" ?
    I want to make dissapear the right border of the first column, and the same thing for the left border of the second column, also do both things for the column headers of that two columns.
    All that to simulate having one column when there's actually two differents columns.
    How can i do that ? Thanks !

    Make a TableModel that filters your original table model.
    See JTable.setModel.
    public class MergedColumnsTableModel extends javax.swing.table.AbstractTableModel
         javax.swing.TableModel model;
         int[] columnSpans;
          * Assume for simplicity that model does not change (no columns inserted/deleted).
         public MergedColumnsTableModel(javax.swing.TableModel model) {
              this.model = model;
              columnSpans = new int[model.getColumnCount()];
              for (int columnIndex = 0; columnIndex < columnSpans.length; ++columnIndex) {
                   columnSpans[columnIndex] = 1;
         public void merge2(int columnIndex) {
              int leftSpan = columnSpans[columnIndex];
              int rightSpan = columnSpans[columnIndex + leftSpan];
              columnSpans[columnIndex + leftSpan] = 0;
              columnSpans[columnIndex] += rightSpan;
         public int getRowCount() {
              return model.getRowCount();
         public int getColumnCount() {
              int n = 0;
              for (int i = 0; i < columnSpans.length; ++i) {
                   if (columnSpans[i] != 0) {
                        ++n;
              return n;
         public Object getValueAt(int row, int column) {
              int n = 0;
              for (int i = 0; i < columnSpans.length; ++i) {
                   if (columnSpans[i] != 0) {
                        if (n == column) { // We are at the column
                             return model.getValueAt(row, i);
                        ++n;
    }

  • Implicit list when using TABLE OF instances within an object.

    I have been searching for a solution for this problem, but to no avail.
    I have an XML schema which specifies within the root element:
    <xsd:element name="onestring" type="xs:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="manystrings" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
    So I have created a few types in my database:
    CREATE OR REPLACE TYPE VARCHAR_TABLE AS TABLE OF VARCHAR(5);
    CREATE OR REPLACE TYPE rootelement AS OBJECT(
    onestring VARCHAR(5),
    manystrings VARCHAR_TABLE
    Now I preform the following:
    DECLARE
    xml XMLTYPE;
    obj rootelement;
    BEGIN
         obj := rootelement('valA', VARCHAR_TABLE('val1','val2','val3'));
         xml := XMLTYPE(obj);
         print_out( xml.getstringval );
    END;
    And from this, the result I get is:
    <ROOTELEMENT>
    <ONESTRING>valA</ONESTRING>
    <MANYSTRINGS>
    <VARCHAR2>val1</VARCHAR2>
    <VARCHAR2>val2</VARCHAR2>
    <VARCHAR2>val3</VARCHAR2>
    </MANYSTRINGS>
    </ROOTELEMENT>
    When what I would like to see is:
    <ROOTELEMENT>
    <ONESTRING>valA</ONESTRING>
    <MANYSTRINGS>val1</MANYSTRINGS>
    <MANYSTRINGS>val2</MANYSTRINGS>
    <MANYSTRINGS>val3</MANYSTRINGS>
    </ROOTELEMENT>
    Can this be accomplished? I also need the outputted XML to be able to be read back in. (Currently I am calling XMLTYPE(xml).toObject(obj); ).
    Thanks in advance.
    Dave

    Well, since XSL Transformations worked in 10.1 too, the following will do what you want
    SELECT XMLTYPE(ROOTELEMENT('valA', VARCHAR_TABLE('val1', 'val2', 'val3'))).TRANSFORM(XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>
        <xsl:template match="*">
            <xsl:choose>
                <xsl:when test="*">
                    <xsl:apply-templates/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="."/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
        <xsl:template match="/ROOTELEMENT/MANYSTRINGS/node()">
            <xsl:element name="{name(..)}">
                <xsl:value-of select="text()">
           </xsl:value-of>
            </xsl:element>
        </xsl:template>
        <xsl:template match="ROOTELEMENT">
            <ROOTELEMENT>
                <xsl:apply-templates/>
            </ROOTELEMENT>
        </xsl:template>
    </xsl:stylesheet>
    ')) AS TRANSFORMED
      FROM DUALSorry for providing an earlier solution that would not apply to your version, but I find it hard to remember the features of each distinct one. I vaguely remembered (I work with 11g for quite a bit now) that APPENDCHILDXML was 10g functionality, but did not remember that it was actually 10.2.
    Regards
    Philip

  • SBO - How to use two different Stock Account within the same Item Group

    Hi,
    I'm currently stuck within one of my implementation.
    I'm deploying the same solution worldwide which worked pretty well until now. All the items are connected to an item group, with a unique GL account, supposed to book at the same time the good receipt and the good issue (Balance-Sheet Account = 14xxxxx).
    My new unit is willing to use two different GL accounts when performing its stock entry (let say 14xxx10) and another GL account for the good issue, let say 14xxx20.
    Do you have any clue so i can please them and keep using at the same time the item group ?
    Thanking you in advance
    Stephane

    Hi,
    In fact, we use the GL account as the HQ Account (Reporting Account) while the "Export Code" will be used to store the local GL Account (greek account).
    As such, we can, somehow handle two different chart of accounts.
    In my reporting, i'm only using a single GL account for stock movements, while my greek counterparts want to handle two different accounts.
    Threfore, i have only two solution since there is normally a one to one relationship between a HQ account and a local account that are :
    1 - Duplicate the HQ accounts
    In that case, i do respect anytime the one to one relationship. I've got one HQ account for one local account. But how can i put this since i can only handle one single stock account.
    2 - I keep my single stock account like this but i won't be managing the possibility to get two different Export Codes.
    Regards
    Stephane

  • Problem using an editable JComboBox as JTable cell editor

    Hi,
    i have a problem using an editable JComboBox as cell editor in a JTable.
    When i edit the combo and then I press the TAB or ENTER key then all works fine and the value in the TableModel is updated with the edited one, but if i leave the cell with the mouse then the value is not passed to the TableModel. Why ? Is there a way to solve this problem ?
    Regards
    sergio sette

    if (v1.4) [url
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTa
    le.html#setSurrendersFocusOnKeystroke(boolean)]go
    hereelse [url
    http://forum.java.sun.com/thread.jsp?forum=57&thread=43
    440]go here
    Thank you. I've also found this one (the first reply): http://forum.java.sun.com/thread.jsp?forum=57&thread=124361 Works fine for me.
    Regards
    sergio sette

  • Using Two JTextPanes to create an editor..help

    Hi
    I am writing a language editor ( english to native language). The editor would use the tranliteration. I need to make this both an application and an applet(for obvious reasons). Any suggestions on what container should be used? I am planning to use two text panes on a Frame? It this the right approach? The editor would have the standard features an editor has.Any examples to look at?
    Thanks
    kris

    James
    Thanks for responding
    I need some direction here, the following is what i am trying to accomplish
    have something like this
    ------------------------------------------------THIS IS FRAME----------
    ---------JTextPane1---------------------------------
    | |
    | |
    | |
    | |
    | |
    ----------JTextPane2--------------------------------
    | |
    | |
    | |
    | |
    | |
    I will use the below box for entry in to english and above box for transliterated text, how do I get the text from box below to the box above(plain english would be ok right now). And WHY do I need a box?
    Any code on how to do it is appreciated

  • Hello. I have two version of Office for Mac. 2008 and 2001. I want to delete the 2008 version. If I use the removal tool within the Offie 2008 folder, is there any danger of the 2001 version being removed too.  Thanks Dave UK

    Hello. I have two version of Office for Mac. 2008 and 2001. I want to delete the 2008 version. If I use the removal tool within the Offie 2008 folder, is there any danger of the 2001 version being removed too.  Thanks Dave UK

    Do you mean Office 2008 and 2011 or do you really want Office 2001? I think you mean 2011 since Office 2001 wouldn't make much sense.
    The Office uninstaller should be able to identify there are two versions and allow you to delete either one or both.

  • Is it impossible to use track editor within iphone version of GB? If yes, where is the button?

    Is it impossible to use track editor within iphone version of GB? If yes, where is the button?

    Thanks for the information provided.
    I am using 9i JDeveloper with OA extension, i.e., 11.5.10 CU2 JDeveloper from Patch 4573517 (Oracle9i JDeveloper with OA Extension for 11.5.10 CU2)
    I have gone through the developer's guide. Though Developer's guide talks about "Building an OA Framework application (basics)" in chapter 3, the file naming standards hint that such kind of an application can go ONLY as an extension to the existing application.
    Chapter 9 talks about extending and deploying OA FWK applications which are purely extensions. These extensions might typically have a custom EO, VO and at the max. a custom CO too. And for deploying this custom code, documentation talks about substituting the standard BC4J objects with that of the custom ones. This is OK as long as we need modifications to an existing page.
    BUT, what I am looking forward is "whether it's possible to develop a new application altogether, e.g. an online book store using OA framework and integrate it with Oracle E-Business suite.". If so, how can such a new application be deployed without losing the flexibility on future upgrades?

  • Connecting to two database instances using the same Toplink

    Hi,
    We are trying to create a process using BPEL where data from one database instance needs to be passed to the other. The process is compiling properly and we could deploy it in BPEL Process Manager. But when we try to run the process, the data is not getting inserted into the second instance. There is no error /exception being thrown at most of the time, but at times we are getting a 'Unique constraint error' eventhough there is no duplication of data.
    Can we connect to two different instances using the same toplink. How can we achieve this.
    Thanks in advance
    Pratheusha

    You need to use two different sessions with two different mapping descriptors

  • HT1918 is it possible to have two different password within one iTunes account?  one to log in with and a different one to use when making a purchase?

    Is is possible to have two different passwords within itunes? one to log in with and a different one to make purchases with?

    The system is not setup to provide that kind of sservice.  If making certain purchases it does ask for an answer to one of your security questions, so that provides a little more security for some purchases, just not all.

  • Trigger two FPGA instances at same time

    I have some basic FPGA code that transmits data bits over a serial bus (RS485),  The code is written so that it waits in the first state of a state machine in a single cycle timed loop.  Upon a certain trigger, it starts reading a FIFO containing data and sends the data out on a Tx line.  It does this until all bits are send then it goes back to the first state to wait for the next trigger.  The trigger is needed because windows has to fill the FIFO first before the FPGA can start sending.
    I need two instances of this code running because I have two com busses (one is redundant).  So I am using the FPGA code as a subvi and I wrote a main FPGA vi to call two separate instances of the subvi in parallel.  A regular windows vi writes to the FIFOs for Tx and reads FIFOs for Rx.  No problem so far.
    The trick is that I have to start both transmissions within 200nS of each other (yes, nanoseconds).  Windows will write to both FIFOs in parallel, but the timing is 4uS apart, too long.  I tried setting up a boolean flag in the FPGA subvi, but windows can't write to the subvi control directly.  FPGA won't allow it (the Write function is greyed out).  I tried using a FIFO for a flag, but the problem is a race condition.  One of the instances will read the FIFO first and wipe it out.  The other does not get to read it.  I need one common trigger point to be used by both subvi instances.
    My final solution was to use a memory in the FPGA subvi and a numeric control in the main FPGA vi.  Windows write to the numeric control,  It can because the control is in the main FPGA vi.  Inside the main FPGA, I run a timed loop that looks for the numeric to be other than zero.  If so, it writes the value to the memory location used by the FPGA subvi.  After some time, the main writes a zero back to the memory to prevent the subvi from starting up again, and it writes a zero to the numeric to reset it.  The whole thing repeats, waiting for windows to write to the numeric again for the next transmission.
    I had to do it this way because sometimes I want to transmit on both busses, and sometimes just one or the other.  Numeric values are used to determine which to transmit on.  Now the transmissions start at almost exactly the same time, 1 or 2 nanoseconds apart.  But the trigger process seems very far fetched to me.  I was wondering if there is a better solution.  I'm pretty new to FPGA.
    - tbob
    Inventor of the WORM Global
    Solved!
    Go to Solution.

    tbob wrote:
    Basically I did the same thing using FPGA Memory.  From windows I write to a numeric control which resides inside the FPGA Main vi.  In the FGPA main, I write to the Memory.  Inside the FPGA subvi, I read the memory and decode the value to either use one or the other or both busses.  After fooling with this for some time, because the Read Memeory needs to use a shift register (probably due to it taking an entier clock cycle), I got it to work.  Both busses trigger at the same time.  I guess it really doesn't matter if I use a FIFO or if I use Memory.  The main issue is that I have to write from Windows to the FPGA Main, and then from the FPGA Main to the FPGA subvi.  Then the timing is exact as far as the subvi is concerned.
    There are a couple of advantages to using two FIFOs over your approach.  First, you don't need the shift register for the memory location.  Second, you don't have to worry about which VI is responsible for clearing the memory location, nor do you run the risk that one of your subVIs will execute twice, or not at all, if the memory isn't cleared at the right time.  Perhaps most importantly, you'll save yourself space on the FPGA because you won't need arbitration - the extra code that gets added when two parts of the FPGA try to access the same resource at the same time.  In your case, both instances of the subVI access the memory block concurrently, so the FPGA compiler adds extra logic to prevent conflicts.  If you only read the memory block in one place and only write it in one place (the read and write can be in different loops or subVIs) there's no need for arbitration.  By using two FIFOs you can keep them independent and avoid the conflict resolution code.  See the help for "arbitration" for more details.

  • Using external editor with PSE 9

    I use CS4 as my external editor.Typically Adobe installs 2 versions 32 and 64 bit versions of CS4.
    When using Ctrl-H from within PSE9, it always calls the 64 bit version of CS4. How can I tell it to use the 32 bit version. I have to use 32 bit CS4 because of some plugins I need that do not work with the 64 bit version.
    Any suggestions?
    Thanks in advance.

    The work around is to copy the 32 bit application to My documents. Then rename it and put it back. You will have two identical applications. When you browse to the renamed application PSE will be fooled into thinking it’s another program.

Maybe you are looking for

  • Can't get songs to appear in itunes from ext hard drive!

    I moved the contents of itunes to an external hard drive that is connected to the computer that I have always used itunes on. Now when I open itunes there are no songs in itunes. I have no idea how to fix this. Also, when I plug in my ipod an error m

  • Custom navigation dropdown menu /To null out a collection or variable in 6.

    Is there are way to clear a variable or Null out a Collection in 6.5.We are having problem with displaying pages of a communities in navigation menu.Since the pages for a community is fetched inside the loop, the pages in each community gets appended

  • Images show up only as blue question marks

    I just purchased a new Macbook Pro approximately one week ago, and concitering it's BRAND NEW I don't understand why I have this problem. On sites like www.deviantart.com and also www.weheartit.com images show up as blue question marks... I have down

  • Process MAD.EXE (PID=1932). All Domain Controller Servers in use are not responding:

    Process MAD.EXE (PID=1932). Topology discovery failed, error 0x80040a02 (DSC_E_NO_SUITABLE_CDC). Look up the Lightweight Directory Access Protocol (LDAP) error code specified in the event description. To do this, use Microsoft Knowledge Base article

  • Cant't update camera raw 8.5

    I can't update latest 8.5 version of Camera Raw in photoshop plug-in. I aleary try reinstall after use official cleaner tool but can't solve this problem yet. appearing error message is U44M1P34, and i have found this massage that "06/22/14 01:36:25: