6
So guys I got one jTextField
that works normally but when I put it as static
the setText
no longer works, and I need it static because I pass the same to a function, I did it without the swing
and it worked I don’t know what’s going on now.
Below is the code:
//Codigo gerado automaticamento pelo swing
public static javax.swing.JTextField blueBGolem;
blueBGolem.setEditable(false);
blueBGolem.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
blueBGolem.setForeground(new java.awt.Color(255, 255, 255));
blueBGolem.setHorizontalAlignment(javax.swing.JTextField.CENTER);
blueBGolem.setText("5:00");
blueBGolem.setBorder(null);
blueBGolem.setOpaque(false);
Painel.add(blueBGolem);
blueBGolem.setBounds(0, 0, 70, 17);
private void blueBGolemStartActionPerformed(java.awt.event.ActionEvent evt) {
//timerBlueBGolem.start();
blueBGolem.setText("ooi");
}
EDIT
I think it’s something in my code but I can’t find what..
follows the complete code
What is the error message? I don’t think using Static is the best solution to the problem. Specify better what you are trying to do.
– Jodson Leandro
@Jodsonleandro There is no error message simply by clicking on jbutton nothing happens
– tissei
@Jodsonleandro I need to pass my jtextfield to a function where the same will be changed and to do this he has to be static
– tissei
@alleen94 It does not need to be static. If you pass the object by parameter in the method, you will get the instance. I don’t remember in which structure the swing was made, but you can validate if your Jtextfield instance is always the same.
– Jodson Leandro
@Jodsonleandro the netbeans won’t let me pass if the object is not static
– tissei