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!):
Code Java:
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);
}
Re: I'm sure it is really simple but it is driving me crazy
Heya,
First thing's first, Welcome :P.
- 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 :P
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 :D)
If I've understood your specifications properly, is there a reason you can't simply make a getter method that returns a String?
Re: I'm sure it is really simple but it is driving me crazy