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: I'm sure it is really simple but it is driving me crazy

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I'm sure it is really simple but it is driving me crazy

    I am not a great programmer but I need to make a simple rule management system, the problem I am having is that due to the number of options I had to divide it up over two separate JFrames, what I have done so far is that when the' Next' button is clicked it will combine the users input into a single String which works fine but I need to access this String from the new class on the second JFrame at this point it seems what ever I try I end up with a null-point exception.

    This is the code for my button (not including any of my poor attempts to pass it over!):

    private void cmdnextActionPerformed(java.awt.event.ActionEvent evt) {
    ruleHeader = (String)lsbaction.getSelectedItem() + " " + (String)lsbprotocol.getSelectedItem();
     
    if (cbsourceipany.isSelected()){
    ruleHeader = ruleHeader + " any";
    }else{
    ruleHeader = ruleHeader + " " + txtsource.getText() + (String)lsbsourcex.getSelectedItem();
    }
    if (cbsourceportany.isSelected()){
    ruleHeader = ruleHeader + " any";
    }else{
    ruleHeader = ruleHeader + " " + txtsport.getText();
    }
     
    if (cbdirect.isSelected()) {
    ruleHeader = ruleHeader + " <> ";
    }else{
    ruleHeader = ruleHeader + " -> ";
    }
     
    if (cbdestipany.isSelected()){
    ruleHeader = ruleHeader + " any";
    }else{
    ruleHeader = ruleHeader + " " + txtdest.getText() + (String)lsbdestx.getSelectedItem();
    }
    if (cbdestportany.isSelected()){
    ruleHeader = ruleHeader + " any";
    }else{
    ruleHeader = ruleHeader + " " + txtdestport.getText();
    }
    txttest1.setText(ruleHeader);
     
    new Rule_Addition_Options().setVisible(true);
    }


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: I'm sure it is really simple but it is driving me crazy

    Heya,
    First thing's first, Welcome .
    • When posting code, surround the code with tags, such as the ones in my sig.
    • Can you paste in the exception? what is throwing the null-pointer?
    • Can you confirm that everything has been initialised? i.e "lsbprotocol".

    Some people may be able to actually find your issue straight from that code, but it's rather hard when there's no details about the components you're using
    Does your JComboBox have any content, or is it an empty list? (Although I'm not sure if it would throw a null-pointer if it didnt )

    If I've understood your specifications properly, is there a reason you can't simply make a getter method that returns a String?
    Last edited by newbie; January 15th, 2011 at 02:01 PM.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: I'm sure it is really simple but it is driving me crazy

    Moved to - AWT / Java Swing - Java Programming Forums
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Crazy array
    By javapenguin in forum What's Wrong With My Code?
    Replies: 18
    Last Post: June 26th, 2010, 03:02 AM
  2. [SOLVED] Should be simple.
    By Time in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 22nd, 2010, 02:23 AM
  3. urgent simple help for a very simple program
    By albukhari87 in forum Java Applets
    Replies: 4
    Last Post: June 5th, 2010, 03:43 PM
  4. not so simple, simple swing question box
    By wolfgar in forum AWT / Java Swing
    Replies: 2
    Last Post: November 20th, 2009, 03:47 AM
  5. [SOLVED] NullPointerException in Poker's program
    By dean_martin in forum Exceptions
    Replies: 10
    Last Post: April 21st, 2009, 06:40 AM