Results 1 to 5 of 5
  1. #1
    kushiG is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default please help me in editing a table cell in AWT

    Hi All,

    Can any one please help me in editing a column in a table, and type a new value in the cell and update it in the database.

    I need a piece of code from begining,

    and one more thing is I wanted to edit int values

    Please help me,

    Thnak you very much

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    This is not a code-production service. If all you need is the code, then you probably want to pay for it at rent a coder . com. If on the other hand you want help from volunteers, then please show us your work and ask specific questions regarding your code.

    edit: I also deleted your hijack post in the other thread. If you need to reference another thread, then do so as a link in this thread, but please don't hijack another's thread.

    Much luck.

  3. #3
    kushiG is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    Hello Sir Fubarable,

    I am new to this Java Forums, and so I did like that without knowing,

    I m very sorry for that,

    Thank you very much,

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,039
    Rep Power
    10

  5. #5
    kushiG is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    Hi All,

    Can any one help me in getting the editing value of a cell,

    My main idea is I should edit a table cell and modify the value and I placed an update button and when I click on that the should be updated in the database.

    But when I am getting the value of the editig cell I am getting an error, I had used the code as follows

    Java Code:
    column.setCellEditor(new MyTableCellEditor());	
    
    //MyTableCellEditor  class
    
    
    public class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor {
    	JPanel jpanel = new JPanel(new BorderLayout(5,5));
      
    	JTextField tfield = new JTextField();
    	
    	
    	public MyTableCellEditor()
    	{
    		jpanel.add(tfield);
    	}
    	
    	
    	public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
    	{
    		tfield.setText(String.valueOf(value));
    		return jpanel;
    	}
    	
    	public Object getCellEditorValue()
    	{
    		
    		String  nucritical = tfield.getText();
    		//tfield.getText(Integer.parseInt(nucritical));
    		  int i = Integer.parseInt(nucritical);
    		
    		System.out.println(i);
    		 return tfield.getText();
    	   
    	}
    }
    
    
    private JButton getUpdateButton() {
    			if (this.updateButton == null) {
    				this.updateButton = new JButton("Update");
    				this.updateButton.addActionListener(new ActionListener() {
    					public void actionPerformed(ActionEvent event) {
    						updateButton_actionPerformed(event);
    					}
    				});
    			}
    			return this.updateButton;
    		}
    	  
    	  private void updateButton_actionPerformed(ActionEvent event)
    	  {
    		  [B]MyTableCellEditor editor = new MyTableCellEditor();
    		  
    		  Object newcritical = editor.getCellEditorValue();
    	      String nucritical = newcritical.toString();
    	      int i = Integer.parseInt(nucritical);
    	      
    		  System.out.println(i);[/B]	  
    	  }


    I am getting the error as follows
    Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(Unk nown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at client.cpm.dailyT8.alarm.MyTableCellEditor.getCell EditorValue(MyTableCellEditor.java:36)
    at client.cpm.dailyT8.alarm.CBRCPMDailyT8Update.updat eButton_actionPerformed(CBRCPMDailyT8Update.java:1 07)
    at client.cpm.dailyT8.alarm.CBRCPMDailyT8Update.acces s$0(CBRCPMDailyT8Update.java:103)
    at client.cpm.dailyT8.alarm.CBRCPMDailyT8Update$1.act ionPerformed(CBRCPMDailyT8Update.java:96)
    at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    Can any one help me and give an idea to solve this error and get the data


    Thanks in advance

Similar Threads

  1. Programmatically starting cell editing in JTable
    By javaexplorer in forum AWT / Swing
    Replies: 2
    Last Post: 05-21-2010, 05:33 PM
  2. If on cell of table
    By Tovam in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 05-18-2010, 09:34 AM
  3. Start editing in a cell in JTable on gaining focus
    By javaexplorer in forum AWT / Swing
    Replies: 2
    Last Post: 05-05-2010, 08:34 AM
  4. Colour Specific Cell within Table
    By poddy88 in forum New To Java
    Replies: 2
    Last Post: 04-14-2009, 09:20 AM
  5. jTable Cell editing
    By mahaling_m in forum AWT / Swing
    Replies: 0
    Last Post: 06-23-2008, 09:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •