P
pek
OK, I got really confused about when to use SwingUtilities or not.
For example.
Let's say that I have a simple class that extends JFrame, a private
JButton field testButton and a private JLabel field testLabel.
Somewhere down the code I right the following:
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
testLabel.setText("testButton");
}
});
Does this needs to be converted to :
public void actionPerformed(ActionEvent e){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
testLabel.setText("testButton");
}
})
});
or not? And why..?
When exactly do I need to use SwingUtilities?
If I have a thread that changes a JLabel inside/outside the class, do
I need it?
If the thread instead of changing the testLabel invokes
testButton.doClick(), will I still need to use SwingUtilities..?
Overall, is there any good reference in the internet to explain all
these..?
Thank you very very very very much for your help..
For example.
Let's say that I have a simple class that extends JFrame, a private
JButton field testButton and a private JLabel field testLabel.
Somewhere down the code I right the following:
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
testLabel.setText("testButton");
}
});
Does this needs to be converted to :
public void actionPerformed(ActionEvent e){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
testLabel.setText("testButton");
}
})
});
or not? And why..?
When exactly do I need to use SwingUtilities?
If I have a thread that changes a JLabel inside/outside the class, do
I need it?
If the thread instead of changing the testLabel invokes
testButton.doClick(), will I still need to use SwingUtilities..?
Overall, is there any good reference in the internet to explain all
these..?
Thank you very very very very much for your help..