You mention that you switched to using JTabbedPane, but in your "actionPerformed" method code you still cast to "JDesktopPane" and the stacktrace says: 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 Probably changing it to: if(e.getSource() instanceof JTabbedPane) { JTabbedPane = (JTabbedPane)e.getSource(); } might be the change you need to do.
You are very right, but unfortunately the code that causes the exception is not mine but substance look and feel, and unfortunately I cannot change it, and if I could I don't know if that would cause other problems. Is it possible that some look and feels don't "run" properly for some applications? Should I just change the look and feel?
Thank you so much for your immediate answer! Awesome work in here! – gosling Jan 11 '10 at 11:42 Sorry, I am not aware of 'Substance' look and feel and I had posted my answer entirely looking at the stacktrace, and assuming that you can modify code in actionPerformed method.
I hope knowlegable users of Substance LF would provide a solution that would work for you. – sateesh Jan 11 '10 at 11:56.
Use keybindings this.getRootPane(). GetInputMap(JComponent. WHEN_IN_FOCUSED_WINDOW).
Put(KeyStroke. GetKeyStroke(KeyEvent. VK_ESCAPE, 0), "fecharAction"); this.getRootPane().getActionMap().
Put("fecharAction", new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { int resp = JOptionPane. ShowConfirmDialog(MainForm. This, "Encerrar sistema?", "Confirmação", JOptionPane.
YES_NO_OPTION, JOptionPane. QUESTION_MESSAGE); if (resp == 0) { MainForm.this. SetVisible(false); MainForm.this.dispose(); } } }).
When the user clicks a row(patient) in the jtable the form's fields is filled by patient's data and when he presses "Escape" the form's fields are cleared and the user can go on to search/check/enter another patient. My problem is that this escape key event, throws a classCastException in the Substance look and feel I use. The code I've written for the action performed works fine.
This problem appeared since I started to use tabbed panes (before everything was made in a single pane). If I change look and feel to e.g. Windows no exception is thrown. Do you have any idea?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.