Search code examples
javaif-statementnetbeans

Java: If Statement Conditions can't Set the Value of the Components


I am trying to set the value of Text Field component and ComboBox Component using If statement So, there are 2 files on my project The first Java files contain the public method that called isCek here how it looks like

public void isCek(String kamar) {
    if(kamar!= null){
      System.out.println(kamar);
      JenisPasien.setSelectedIndex(1);
      AsalKamar.setText(kamar);
    }else{
      System.out.println(kamar);
      JenisPasien.setSelectedIndex(0);
      AsalKamar.setText("-");
    }

And the second Java file contain a method that uses the isCek method from my first file here's the code

        RMPenilaianMedisLanjutanHemodialisa form = new RMPenilaianMedisLanjutanHemodialisa(null, false);
        form.isCek(tbKamIn.getValueAt(tbKamIn.getSelectedRow(),7).toString());

On the terminal output, it shows that if statement works fine

But, JenisPasien (ComboBox) and Asal Kamar (Text Field) don't set the value

Can anyone help me with this issue? Thank you


Solution

  • After I checked my whole script, there is an AsalKamar.setText() on a different line that makes if else script above doesn't work Btw, thank all of your help