[Solved] how to fix Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException: class javax.swing.JLabel cannot be cast to class java.lang.String


You get the exception because you are trying to cast a JLabel to String.

at row=0 cloumn=0 is a JLabel and I want to get value of JLabel and put in query

Display((String) table.getValueAt(0, 0));

If you want the text-content of a label, use JLabel.getText() instead:

JLabel label = (JLabel)table.getValueAt(0, 0);
String text = label.getText();
Display(text);

Side Note: According to the usual coding conventions for Java, method names should start with a lower case letter, therefore Display() should be renamed to display().

0

solved how to fix Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException: class javax.swing.JLabel cannot be cast to class java.lang.String