Results 1 to 2 of 2
  1. #1
    TrueBear is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default 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?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    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.

Similar Threads

  1. Replies: 0
    Last Post: 05-23-2009, 04:26 PM
  2. Replies: 8
    Last Post: 08-27-2008, 11:48 PM
  3. [SOLVED] Actionevent problem
    By Cymro in forum New To Java
    Replies: 3
    Last Post: 04-04-2008, 07:11 AM
  4. ActionEvent example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-11-2008, 11:00 PM
  5. Problems with jButton ActionPerformed
    By susan in forum AWT / Swing
    Replies: 3
    Last Post: 08-07-2007, 04:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts