0
 private JTable getTRent() {
    if (tRent == null) { ...

        tRent.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent arg0) {
                tDescription.setText(house.getDescripcionMansion(tRent.getSelectedRow()));

                image.setIcon(new ImageIcon(BookWindow.class.getResource(
                        "/images/" + house.getCodeMansion(tRent.getSelectedRow()) + ".png")));

                String childrenAllowed = house.getChildrenAllowed(tRent.getSelectedRow());

                if (childrenAllowed == "N"){
                    txKids.setEditable(false);
                    cbBookHouse.setEnabled(true);
                }

           }
       });
    }
    return tRent;
}

The problem that I'm having with the previous code is that any condition, apart from the image, is accomplished, seems to be ignored.

I just checked if the value was read correctly and it is, with a println in console, I get a N or Y depending on the row, but if I check that value, nothing happens with the components I want its state to be changed.

Also tried to put those conditions inside the components and the same happens.

The code of the methods getChildrenAllowed() for example, is like this

      public String getChildrenAllowed(int index) {
      return houseRelation.get(index).getChildren();
  }
mKorbel
  • 109,525
  • 20
  • 134
  • 319
Niconoid
  • 107
  • 2
  • 12
  • everything (from code posted here) inside private JTable getTRent() { is useless, this should be part for add data to TableModel, and really no idea whats your goal – mKorbel Dec 30 '13 at 13:59

1 Answers1

1

Don't compare strings with ==, use equals() or equalsIgnoreCase()

if ("N".equalsIgnoreCase(childrenAllowed))

See How do I compare Strings in Java

Community
  • 1
  • 1
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
  • ListSelectionListener (with test if is row selected) or rowAtPoint – mKorbel Dec 30 '13 at 14:00
  • @mKorbel sorry I'm not getting your point. Are you suggesting the OP use a `ListSelectionListener`? You should post it as an answer. I don't understadn what the OP is asking enough to try and offer that. I just posted what I noticed to be wrong – Paul Samsotha Dec 30 '13 at 14:03