My applications process patient records. In the main frame, the user can open several internal frames. Each internal frame contains a tabbed panel, and each tab created by the user contains a form in which he can enter patient data and jtable, which shows all the added patients.
When the user clicks on the row (patient) in the jtable, the form fields are filled in with the patient data, and when he presses "Escape", the form fields are cleared and the user can continue searching / checking / entering another patient.
My problem is that this escape key event throws a classCastException in the Appearance of the sensation I'm using. The code I wrote for the action performed works fine. This problem has occurred since I started using tabbed panels (before everything was done in one panel). If I change the appearance, for example, on Windows, there will be no exception. Do you have any ideas?
Here is a sample code:
private void db_existKeyReleased(java.awt.event.KeyEvent evt) {
if(evt.getKeyCode()==KeyEvent.VK_ESCAPE)
{
searchField.requestFocusInWindow();
if(searchField.getText().length()>=1)
{
dataPane.setPid(-1);
dataPane.getPersonalDataPane().clearAll();
treat_diagPane.getDiagnosis_pane().clearAll();
treat_diagPane.getTreat_pane().clearAll();
}
DefaultTableModel model=new DefaultTableModel(
new Object [][] {
},
new String [] {
bundle.getString("lname"), bundle.getString("fname"), bundle.getString("date_birth"), bundle.getString("occupation")
});
db_exist.setModel(model);
}
This is an exception:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JTabbedPane cannot be cast to javax.swing.JDesktopPane
at javax.swing.plaf.basic.BasicDesktopPaneUI$Actions.actionPerformed(BasicDesktopPaneUI.java:329)
at org.jvnet.lafwidget.tabbed.TabPagerWidget$4.actionPerformed(TabPagerWidget.java:158)
and this is the code that throws the exception:
public void actionPerformed(ActionEvent e) {
JDesktopPane dp = (JDesktopPane)e.getSource();
String key = getName();
if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key ||
RESTORE == key) {
setState(dp, key);
}
else if (ESCAPE == key) {
if (sourceFrame == dp.getSelectedFrame() &&
focusOwner != null) {
focusOwner.requestFocus();
}
moving = false;
resizing = false;
sourceFrame = null;
focusOwner = null;
}
source
share