I'm kinda new to Java (I only have experience with Processing) and I have a question.
I'm building a small task planning application in Eclipse. I'm using the MigLayout. Every task has its own row (see image). I use three classes, TaskRowDone, TaskRowBusy and TaskRowToDo.
public HoofdScherm() {
initialize();
drawDone();
drawBusy();
drawToDo();
drawNewBtn();
}
The code above draws the main screen. The code below draws the button labeled "Nieuwe taak" (New task). I want to be able to click this button to make a new task row. I've tried putting the lines TaskRowToDo trtd3 = new TaskRowToDo(5, true, "test", 3);
and trtd3.draw()
inside the actionPerformed
function of the button (as a way of testing), but this doesn't seem to do anything. Does the program only run the functions inside 'HoofdScherm' once and then stop drawing? If this is the case, how do I structure the program so the layout can always be changed? I tried a while(true) loop inside 'HoofdScherm' so it kept looping but of course this crashed the computer.
private void drawNewBtn(){
JButton btnNew = new JButton("Nieuwe taak");
btnNew.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("New task added");
}
});
frmPlanner.getContentPane().add(btnNew, "cell 3 7");
}