Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
  1. #21
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    There might be a better way, but if it were me, I would create a method called initF1ActionMap() and add the action map to every component in your initComponent method...

    I would skip JButtons, ButtonGroups and JLabels...



    Java Code:
            optPane1 = new javax.swing.JOptionPane();
            buttonGroup1 = new javax.swing.ButtonGroup();
            jPanel1 = new javax.swing.JPanel();
            txtMembership = new javax.swing.JTextField();
            txtJdate = new javax.swing.JTextField();
            txtAge = new javax.swing.JTextField();
            txtGender = new javax.swing.JTextField();
            cmdNew = new javax.swing.JButton();
            cmdAdd = new javax.swing.JButton();
            cmdSearch = new javax.swing.JButton();
            cmdFirst = new javax.swing.JButton();
            cmdHelp = new javax.swing.JButton();
            cmdExit = new javax.swing.JButton();
            cmdUpdate = new javax.swing.JButton();
            cmdReset = new javax.swing.JButton();
            JheightWeightPanel = new javax.swing.JPanel();
            txtHeight = new javax.swing.JTextField();
            txtConvHeight = new javax.swing.JTextField();
            txtWeight = new javax.swing.JTextField();
            txtConvWeight = new javax.swing.JTextField();
            cmdConvert = new javax.swing.JButton();
            jLabel5 = new javax.swing.JLabel();
            jLabel7 = new javax.swing.JLabel();
            jRmetric = new javax.swing.JRadioButton();
            jRimp = new javax.swing.JRadioButton();
            jBmiPanel = new javax.swing.JPanel();
            txtBmi = new javax.swing.JTextField();
            txtResults = new javax.swing.JTextField();
            jLabel8 = new javax.swing.JLabel();
            jLabel9 = new javax.swing.JLabel();
            cmdCal = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            Limage = new javax.swing.JLabel();

    But... A draw back to this answer is that every time you add a new component you will also have to update your intiF1actionMap()
    Who Cares... As Long As It Works...

  2. #22
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    good luck mark! myself, I'll take an SSCCE any day.

  3. #23
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    LOL... I did enjoy the guidelines of SSCCE...
    Who Cares... As Long As It Works...

  4. #24
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Default

    So just to clarify your saying that the section of code you have listed above is where I need to add the code, its just that this is system generated code and that I cannot add anything to it

  5. #25
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    That does pose a problem...
    Who Cares... As Long As It Works...

  6. #26
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Nah, no problem. Loose the system generated code, learn Swing, problem solved. Not only will you have better overall control of your program, the information that you've learned in your studies will mean that you'll not have to ask questions here as often, but rather you'll be answering them. Good luck.

  7. #27
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    You can't argue with that...

    But for now, I checked out netbeans's JFrame form and if you click on the source button on the menu bar directly above your design, it will display your code... You can add any custom code you want...
    Who Cares... As Long As It Works...

Page 2 of 2 FirstFirst 12

Similar Threads

  1. keyListener isn't working for me
    By lost_in_java in forum AWT / Swing
    Replies: 7
    Last Post: 12-05-2008, 04:24 AM
  2. KeyListener Example
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 04:46 PM
  3. How to use KeyListener and ActionListener
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 04-23-2008, 08:19 PM
  4. how to add a KeyListener
    By leonard in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 04:44 PM
  5. Help with KeyListener in applet
    By mathias in forum Java Applets
    Replies: 1
    Last Post: 08-06-2007, 02:22 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
  •