Adding items in a table

Hello guys, I looked for a solution to my problem, but I can not find the correct answer...

Here's the thing;

I have a variable (let's call it 'Variable Case'). Whenever this variable goes from 0 to 1, I want to add to the value of another variable (let's call this a "Defective nozzle") to an array of 2D. So far, nothing impressive, but things will get worse now!
To be sure I added correctly the value of "Defective nozzle" in my table, I have another variable (let's call it 'Successfully added') which goes from 0 (Nothing) to 1 (the value added in the table). When 'Successfully added' is '1', I have to set the value of 'Box' return from 1 to 0 (the 'Case' variable is in a while loop which is refreshed every 100 ms so it is very important that "The case" goes to 0 as soon as 'Defective nozzle' writing is done) and once the 'case' is 0 , the value 'Successfully added' aswell 0.
In addition, the size of the array is set to 10 items and whenever a value is written in this document, I have to increment the value of the index for the next value.

How to understand;

First iteration:

  • I have (from table) = 0

  • Business goes from 0 to 1

  • I insert the "Defective nozzle" value in the table

  • "Successfully added" goes from 0 to 1 (the value was written in the table)

  • I put back 'Case' to 0

  • I (index table) ++

  • 'Successfully added' move to '0 '.

Second iteration:

  • I have (from table) = 1

  • Business goes from 0 to 1

  • I insert the "Defective nozzle" value in the table

  • "Successfully added" goes from 0 to 1 (the value was written in the table)

  • I put back 'Case' to 0

  • I (index table) ++

  • 'Successfully added' move to '0 '.

Third generation (you have the thing...)

I have everything works but the "I ++" thingy. Could you take a look at my vi and tell me what I'm doing wrong? Thanks for your help!

Hello Claude,.

meaning of GerdW, is, that you don't find the answers to many questions.

  1. Due to the paradigm of data flow of LabVIEW, independent (and not with the wire) parts of the diagram run in parallel. If the sequence you have described in your message will run not in your VI, because the structure of the case, the structure of the event and the select node are independent of each other. You see, if you perform the VI mode with the debugging light bulb on.

  2. Shared variables are not the best way to store values, except that you want to share these values with other applications on remote computers. The best way to pass values from one part of the block diagram to another is a thread!

  3. "Change the value" - event fires only if the value is passed to the user interface, this means only by the user or through the 'value (signalling)' property node. So in your VI this event never fires. And because the terminal timeout is not wired, the structure of the event you expected forever to run your loop don't cycle.

  4. The part with the select node is already described in the Rube Goldberg-Thread, this means: If TRUE then TRUE else FALSE

I modified your VI so that he could answer some of your needs. Have a look at it and maybe you can answer the questions that came up to me:

  1. Why "table initialized" a 2D array and to what index elements must be inserted?

  2. Why 'table initialized' limited to 5 rows and 2 columns, and what happens when you want to insert multiple items? You can start again by the index 0? Do the loop terminate?

  3. If you want an unlimited size of the "initialized array", you must use the node 'build array' instead of 'subset of table to replace.

  • The delay between the "successfully added" definition affecting the value TRUE and FALSE reset is very short (about 10 ns), do you really need this information?
  • For some reason, I'm not able to view a VI. I get the message error that the extension doesn't ' corresponds to the file type.

    Tags: NI Software

    Similar Questions

    • Adding items to a table and having the front Table is displayed correctly

      Hi all

      I'm working on creating a .vi who will take an old instrument and allow the operators on the ground record the data automatically instead of reading the data out of the instrument and to have to manually enter in the computer.

      The instrument is configured using a RS232 communication port, I can communicate with the instrument, and I have full control of all functions.

      My problem is when I am trying to gather data and add it to a table existing and then to have the front table information is displayed correctly.  At the end of which this table in its entirety will be saved in a template excel in an existing format, so I can't adjust the way I need to the table to display.

      Please take a look at pictures and give me a hand if possible.  I won't be able to view the .vi due to the nature of my work and I like to read the information of the instrument.

      Thanks in advance for any assistance!

      There is no way to solve this problem by looking at the pictures. Please attach a version of VI simplfied. Is the "FG" table just a driving force?

      What size of the 2D string table that comes out of the table of FG? There may be large enough to hold all the fields as empty strings, then you can (re) place values using 'replace the subset of table' to desired locations.

    • How can I determine which item in a table was just clicked on?

      I have a table set in place on my front. When user right click on an item in this table, I would like to be able choose among 3 different options. I have the shortcut menu works, but I need to know what element of the array of the user in a click with the right button to determine what values to change. How can I get the index of the item?

      Thanks for any help!

      https://decibel.NI.com/content/docs/doc-6406

    • How can I read items in four tables and store them in variables?

      Greetings,

      I have 4 tables which I read to control an autonomous robot vehicle as instructions.

      I must be able to read the first elements of each table and store in separate variables 4 (direction, speed, angle, distance). Wait until the first statement has been executed. Then I move on to the second elements of each array. I'll repeat this until I went through all the elements. I am struggling to figure out how to do this?

      Please note:

      -The number of items in the tables is always the same, although the number of items varies as can be less instructions or more.

      For example, a full trial takes 1st element of table 1, table 2, table 3 and table 4 and it builds something like: forward, 10, 20, to the left. This will then be the robot moving forward at a speed of 10 over a distance of 20 and then turn left. Once this done then it contains the elements 2 and so on.

      Please find attached my VI that reads a text file and creates 4 berries.

      Thank you.

      stanm13 wrote: Unfortunately, I don't think you understood my question.

      Then, I would say a) you don't understand the answer or b) you explain well enough.

      To make each element of an array, using a loop FOR with autoindexing entered is the way to go.

    • How Split items in a table

      Hi guys

      I have signal consisting of a few numbers... .they are declared separately to Labview as x, y, z.

      So I need a way to group 3 these items in a table (for example) as x refes to a data point, number there is tension and z is the current.

      I would then separate the 'picture' in a XY Chart for I draw vs V.

      Any suggestions?

      Rgards

      B

      Hi Barrys,

      I'm not very clear on your doubts. I guess that if you can make a chart of your x y z-values, then you can yourself. See the attached example. I made a picture of a set of values. Instead of the constant I've used, you can read directly in your worksheet. I hope this helps.

      Kind regards
      Amine31

      (Bravo to give good answers, mark it as a Solution If your problem is resolved)

    • Adding items to an enum shifts the constant on the BD...

      A picture is worth a 1000 words, here is my qualm:

      Why adds an element to a constant of the enum addressing the constant of the comic?

      I use a lot this approach for Pseudo-stacked sequences (I use instead a state machine) and I end up spending the enum constant after adding item wach, otherwise, it ends by disappears under what structure it is right...

      Of course, I could just right-click and use the Edit items property (which I've been using today doing my level of tolerance has ebbed down a lot lately), but unless this feature has been voluntarily integrated in LV, it is bordering the sadist.

      Tested in LV 2011.

      Hi guys,.

      Thank you for this comment! I was also able to reproduce here on my computer running LabVIEW 2011 SP1.

      This was reported to R & D (CAR # 339320) for further investigations. Please let us know if you find other problems, we like always your diligence and your comments!

    • E/s files does not save the items in the table

      I can't save the items in the table. If I quit the program and restart it, the array starts at 0 again. I want it from the value at which it stopped.

      Is this a flaw in the Subvi "Timer A1"?

      Thanks for the help.

      mhaque

      Your feedback nodes are defined overall boot on the first call, as evidenced by the glyphs.  If you are stop and start your program, must be configured to initialize worldwide on the compilation or the load, simply right-click and change the setting.  This should give you the behavior you're looking for, but does not exclude the intrinsic problems with the code.

    • How to convert a table 1 d of cluster of 5 items in a table of numbers 2D? (a graph historical data)

      Hello

      in my vi, I have an array with 5 slots displaying measurement data.

      The user must be able to record all the data in the history of the card at any time. (for example the user looks at the picture and something happens, then it based on a 'save' - button)

      I know that I can read the data in the history with a property node. This isn't the problem. The problem is, how to deal with the data? The type of history data is a table 1 d of cluster of 5 elements.

      I convert these data somehow in a 2 D-table of numbers or strings, so that I can easily save it to a text file.

      How to convert a table 1 d of cluster of 5 items in a table of numbers 2D?

      I use LabVIEW 7.1

      Johannes

      Hallo Johannes,

      the photo shows the trivial way:

    • Added items to randomly change after opening other files in a subfolder.

      I have a file that is pinned on my Start menu that is attached to excel 2007. Now I can quickly open this file in excel when I want.

      The location of this file is \\server\sharedarea\inout.xls

      I have another file I want to pin to pin of excel area. This file is located in a subfolder of the original file.

      The location of this new file is \\server\sharedarea\subfolder\anotherfile.xls

      However when I opened the "anotherfile.xls" my pinned original file "inout.xls" has been replaced by "anotherfile.xls" and anotherfile.xls does not appear in my list of files recently viewed and or not "inout.xls".

      In order to get the "inout.xls" file that is pinned in my pinned items I open it in excel and the pinned "anotherfile.xls" link is automatically crushed and changed in the pinned file 'inout.xls'. For this reason, I am not able to get both "inout.xls" and "anotherfile.xls", pinned to the excel menu area start due to this bug. Not appear in my list of recent files either.

      I also have the same problem with task bar pinned items. If I open a folder or a file that is located in a subfolder of the original pinned item, windows, in his infinite wisdom, will replace my original pinned object, change to the new folder / file I open even if I don't want it (and 99% of the time I don't want it).

      Someone from microsoft can fix pinned bugs points because it is certainly not just me that sees a massive amount of bugs in the added items. It's something I could code and get it right the first time. It would take probably more effort to get Windows to the elements of pinned randomly change he would to leave him alone.

      I'm starting to think that the code of favorite items in Windows 7 needs a serious rewrite. So many bugs for something that really should not have problems, there!

      Thank you for the lack of support on this issue.

    • Get random items, no repetitive table

      Hello!

      I'm doing a 20-question, multiple-choice quiz. Each question is chosen at random in a table, and whenever the user clicks on the right answer, another random question comes up. I was not able to find a way to make sure not to repeat issues already selected. I tried to push the selected items in a table, then using $.grep and an if statement to check if the other randomly chosen question is already in the new table or not, but I couldn't get that to work.

      My code in the Panel of compositionReady is:

      var arr is ["Symbol_1", 'Symbol_2', 'Symbol_3', 'Symbol_4', 'Symbol_5', 'Symbol_6', 'Symbol_7', 'Symbol_8', 'Symbol_9', 'Symbol_10', 'Symbol_11', 'Symbol_12', 'Symbol_13', 'Symbol_14', 'Symbol_15', 'Symbol_16', 'Symbol_17', 'Symbol_18', 'Symbol_19', 'Symbol_20'];.

      sym.setVariable ("arr", arr);

      arr.sort (Function () {return 0.5 - Math.random ()});

      arr. Length = 20;

      var c = Math.floor (Math.random () * 100) %arr.length;

      for (i = 0; i < 20; i ++) {}

      SYM.$(arr[i]). Hide();

      SYM.$(arr[ques]). Show();

      };

      and whenever you click on the right answer, I run this:

      sym.getComposition () .getStage ().$("try_again1").hide ();

      sym.getComposition () .getStage ().$("correct1").show ();

      sym.getComposition () .getStage ().getSymbol("correct1").play ();

      var arr = sym.getComposition () .getStage () .getVariable ("arr");

      var c = Math.floor (Math.random () * 100) %arr.length;

      for (i = 0; i < = 20; i ++) {}

      sym.getComposition () .getStage ().$(arr[i]).hide ();

      sym.getComposition () .getStage ().$(arr[ques]).show ();

      }

      An overview of this would be much appreciated!


      Hi, bettiesac212-

      Well, I took a quick glance to your project (including project files was very useful, which is said by the way).  So what happens, is that you have included my code snippet in the middle of all the other things happening in your file.  There are a lot of questions I had looking at your code, like:

      • What is 'e '?  Where did this come from?
      • Why did you an array.sort initially?
      • Why do you attribute arr.length?  It is a property of arr already, so there is no reason to assign this

      Anyway, I cleaned up the code a bit to my snippet in.  I left some of her "as an exercise to the student", to paraphrase some of my old books, but I hope the console log will show you that usedArr is now a random picture that you can save.  If you save a variable that has the index, (aka "what question am I on?"), then you can get where you are now, add one, save this variable and are looking for the next item in usedArr and know that it is properly randomized.

      For those who are looking for an answer, this is the code I ended up using:

      var usedArr = new Array();

      var currentIndex = 0;

      While (currentIndex< 20)="">

      var randNum is Math.floor ((Math.random () * 100)) % 20;.

      If (usedArr [randNum] == undefined) {}

      We can place an object!

      usedArr [randNum] = arr [currentIndex];

      currentIndex ++;

      }

      by do not increment the currentIndex, we force basically he draw again

      }

      for (i = 0; i< usedarr.length;="" i++)="">

      Console.log ("index usedArr" + i + ":" + usedArr [i]);

      }

      You can save your new table and just browse each time

      you say "next question."

      I think that's more or less what I posted in my previous answer.  Bettie, I'll send you a link to your project files via private message in a few minutes.

      Thank you

      -Elaine

    • Returns the unique items in a table

      I would like to know how to get combanations of any table without repetitions of the same elements in a different order.

      The table is made of properties of the object and could have a variable number of elements.

      In other words, if I have an array of 2 elements for example

      [a, b]

      I want to receive 3 new arrays of void

      (1) [a]

      (2) [b]

      (3) [a, b]

      I don't want to receive [b, a] as having the same elements as [a, b] only in a different order.

      Well, if there just 2 items in the table then it's pretty easy, but when there is more then I do not understand!

      An array of 4 elements for example

      [a, b, c and d]

      would need to produce a new table of the following tables 15 sub

      (1) [a]

      (2) [b]

      (3) [c]

      (4) [d]

      (5) [a, b]

      (6) [a, c]

      (7) [a, d]

      (8) [b, c]

      (9) [b, d]

      (10) [c, d]

      (11) [a, b, c]

      (12) [a, b, d]

      (13) [a, c and d]

      (14) [b, c and d]

      (15) [a, b, c and d]

      A table of 5 elements would give me overtime 24 tables and so forth.

      I tried many ways with diddlysquat results

      Slice, splice and all things nice!

      If someone of you could share this trade secret with me, I would appreciate it a lot.

      Trevor

      Nice challenge!

      We could try this:

      function arrayParts(/*arr*/a, r,i,j,t,s,p)
      // -------------------------------------
      // Note: a is supposed to contain unique items
      // [if necessary, apply a makeUnique routine first]
      {
          if(! (i = Math.pow(2,a.length)-1) ){ return null; }
          (r=[]).toString = function(){return this.join('\r');};
      
          while(i--)
              {
              r[i] = t = [];
              s = (1+i).toString(2);
              p = (j=s.length) - 1;
              while( j-- ) '1'==s[j] && t[t.length]=a[p-j];
              }
      
          // Reorder by length [if needed!]
          // ---
          r.sort( function(x,y){return x.length-y.length;} );
      
          return  r;
      }
      
      // Sample code
      // ---
      var arrTest = ['Blue','Red','Yellow','Green','Black'];
      alert( arrayParts(arrTest) );
      

      Really not optimized, but it was pretty fun to write ;-)

      @+

      Marc

    • Call for ensureIndexIsVisible after adding items to the dataProvider

      Hello

      I have a strange behavior where call ensureIndexIsVisible does not show the correct item.

      Did I miss the correct event to listen to after adding items to the list data provider?

      Description:

      I use spark.components.List with a HorizontalLayout to display my data.

      My data is displayed using the ItemRenderer.

      After the addition of new elements to the dataProvider, I register the Event.RENDER and within this handler, I call ensureIndexIsVisible and cancel the registration to this event.

      Add some data to dataProvider - some elements of thousnd

      list.dataProvider.add (...)

      list.addEventListener (Event.RENDER,

      function renderHandler(e:Event):void

      {

      show index

      list.ensureIndexIsVisible (indexToShow);

      list.removeEventListener (Event.RENDER, renderHandler);

      });

      I made the debug:

      1. If I comment removeEventListener, it will eventually work after some time the event fires.

      2. the original location that I see is a few points behind so if I scroll a bit I can find the desired article

      Thank you

      Roy.

      This blog can be useful: http://flexponential.com/2011/02/13/scrolling-to-the-bottom-of-a-spark-list/

    • How can I remove a specific item of a table?

      Hello.

      I have an array of movieclips and when my (controlled with the keyboard) circle hitTests true with one of the clips inside this table I want to delete this movieclip to the table, so when I hitTest it even once, it returns false (I hitTest using a ' for in ' with this table).

      How to remove a specific item of a table?

      Can someone help me? Thank you very much.

      Try:

      yourArray.splice (yourArray.indexOf (yourmovieclip), 1);

    • Adding items dynamicaly in a column 3 MessageComponentLayout region

      Hi all

      I add a few items dynamically to a region of MessageComponentLayout, I want to show them three in a row.

      The region is created declaratively and its 'Columns' value 3 property

      Then the elements are dynamically added

      When I run the page, all the items are displayed in a column,

      Please can someone tell what could be the problem?

      Thank you

      Kind regards

      Afaf

      You can try with lines = 1 and cols = 3 and see what happens.

      Otherwise, you will have to go with another provision.

      Create a Table layout of declaratively.

      Programatically add RowLayout available to the table and add items under online.

      After every third element create a new Rowlayout and add to the tabular presentation.

      I hope this helps.

      See you soon

      AJ

    • Why not adding css class for table poster red border cell error?

      JavaFX 2.2.21 Java 7.21

      I'm trying to display a red border and a picture on a cell text when an error occurs.

      I took the address book example (example 12-11 http://docs.oracle.com/javafx/2/ui_controls/table-view.htm#CJAGAAEE).

      and also James D solution to my previous question.

      I find that adding a class of css error does not display the red border and the image.

      However, using setStyle this - but it is not preferable, because I want to put the border value by default once the error is corrected.

      In the example below, red border does NOT appear. The 'name' field was changed to salary and must display one error (red border and image) if other thing that an integer is entered.

      If you uncomment the setStyle lines, then it is displayed.

      Note: I use empty.png to erase the image of 'failure' because using - fx-background-image: none; somehow, did not.

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.geometry.Insets;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.TableColumn.CellEditEvent;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.scene.text.Font;
      import javafx.stage.Stage;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableCell;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.control.TextField;
      import javafx.scene.control.cell.PropertyValueFactory;
      import javafx.scene.input.KeyCode;
      import javafx.scene.input.KeyEvent;
      import javafx.util.Callback;
      public class TableViewSample extends Application {
      
      
          private TableView<Person> table = new TableView<Person>();
          private final ObservableList<Person> data =
                  FXCollections.observableArrayList(
                  new Person("Gates", "46", "[email protected]"),
                  new Person("Ellison", "25", "[email protected]"),
                  new Person("McNealy", "1", "[email protected]"),
                  new Person("Jobs", "0", "[email protected]"),
                  new Person("Me", "0", "[email protected]"));
          final HBox hb = new HBox();
      
      
          public static void main(String[] args) {
              launch(args);
          }
      
      
          @Override
          public void start(Stage stage) {
              Scene scene = new Scene(new Group());
              stage.setTitle("Table View Sample");
              stage.setWidth(450);
              stage.setHeight(550);
      
      
              final Label label = new Label("Address Book");
              label.setFont(new Font("Arial", 20));
      
      
              table.setEditable(true);
              Callback<TableColumn, TableCell> cellFactory =
                      new Callback<TableColumn, TableCell>() {
                  public TableCell call(TableColumn p) {
                      return new EditingCell();
                  }
              };
      
      
              TableColumn firstNameCol = new TableColumn("First Name");
              firstNameCol.setMinWidth(100);
              firstNameCol.setCellValueFactory(
                      new PropertyValueFactory<Person, String>("firstName"));
              firstNameCol.setCellFactory(cellFactory);
              firstNameCol.setOnEditCommit(
                      new EventHandler<CellEditEvent<Person, String>>() {
                  @Override
                  public void handle(CellEditEvent<Person, String> t) {
                      ((Person) t.getTableView().getItems().get(
                              t.getTablePosition().getRow())).setFirstName(t.getNewValue());
                  }
              });
      
      
      
      
              TableColumn salaryCol = new TableColumn("Salary");
              salaryCol.setMinWidth(100);
              salaryCol.setCellValueFactory(
                      new PropertyValueFactory<Person, String>("salary"));
              salaryCol.setCellFactory(cellFactory);
              salaryCol.setOnEditCommit(
                      new EventHandler<CellEditEvent<Person, String>>() {
                  @Override
                  public void handle(CellEditEvent<Person, String> t) {
                      ((Person) t.getTableView().getItems().get(
                              t.getTablePosition().getRow())).setSalary(t.getNewValue());
                  }
              });
      
      
              TableColumn emailCol = new TableColumn("Email");
              emailCol.setMinWidth(200);
              emailCol.setCellValueFactory(
                      new PropertyValueFactory<Person, String>("email"));
              emailCol.setCellFactory(cellFactory);
              emailCol.setOnEditCommit(
                      new EventHandler<CellEditEvent<Person, String>>() {
                  @Override
                  public void handle(CellEditEvent<Person, String> t) {
                      ((Person) t.getTableView().getItems().get(
                              t.getTablePosition().getRow())).setEmail(t.getNewValue());
                  }
              });
      
      
              table.setItems(data);
              table.getColumns().addAll(firstNameCol, salaryCol, emailCol);
      
      
              final TextField addFirstName = new TextField();
              addFirstName.setPromptText("First Name");
              addFirstName.setMaxWidth(firstNameCol.getPrefWidth());
              final TextField addSalary = new TextField();
              addSalary.setMaxWidth(salaryCol.getPrefWidth());
              addSalary.setPromptText("Last Name");
              final TextField addEmail = new TextField();
              addEmail.setMaxWidth(emailCol.getPrefWidth());
              addEmail.setPromptText("Email");
      
      
              final Button addButton = new Button("Add");
              addButton.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent e) {
                      data.add(new Person(
                              addFirstName.getText(),
                              addSalary.getText(),
                              addEmail.getText()));
                      addFirstName.clear();
                      addSalary.clear();
                      addEmail.clear();
                  }
              });
      
      
              hb.getChildren().addAll(addFirstName, addSalary, addEmail, addButton);
              hb.setSpacing(3);
      
      
              final VBox vbox = new VBox();
              vbox.setSpacing(5);
              vbox.setPadding(new Insets(10, 0, 0, 10));
              vbox.getChildren().addAll(label, table, hb);
      
      
              ((Group) scene.getRoot()).getChildren().addAll(vbox);
              scene.getStylesheets().add(getClass().getResource("errorTextField.css").toExternalForm());
      
      
              stage.setScene(scene);
              stage.show();
          }
      
      
          public static class Person {
      
      
              private final SimpleStringProperty firstName;
              private final SimpleStringProperty salary;
              private final SimpleStringProperty email;
      
      
              private Person(String fName, String pay, String email) {
                  this.firstName = new SimpleStringProperty(fName);
                  this.salary = new SimpleStringProperty(pay);
                  this.email = new SimpleStringProperty(email);
              }
      
      
              public String getFirstName() {
                  return firstName.get();
              }
      
      
              public void setFirstName(String fName) {
                  firstName.set(fName);
              }
      
      
              public String getSalary() {
                  return salary.get();
              }
      
      
              public void setSalary(String fName) {
                  salary.set(fName);
              }
      
      
              public String getEmail() {
                  return email.get();
              }
      
      
              public void setEmail(String fName) {
                  email.set(fName);
              }
          }
      
      
          class EditingCell extends TableCell<Person, String> {
      
      
              final String errorCSSClass = "error";
              private TextField textField;
      
      
              public EditingCell() {
              }
      
      
              @Override
              public void startEdit() {
                  if (!isEmpty()) {
                      super.startEdit();
                      createTextField();
                      setText(null);
                      setGraphic(textField);
                      textField.selectAll();
                  }
              }
      
      
              @Override
              public void cancelEdit() {
                  super.cancelEdit();
      
      
                  setText((String) getItem());
                  setGraphic(null);
              }
      
      
              @Override
              public void updateItem(String item, boolean empty) {
                  super.updateItem(item, empty);
      
      
                  if (empty) {
                      setText(null);
                      setGraphic(null);
                  } else {
                      if (isEditing()) {
                          if (textField != null) {
                              textField.setText(getString());
                          }
                          setText(null);
                          setGraphic(textField);
                      } else {
                          setText(getString());
                          setGraphic(null);
                      }
                  }
              }
      
      
              private boolean validate(String text) {
                  try {
                      Integer.parseInt(text);
                  } catch (NumberFormatException ne) {
                      return false;
                  }
                  return true;
              }
      
      
              private void createTextField() {
                  textField = new TextField(getString());
                  textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
                  textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
                      @Override
                      public void changed(ObservableValue<? extends Boolean> arg0,
                              Boolean arg1, Boolean arg2) {
                          if (!arg2) {
                              commitEdit(textField.getText());
                              boolean valid = validate(textField.getText());
                              if (!valid) {
                                  if (!getStyleClass().contains(errorCSSClass)) {
                                      getStyleClass().add(errorCSSClass);
                                  }
      //                            setStyle("-fx-border-color: red; -fx-background-image:url('fail.png'); -fx-background-repeat: no-repeat; -fx-background-position: right center;");
                              } else {
                                  getStyleClass().remove(errorCSSClass);
      //                            setStyle("-fx-border-color: gray;  -fx-background-image:url('empty.png');");
                              }
                          }
                      }
                  });
                  textField.setOnKeyReleased(new EventHandler<KeyEvent>() {
                      @Override
                      public void handle(KeyEvent event) {
                          if ((event.getCode() == KeyCode.ENTER)) {
                              commitEdit(textField.getText());
                              boolean valid = validate(textField.getText());
                              if (!valid) {
                                  if (!getStyleClass().contains(errorCSSClass)) {
                                      getStyleClass().add(errorCSSClass);
                                  }
      //                            setStyle("-fx-border-color: red; -fx-background-image:url('fail.png'); -fx-background-repeat: no-repeat; -fx-background-position: right center;");
                              } else {
                                  getStyleClass().remove(errorCSSClass);
      //                            setStyle("-fx-border-color: gray;  -fx-background-image:url('empty.png');");
                              }
                          } else if (event.getCode() == KeyCode.ESCAPE) {
                              cancelEdit();
                          }
                      }
                  });
              }
      
      
              private String getString() {
                  return getItem() == null ? "" : getItem().toString();
              }
          }
      }
      
      
      

      errorTextField.css

      root {
          display: block;
      }
      
      
      .text-field.error {
      -fx-border-color: red ;
        -fx-border-width: 2px ;
        -fx-background-image:url('fail.png');
        -fx-background-repeat: no-repeat;
        -fx-background-position: right center;
      }
      .text-field {
      -fx-border-width: 0px ;
      -fx-background-image:url('empty.png') ;
         -fx-background-repeat: no-repeat;
        -fx-background-position: right center;
      }
      
      
      

      The css Setup is fine. The selector

      .a.b
      

      Selects elements that have the two class a and class b. Note that in this example, you set the style on the table cell class, not on the text field. So you have the selector

      .table-cell.error
      

      You can select the cells of a table with text fields that also have the style class 'mistake' set with

      .text-field.error, .table-cell.error
      

    Maybe you are looking for