Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JButton trouble

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JButton trouble

    I'm new to this forum, and I hope I'm posting this in the right area. I thought this would be best. I'm new to Java as well and am having a bit of a snag. I'm using NetBeans 7.1 and I'm fooling around with the idea of a turn-based RPG style game. Well using code generated by the GUI designer from NetBeans, I'm trying to make sure that when a button is pressed, it's action will only be carried out if it's the users turn. The best way I could really see to do this was have the listeners operate from an external class that controls the flow of battle. I've searched everywhere and in this forum but really all I can tell is that it is possible to do it, but not and real direction as to how. I could really use some insight into this from more experienced programmers.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JButton trouble

    My first piece of advice - ditch the GUI builder for the time being. If you are new to development in this area, then knowing how to design a user interface without the builder goes a long way towards not only making more customized designs, but in debugging and adapting code. My second piece of advice, it you wish to fire an action only under a certain condition, then make a flag (this could be a boolean if you wish) of that condition and evaluate it prior to completing the action

  3. #3
    Member
    Join Date
    Feb 2012
    Posts
    58
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: JButton trouble

    Use some sort of flag - turn it on when user gets turn, and turn it off when action completed.

Similar Threads

  1. JButton listener trouble...
    By sparky5783 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 13th, 2011, 01:19 PM
  2. Help with jButton
    By ls7897 in forum AWT / Java Swing
    Replies: 6
    Last Post: March 13th, 2011, 03:22 PM
  3. JButton help
    By tabutcher in forum Java Applets
    Replies: 4
    Last Post: March 9th, 2010, 07:04 PM
  4. JButton Help
    By ravjot28 in forum AWT / Java Swing
    Replies: 3
    Last Post: January 17th, 2010, 11:38 AM
  5. JButton...
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 27th, 2009, 11:39 AM

Tags for this Thread