Problem with comboBox editor

Hi experts,
i am keeping a combobox renderer and editor in my JTable for 2 columns say 5th column and 7th column.
In renderer no Problem.
But while i am editing ,whenever i am choosing a perticular item from the drop down in the first row of table,it is affecting the remaining set of rows.,not all the rows also.
for example,next 5 rows are getting the same selected value.
next some 2 rows are getting affected.
the below 2 class are my renderer and editor.public class ComboBoxRenderer extends JComboBox implements TableCellRenderer {
        public ComboBoxRenderer(String[] items) {
                        super(items);
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                if (isSelected) {
                // Select the current value
                setSelectedItem(value);
                return this;
}My ComboBox editor is public class ComboBoxEditor extends DefaultCellEditor {
        public ComboBoxEditor(String[] items) {
               super(new JComboBox(items));
}so i am using this render and editor in my swing screen by the following codeString strSP[] = {"P", "O", "H", " "};
column5.setCellEditor(new ComboBoxEditor(strSP));
column5.setCellRenderer(new ComboBoxRenderer(strSP));I am sure like the problem with my renderer and editoronly,but i am helpless.
Please if someone help me to come out of this problem,it will be much helpful for me .
thanks

Hi,
Thanks for u'r reply
I tried in so many ways.
I tried with u'r editor,and sun forum examples also.
I brief what i want.
I am having table with 3 column.
The zeroth col, and the 2 col is a combo box.so i am rendering.
when i choose a one from zeroth col combo Box ,the 2nd col ComboBox value has to change into YES
when i choose a apart from one from zeroth col combo Box ,the 2nd col combo Box value has to change into NO.
Here my Problem is
When ever i am choosing the particular value from the 1st combo box,it is affecting the all the combobox values below(set of values,not all)..To solve that i kept the commented line in the renderer but it is creating the new problem.
I am very seriously working to solve this problem,if any one suggest to solve this,it will be very much helpful to me.
I am posting my code belowimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.*;
public class TableComboBox extends JFrame implements TableModelListener
     public JTable table;
        DefaultTableModel model = null;
        JComboBox editor2 = null;
     public TableComboBox()
          Object[][] data = { {" ", "A" , " "}, {" ", "B", " "}, {" ", "C", " "}, {" ", "D", " "}, {" ", "E", " "}, {" ", "F", " "}, {" ", "G", " "}, {" ", "H", " "}  };
                String[] columnNames = {"FIRST","SECOND", "THIRD" };
                String[] column0Items = { "one", "two", "three", "four" };
                String column2Items[] = {"YES","NO"};
          model = new DefaultTableModel(data, columnNames);
                model.addTableModelListener(this);
          table = new JTable(model);
          //  Set the Zeroth column to use a combobox as its editor,renderer
                table.getColumnModel().getColumn(0).setCellRenderer(new ComboBoxRenderer(column0Items));
          table.getColumnModel().getColumn(0).setCellEditor(new ComboBoxEditor(column0Items));
                //  Set the second column to use a combobox as its editor,renderer
                table.getColumnModel().getColumn(2).setCellRenderer(new ComboBoxRenderer(column2Items));
          table.getColumnModel().getColumn(2).setCellEditor(new ComboBoxEditor(column2Items));
                JScrollPane scrollPane = new JScrollPane( table );
          getContentPane().add( scrollPane );
         public void tableChanged(TableModelEvent e) {
                int row = e.getFirstRow();
                int column = e.getColumn();
                if(e.getType() == TableModelEvent.INSERT) {
                if (e.getType() == TableModelEvent.UPDATE) {
                        if(table.getEditingRow() != table.getSelectedRow())
                                ((DefaultCellEditor)table.getCellEditor()).cancelCellEditing();                      
               if ( column == 0 ) {
                                if(model.getValueAt(row, 0).equals("one")) {
                                        model.setValueAt("YES", row, 2);
                                } else if(model.getValueAt(row, 0).equals("two")){
                                        model.setValueAt("NO", row, 2);
                                } else if(model.getValueAt(row, 0) == "three"){
                                        model.setValueAt("NO", row, 2);
                                } else if(model.getValueAt(row, 0) == "four"){
                                        model.setValueAt("NO", row, 2);
                       }else{
                                //do nothing
     public static void main(String[] args)
          final TableComboBox frame = new TableComboBox();
          frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
          frame.pack();
          frame.setVisible(true);
        class ComboBoxRenderer extends JComboBox implements TableCellRenderer {
                String items[];
                public ComboBoxRenderer(String[] items) {
                                super(items);
                                this.items = items;
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                               if(isSelected){
                                        setSelectedItem(value.toString());
                                        return this;
                                }/*else{
                                        setSelectedItem(items[0]));
                        return this;
        class ComboBoxEditor extends DefaultCellEditor {
                public ComboBoxEditor(String[] items) {
                       super(new JComboBox(items));
        }

Similar Messages

  • HTMLLoader problem with comboBox

    hi guys
    I'm trying to loader pdf file using XML to retrieve the URL  and I have CombBox to list all the files ,and I need to load another file every time I change the silder for the CombBox
    the problem is the pdf file load only first time and dosent  change if I select another one from the list, I dont know what the the probelm I tried manything like removeChild and I tried to use container but no change, only first time the file loaded
    this is the code
    cb_list.addEventListener(
    SliderEvent.CHANGE,changehandler);
    function changehandler(e:Event):void {
        var sort1:String=cb_list.value;
        var id:String = myXML.tip.(title == sort1)[email protected]();
         //trace(id)
        var slectedtip = myXML.tip.(title == sort1).fulltip.text();
        tit_label.text=myXML.tip.(@ID == id).title .text();
        date_label.text=myXML.tip.(@ID == id).date.text();
        full_tip.text=myXML.tip.(@ID == id).fulltip.text();
         var flashfileURL = myXML.tip.(@ID == id).picURL.text();
        swfURL.text=flashfileURL;
        var url:String = new String();
        url= myXML.tip.(@ID == id).picURL.text().toXMLString();
        var requestpdf:URLRequest=new URLRequest(url);
         var container:Sprite = new Sprite();
        var pdf = new HTMLLoader();
        pdf.height=stage.stageHeight-150;
        pdf.width=stage.stageWidth-270;
        pdf.y=100;
        pdf.x=260;
        pdf.load(requestpdf);
           pdf.addEventListener(Event.COMPLETE, completeHandler);
        function completeHandler(event:Event):void {
            addChild(pdf);

    [problem with combobox comes infront of popup window|http://forum.java.sun.com/thread.jspa?threadID=5291468]

  • Problem with combobox gets dispalyed infront of popup window

    when ever popup window is open and kept on combobox ,combobox appears in front or overlaps the popup window,where exactly i have to check the code.which place of code i have to look into... plz help if there is any problem with css then plz specify which property i have to look into..

    [problem with combobox comes infront of popup window|http://forum.java.sun.com/thread.jspa?threadID=5291468]

  • Problem with ComboBox / Matrix

    Hi all,
    I have this problem... when I try to populate a column with comboxbox ...
    Code:
            Set co = lmatrix.Columns.Add("orgDist", it_COMBO_BOX)
                co.TitleObject.Caption = "Dist"
                co.Editable = True
                co.Visible = True
                co.DataBind.SetBound True, "@DIST", "Code"
            Set DBSource = lfrm.DataSources.DBDataSources.Item("@DIST")
                DBSource.Query
                For x = 0 To DBSource.Size - 1
                    tp1 = Trim(DBSource.GetValue("Code", x))
                    tp2 = Trim(DBSource.GetValue(3, x))
                    co.ValidValues.Add tp1, tp2
                    DBSource.Offset = x
                Next
    - at the 'co.ValidValues.Add tp1,tp2' I receive this error
      'Valid Value - The Value Exceed boundaries'
    - tp1 max value is of 8 Char
    - tp2 max value is of 50 Char
    I've try to insert manually the value like validvalue.add "101","23123123....213" and it work correctly..
    where is my error??
    Bye!!
    PS: Sorry for my english

    Hi,
    There's no problem with your code itself (however you don't need to set the DBDataSource offset, if you are only filling the ComboBox - GetValue picks the right data anyway...). It works fine (at least with 2004 PL23 + 2005 Build 119).
    Looks like a problem with your data (or some "old" bug, but this would be the first time I heard about it...)?
    ...or did you solve it in the meantime?
    Regards,
    Frank

  • Several Problems with Visual Editor 1.1

    I have installed the latest version of visual editor and also the emf and gef version required,the problem comes when i try to create a new Vsual class after i choose the property of the class such as name and so on and clicked finish My visual editor is empty.....the palette for visual component doesn't appear.
    The visual editor creates a little window and duplicates it evrey time i click in the visualEditor page......please help me...i don't know what i have to do.... i tried the impossible but visual editr still doesn't work!

    Mmm yes it's true, I have a virus checker on my computer...
    and I have tried it twice to download WLS6.1 and always the same problem....so
    I'll try again.
    As for the last point (quick deploy of ejbs without compiling the classes)- Has
    anybody managed to do it? It really could be helpful is somebody, who managed
    to deploy a bean like this (without compiling) could post it to me, so I can examine
    it...
    You can mail it to [email protected]
    Thanks
    Francesco
    David Felts <[email protected]> wrote:
    It sounds like there is a problem with your downloaded version of the
    installer.
    Perhaps your download was corrupted by a running virus checker - we've
    seen that
    before. If you have a virus checker active, flush your browser cache,
    turn off the
    virus checker and reboot. Attempt to download again and run the install
    program.
    You should be prompted for the password and JDK 1.3.1 should be installed
    on your
    system.
    Francesco wrote:
    Hi all,
    I have downloaded WLS 6.1 (NT /2000 version) but
    I found several problems with it.
    1) During the installation I'm not asked anymore
    a password for my domain (feature or bug?)
    2) The installation doesn't install jdk1.3.1
    as required by setEnv.cmd. I have arranged the problem
    pointing to my elder jdk1.3.0 that comes with WLS 6.0 but I don't knowif it's
    correct this behaviour.
    3) I have read in the docs that it's possible to deploy
    EJB in a very quick way, without even compiling the classes.
    So I have tried to pack the basic stateless Trader example
    like this:
    META-INF\
    ejb-jar.xml
    weblogic-ejb-jar.xml
    examples\
    ejb\
    basic\
    statelessSession\
    Trader.java
    TraderBean.java
    TraderHome.java
    TradeResult.java
    But then I get only a Stack-trace full of exceptions stating that
    <3-set-01 13.58.26 GMT+02:00> <Error> <Management> <Error deployingapplication
    \config\mydomain\applications\basic.jar: java.lang.reflect.UndeclaredThrowa
    bleException>
    Is anyone aware about how to solve this problems?
    Thanks
    Francesco

  • Problems with AppleScript Editor.app in Snow Leopard

    I have been using the Satimage.osax scripting addition with Script Editor.app in Leopard without problem. After I upgraded to Snow Leopard, the Script Editor.app was replaced by AppleScript Editor.app in which the following one-line script
    change "," into "." in "3,1416"
    compiles without error but it gives an error when I try to run it: as if AppleScript Editor.app was not able to load the ScriptingAdditions (despite the fact that it correctly shows the dictionary for the Satimage.osax scripting addition).
    When I decided to get back the old "Script Editor.app" and use it in Snow Leopard to run the above script, I found... no error! It ran correctly.
    Anybody observed similar problems with the AppleScript Editor.app and ScriptingAdditions?
    Can anybody offer a solution other than trash the new AppleScript Editor.app and stick to the old Script Editor.app?

    Post to the AppleScript forum under OS X Technologies and send a message to Satimage.

  • Problem with Theme Editor

    Hi,
      I have installed Ep 6.0 SP12 along with KM. I want to customize it, but when I open the theme editor in the portal, it shows portal runtime exception and the stack trace in the logviewer shows "JAVA.lang.outofmemoryerror".
    I upgraded my heapsize to 1.5 GB using config tool.
    but i get the same problem.
    any sort of help is appreciated
    Thank you

    In Addition,
    version info: Ep6.0 Sp12, J2ee engine 6.40
    I have gone all the notes related to themes and also related to out of memory exceptions, but couldnt solve the problem. please let me know if i am missing some note or some patch taht i should apply
       As I said, I am only and only getting this error with theme editor. I select a particular theme to be opened, everything is diplayed except the preview iview, and it shows an exception as follows
    Portal Runtime Error
    An exception occurred while processing a request for :
    iView : pcd:portal_content/administrator/super_admin/super_admin_role/com.sap.portal.system_administration/com.sap.portal.themes/com.sap.portal.theme_editor/com.sap.portal.styleeditor
    Component Name : com.sap.portal.themes.editor.default
    and the exception in stack trace is as follows i.e. in defaultTrace.trc
    1.5#00306E5D9ABC005900000016000020A10003FEB6B46FFD8D#1124485594327#com.sap.portal.portal#sap.com/irj#com.sap.portal.portal#RRY2#1556####1f8dce7010f511dab64600306e5d9abc#SAPEngine_Application_Thread[impl:3]_24##0#0#Error#1#/System/Server#Java###Exception ID:04:06_19/08/05_0001_165044050
    [EXCEPTION]
    #1#com.sapportals.portal.prt.component.PortalComponentException: Error in service call of Portal Component
    Component : pcd:portal_content/administrator/super_admin/super_admin_role/com.sap.portal.system_administration/com.sap.portal.themes/com.sap.portal.theme_editor/com.sap.portal.styleeditor
    Component class : com.sapportals.portal.ssd.StyleSheetDesigner
    User : xyz
    at com.sapportals.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:969)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:343)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:646)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:154)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:392)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
    at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:159)
    Caused by: java.lang.OutOfMemoryError
    so could some one please help me in this regard as i am stuck here..
    seen some note 866009, but as said there, my hierarchy is perfect. There was something mentioned about sps13, but i didnt apply that as my version is sps12
    please help me in this regard
    Thank you

  • Custom DataGrid problems with Comboboxes

    I am using a custom datagrid with comboboxes and
    colorpickers. I found this code on the web and adapted it to work
    with my code. The only problem is that if you pull down a combobox
    and then click somewhere outside without selecting anything, it
    seems to erase the data in the dataprovider arraycollection and so
    'value' in the set data method becomes null.

    This is not a bug if I understand you properly. I believe most people would wish anything which is obtained via the tv to be backed up, which is why the content is transferred. If you want it to remain available on the tv you will need to sync it back to it.

  • Problem with text editor font

    Hiii..
    Actually I am facing some problems with the text editor font. Since I have some part of text was written in arabic (For labels), currently these parts are not readable and appears like this:
    "ط§ط³ظ… ط§ظ„ط¥ط¯ط§ط±ط© ط§ظ„طھط¯ط±ظٹط¨ظٹط©"
    I have tryed to fix that using:
    Tools --&gt; Preferences --&gt; Code Editor --&gt; Font
    However it still arise.
    Please reply me the solution if you have some idea about this..
    Regard's

    Which JDeveloper version?
    What is the character encoding settings for your project's compiler in the project properties?

  • Problem with condition editor in Interface determination

    Hi,
    I have 5 receivers for an interface. There are some conditions based on which the message should be processed.
    one of my condition is:
    If field A = CIT* and (field B != IDP or field C != IDP*) then message should be processed to a particular InterfaceMap(Messaeg Map).
    I am facing problems when giving the condition with != in the condition editor of InterfaceDetermiantion.
    When I send a message that is not satisfying the above condition, even then an output file with 0kb is getiitng created. But in this case, the condition should obstruct the message going to Message mapping.
    I thought this could be the problem with != operator in condition editor.
    Can any one suggest if there is any other way that i can proceed.
    Thanks in advance,
    Minisha.

    Hi Suraj,
    Thanks for the suggestion.
    But it didnt work for me.
    Even when i give empty-message handling to ignore, the empty file is getting generated.
    Not even the condition is working.
    I tried only giving (field A u2248 CIT* AND field B != IDP EX ), which should work in this case. As expected, the message is not processed beyond this as the condition is false. But problem is when i tested with other testfile with which the condition given is true, still the message is not being processed. it is now completely obstructing the message even if the condition is true.
    Thanks,
    Mnisha.
    Edited by: Minisha Uthaman on Sep 10, 2009 4:12 PM

  • Problem with themes editor projects

    Hi Gurus!
    I'm having a problem with SAP NetWeaver Developer Studio.
    Version: 2.0.14
    Build id: 200509100215
    I'm using SAP/UR Design Themes' view. I'm trying to import a Design file (.zip) and the Developer return me error: "The Design could not be imported. Datamanager could not be initialized!"
    Can anybody help me? I don't have idea about this!
    Thanks a lot!!!!

    You better post that question in e.g. the SAP NetWeaver Platform forum. In the Visual Composer forum you might not get the right people with the answers.
    Mario

  • Problems with B2B Editor validating HL7 Messages

    Hi all,
    I am having some problems related to B2B Document Editor and HL7 messages.
    When we ran the Analyzer with the following document:
    MSH|^~\&|ALERT|CHVNG|CPCHS|CHVNG|20070409145826+0000||OMG^O19^OMG_O19|1|P|2.4|
    PID|||303030^^^SONHO^NS||Patient^Alert||19840412000000+0000|M|||ESTRADA DA BARROCA, LOTE C O, FRT^^ENTRONCAMENTO^^2430|||||||^^^CHVNG|
    PV1||URG|1^33^^1||||||||||||||||27041729^^^CHVNG||||||||||||||||||||||||||||||||V|
    ORC|NW|100^ALERT|||||||20070409145813+0000|||123^Teste^M\XE9\dico^^^^^^^^^^ON|||||2000^RADIO TEXT^CHVNG|
    OBR||100^ALERT||M11020^Abd\XF3\men Simples Em P\XE9\^RADIO||||||||||||123^Teste^M\XE9\dico^^^^^^^^^^ON|
    NTE|||dor abdominal|
    we received the following message:
    "The data starting at position 510 is not a valid EDI interchange. The remainder of the data file was ignored. "
    It identifies the header (MSH Segment) well, but it can not identify the message body.
    It is very strange, because we've selected HL7 as the message format on the previous step but aparently this message is a EDI format message. This message occurs on any file we have or with any HL7 message found on the internet (http://www.dt7.com/cdc/sampmsgs.html)
    We can open the document with the Data Editor, but if we change any value and save it, it is impossible to open the message with the Analyzer:
    "The data in the file could not be parsed. Please check the file to verify that it is valid and formatted correctly. This error can occur for one of the following reasons: A) The data file may be a Word document or have some other binary format. B) The envelope data may not be formatted properly. If this is an X12 data file, please verify that the ISA segment is the correct size (exactly 106 characters). If this is an EDIFACT data file, it must have either a UNA or begin with UNB. For other standards, verify that the envelope segments conform to the specified rules. C) The segment/record delimiters in the file are incorrect."
    We are running the B2B Document Editor version 6.0.0.1471 with the 6.0.4.84 version of HL7 Database version.
    Can you give us any advice ?
    Cheers,
    Rodrigo Nascimento

    Hello,
    As per Jeff's post even we have observed OD OA at the end of the line. Please use a hex editor or B2B document editor to correct the same. We have done the above steps and are not getting the mentioned errors. HTH.
    Please let us know.
    Rgds,Ramesh

  • 2007A - Problem with Combobox.Selected with an empty value

    Hi all,
    I 've tried to launch my add-on created with SBO 2005 SP1
    on 2007 client.
    I've a problem when I try to do
    myCombobox.Selected.Value
    when the valid value is empty.
    Selected is null and I've an error.
    So I must test each Combobox by doing this :
    if( myCombobox.Selected is null)
    But I've hundreds of this case in my code.
    Does an another solution exists?
    Thanks

    you have the same problem in every business one version.
    you first have to check if the property is not null/nothing
    the only other way is that you use try / catch
    value = oform.Items.Item("cmb1").Specific.selected.value()
    Catch ex As Exception
       value = ""
    End Try
    but the effort is the same for you

  • PC Suite 6.83.14.1 problem with Text Editor

    Hi,
    I'm getting error while executing the Text Editor of PC Suite and Click on To. for selecting the address.
    I'm using USB cable to connect my phone with the Notebook.
    I found the below error.
    AppName: textmessageeditor.exe AppVer: 6.83.108.5 ModName: msvcr71.dll
    ModVer: 7.10.3052.4 Offset: 00010440
    In order to troubleshoot, I have carried out the following activities :-
    1. Uninstalled the PC Suite 6.83.14.1
    2. Used the Nokia PC Suite Cleaner
    3. Installed the PC Suite 6.83.14.1
    But the problem still persists.
    My System details are as follows:
    Operating system:
    Microsoft Windows XP
    Build 2600
    Service Pack 2
    Language: English
    Language for non-Unicode programs: English
    Locale: English
    Input language: English
    Nokia PC Suite:
    Version 6.83.14.1
    Language: English
    Connectivity Cable Drivers:
    Version 6.83.9.0
    PC Connectivity Solution:
    Version 7.7.10.0
    No supported Bluetooth stack found
    Regards,
    Dwarika

    Please find the logs attached.
    Attachments:
    e8a5_appcompat.txt ‏1 KB

  • Serious problems with Table Editors - Urgent

    Hi to all. I have a table of doubles that I wish to implement a table editor so that I can detect when the user inserts some incorrect number and display a convenient warning message.
    Here is my code for my Editor (TableGasEditor). I have tried to follow the code of the tutorial How to use JTables:
    import javax.swing.AbstractAction;
    import javax.swing.DefaultCellEditor;
    import javax.swing.JFormattedTextField;
    import javax.swing.JOptionPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.KeyStroke;
    import javax.swing.SwingUtilities;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import java.awt.Component;
    import java.awt.Toolkit;
    import java.text.NumberFormat;
    import java.text.ParseException;
    import javax.swing.text.DefaultFormatterFactory;
    import javax.swing.text.NumberFormatter;
    public class TableGasEditor extends DefaultCellEditor {
    JFormattedTextField ftf;
    NumberFormat doubleFormat;
    private Double minimum=new Double(0);
    final int DECIMAL_MAX = 3;
    public TableGasEditor(int min) {
    super(new JFormattedTextField());
    ftf = (JFormattedTextField)getComponent();
    minimum = new Double(min);
    doubleFormat = NumberFormat.getNumberInstance();
    doubleFormat.setMaximumFractionDigits(DECIMAL_MAX);
    NumberFormatter intFormatter = new NumberFormatter(doubleFormat);
    intFormatter.setFormat(doubleFormat);
    intFormatter.setMinimum(minimum);
    ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
    ftf.setValue(minimum);
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
    ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    ftf.getActionMap().put("check", new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
    if (!ftf.isEditValid()) {
    if (userSaysRevert())
    ftf.postActionEvent();
    else try {            
    ftf.commitEdit();
    ftf.postActionEvent();
    } catch (java.text.ParseException exc) { }
    public Component getTableCellEditorComponent(JTable table,
    Object value, boolean isSelected,
    int row, int column) {
    JFormattedTextField ftf =
    (JFormattedTextField)super.getTableCellEditorComponent(
    table, value, isSelected, row, column);
    ftf.setValue(value);
    return ftf;
    public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField)getComponent();
    Object o = ftf.getValue();
    if (o instanceof Double)
    return o;
    else if (o instanceof Number) {
    return new Double(((Number)o).doubleValue());
    } else {
    try {
    return doubleFormat.parseObject(o.toString());
    } catch (ParseException exc) {
    System.err.println("getCellEditorValue: can't parse o: " + o);
    return null;
    public boolean stopCellEditing() {
    JFormattedTextField ftf = (JFormattedTextField)getComponent();
    if (ftf.isEditValid()) {
    try {
    ftf.commitEdit();
    } catch (java.text.ParseException exc) { }
    } else {
    if (!userSaysRevert()) {
         return false;
    return super.stopCellEditing();
    protected boolean userSaysRevert() {
    Toolkit.getDefaultToolkit().beep();
    ftf.selectAll();
    Object[] options = {"Edit",
    "Revert"};
    int answer = JOptionPane.showOptionDialog(
    SwingUtilities.getWindowAncestor(ftf),
    "The value must be a number bigger than "
    + minimum + ". "
    + "You can either continue editing "
    + "or revert to the last valid value.",
    "Invalid Text Entered",
    JOptionPane.YES_NO_OPTION,
    JOptionPane.ERROR_MESSAGE,
    null,
    options,
    options[1]);
    if (answer == 1) { //Revert!
    ftf.setValue(ftf.getValue());
         return true;
         return false;
    And this is the code that I use to set this editor as my table's editor:
    gasTable.setDefaultEditor(Double.class,new TableGasEditor(0));
    The problem is that if I insert a value like:
    15a.15
    the editor acepts the value as it was valid, but it appears only until the valid part of the number. In this example, it only appears this:
    15
    What I intended was the same behaviour it has when I insert a value like this:
    aa15
    The Editor launches the Dialog with the message warning.
    Any idea of what I'm doing wrong, and how can I resolve it?
    I think it might have something to do with the Numberformat, but in spite of having already read the documentation I still didn't figure it out what I was doing wrong....
    Any help would VERY helpfull, since I'm completely stuck in this and have a deadline for tomorrow!:(
    Thanks.
    Fenryl

    Hi there,
    I dont have enough time to test your code, but I see the following errors:
    If the input is not a number, you parse it by:
    doubleFormat.parseObject(o.toString());
    1/ I dont see parseObject(String). I only see parseObject(String source,
    ParsePosition pos)
    Let's assume you use parse(String), then what you got is correct. From API, parse(String)
    "Parses text from the beginning of the given string to produce a number". So if the input is 15a.15, it's normal you get 15 as a result. You only got the exception if "the beginning of the specified string cannot be parsed." which is not the case here, but it is the case as the input is aa15
    2/ I think you dont need to use NumberFormat here. How about using Double.parseDouble(String) ?
    Hope this helps,

Maybe you are looking for

  • Help me! why can not start oracle management server?

    maybe for my shutdown and startup database abnormal for several times,now the server oracleorahome81management server can't start and while i logon to enterprise manager console,it show me a error as follow "vtk-1002:The Oracle Management Server you

  • Adobe DIgital Edition 2.0 has stopped working on my windows 7 program.  How to fix this problem?

    I currently have Adobe Digital Edition 2.0 and am receiving the message that it has "stopped working".  How do I correct this problem?

  • Disk Repairs Please Help!

    I know there are many posts about this problem, but none of them have seemed to help me out.  My Imac runs fast and fine, but when i pull up safari pages take unusually long to load and sometimes dont completely load without saying something like "23

  • Infamous SocketException: Broken Pipe

    Hello, As with many of the other users on this forum I have been plagued by the Broken Pipe SocketException, very rarely, which seems to essentially block on the java.net.SocketOutputStream.socketWrite0(Native Method) for quite a long time (presumabl

  • External drive partitioning problem

    while trying to resize partition on my external drive with disk utility I get a message: Partition failed with the error: Filesystem resize support required, such as HFS+ with Journaling enabled Disk format is Mac OS Extended (Journaled) - isn`t it H