Converter object to string

1 resposta
M

olá pessoal
estou tentando converter um object para uma string
mas dá erros
alguém pode me ajudar

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		getCell().setText( value.toString() );
		return getCell();
	}

erro :

Exception in thread AWT-EventQueue-0 java.lang.NullPointerException

at Tabela_Moeda_Celula_Render.getTableCellRendererComponent(Tabela_Moeda_Celula_Render.java:37)

at javax.swing.JTable.prepareRenderer(Unknown Source)

at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)

at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)

at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)

at javax.swing.plaf.ComponentUI.update(Unknown Source)

at javax.swing.JComponent.paintComponent(Unknown Source)

at javax.swing.JComponent.paint(Unknown Source)

at javax.swing.JComponent.paintToOffscreen(Unknown Source)

at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)

at javax.swing.RepaintManager.paint(Unknown Source)

at javax.swing.JComponent.paintForceDoubleBuffered(Unknown Source)

at javax.swing.JViewport.blitDoubleBuffered(Unknown Source)

at javax.swing.JViewport.windowBlitPaint(Unknown Source)

at javax.swing.JViewport.setViewPosition(Unknown Source)

at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.hsbStateChanged(Unknown Source)

at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(Unknown Source)

at javax.swing.DefaultBoundedRangeModel.fireStateChanged(Unknown Source)

at javax.swing.DefaultBoundedRangeModel.setRangeProperties(Unknown Source)

at javax.swing.DefaultBoundedRangeModel.setValue(Unknown Source)

at javax.swing.JScrollBar.setValue(Unknown Source)

at javax.swing.plaf.basic.BasicScrollBarUI$TrackListener.setValueFrom(Unknown Source)

at javax.swing.plaf.basic.BasicScrollBarUI$TrackListener.mouseDragged(Unknown Source)

at java.awt.Component.processMouseMotionEvent(Unknown Source)

at javax.swing.JComponent.processMouseMotionEvent(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(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown 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.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

ja tentei tambem :

getCell().setText((String) value);

mas dai nao acontece nada, nao da erro, nao sei se converte, mas o valor que precisava aparecer nao aparece …

Obrigado

1 Resposta

T
getCell().setText( value == null ? "" : value.toString() );
Criado 4 de novembro de 2008
Ultima resposta 4 de nov. de 2008
Respostas 1
Participantes 2