Results 1 to 2 of 2
- 08-24-2009, 04:14 PM #1Member
- Join Date
- Jan 2009
- Rep Power
Problems with ActionEvent for JButton
I'm having problems getting an ActionEvent on a JButton to fire the first time the JButton is clicked. I have a JTabbedPane where each pane contains a JPanel inside a JScrollPane. On one of the panes (not the first) are two JFormattedTextFields, a JTable, and four buttons, one of which is enabled when the user selects that tab. The problem I'm running into, and the one that annoys our clients, is that it always takes two clicks to get the ActionEvent for this JButton to fire. I've tried a number of things: invoking requestFocus() on the JPanel and on the JButton when that tabbed pane is selected, setting the button up as the default button on the pane, etc. But nothing I've tried seems to work. If I physically select any of the other controls in the panel, then the first time the JButton is clicked, the ActionEvent fires. But if the user clicks the JButton immediately after the tabbed pane is selected, the event doesn't fire. Can anyone give me some ideas on what could be causing this?
I think that your best bet here is to post some compilable code. Don't post your entire program but instead just create a simple program that has a JTabbedPane, perhaps a JPanel in a JScrollPane and button with a simple actionlistener, just enough widgets to reproduce your problem, and no extraneous widgets or code, a Short, Self Contained, Correct (Compilable), Example or "SSCCE". If you can post this, and again, if this is capable of demonstrating your problem, I can almost guarantee that you'll be able to get "helpful" help soon.
Best of luck.
- By jon80 in forum New To JavaReplies: 0Last Post: 05-23-2009, 04:26 PM
- By playwin2 in forum AWT / SwingReplies: 8Last Post: 08-27-2008, 11:48 PM
- By Cymro in forum New To JavaReplies: 3Last Post: 04-04-2008, 07:11 AM
- By Java Tip in forum Java TipReplies: 0Last Post: 03-12-2008, 12:00 AM
- By susan in forum AWT / SwingReplies: 3Last Post: 08-07-2007, 04:19 AM