Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod not running when initiated in another class
    primarykey
    data
    text
    <p>so I have a few classes but the two in question are my Character class and Gui class</p> <p>In my Character class I have (essentially) </p> <pre><code>public class Character implements Serializable { Gui gui = new Gui(); public Character(String name,int row,int col,int bounds){ this.name = name; this.row = row; this.col = col; this.bounds = bounds; } public String toString() { gui.labels(row, col); return (name + " at (" + row + "," + col + ")\t"); } } </code></pre> <p>And then in my Gui class I have this</p> <pre><code>public void labels(int x, int y) { label[0][0] = label00; label[0][1] = label01; label[0][2] = label02; label[0][3] = label03; label[1][0] = label10; label[1][1] = label11; label[1][2] = label12; label[1][3] = label13; label[2][0] = label20; label[2][1] = label21; label[2][2] = label22; label[2][3] = label23; label[3][0] = label30; label[3][1] = label31; label[3][2] = label32; label[3][3] = label33; JLabel jLabel = label[x][y]; jLabel.setText("0"); jLabel.setText("Test"); } </code></pre> <p>And what is meant to happen is the toString function is meant to send the Col and Row values to the labels function in the Gui and then the Gui sets the label accordingly </p> <p>However it just doesn't do anything and I don't know why, but if I make a test button on the Gui and then make it call the function labels like this for example</p> <pre><code> JButton settingsButton = new JButton("Settings"); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { labels(3, 1); } }); </code></pre> <p>It works perfectly fine, am I missing something here? I can't quite understand why this isn't working</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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