Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your problem is that your comparing Strings with <code>==</code>. Use the <code>equals(...)</code> method instead.</p> <ul> <li><code>==</code> compares if two variables refer to the same object -- something you don't care about. Thus two String variables can hold the same word but not be deemed equal by this operation.</li> <li>the <code>equals(...)</code> or <code>equalsIgnoreCase(...)</code> method checks if two String variables hold the same chars in the same order, and that you <strong>do</strong> care about.</li> </ul> <p>So not:</p> <pre><code>if (e.getActionCommand() == "next") { // ... } </code></pre> <p>but rather:</p> <pre><code>if ("next".equals(e.getActionCommand())) { // ... } </code></pre> <p>or if you don't care about case:</p> <pre><code>if ("next".equalsIgnoreCase(e.getActionCommand())) { // ... } </code></pre> <p><strong>Edit 1</strong><br> Next, once your JTable has hold of the data, changing the data will likely have no effect on the JTable. So here you change the data array:</p> <pre><code>int i=0; public void WriteMonitorData (String IP, String PC_NAME, String ttl, String gw) { data[i][0]=IP; data[i][1]=PC_NAME; data[i][2]=ttl; data[i][3]=gw; i++; table.repaint(); scrollPane.repaint(); } </code></pre> <p>But this array has already been passed into the JTable, is now part of its model and has been changed into a Vector in all likelihood. </p> <p>To see a change in your JTable's representation of the data, you must change the data held by the table's <strong><em>model</em></strong>. I suggest that you use a DefaultTableModel to hold your data in the JTable and then in your method above (which should begin with a lower case letter), you change the data held by the model. </p> <p>Also, regardless if your <code>if</code> blocks work or not, don't use <code>==</code> to compare Strings as this will bite you, if not now, soon.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload