我对联合工作组来说是新的,因此,我宽恕我,可能有些真正开始的问题。
After reading the tutorial on how to use top level containers, I tried the following code inside the actionPerformed event in a button:
private void colgarActionListener(java.awt.event.ActionEvent evt) {
auxButton = new JButton();
auxButton.setSize(100,30);
auxButton.setText("Me button");
getContentPane().add(auxButton);
getContentPane().doLayout();
}
如你所期望的那样,它不工作。 纽伦就没有出现。 如果我尝试一 thing,例如:
getContentPane().setBackground(Color.red);
instead of
getContentPane().doLayout();
它运作。 我做了什么错误?
And the last one: if I write a class which works as a custom ActionListener (with its constructor with parameters), where should I put it? As a private class inside the GUI code? It just feels so dirty... Or as a public class inside another package. maybe?
Thank you very much.
问题。
Martín。