so i have a custom jtextfield which i call RoundJTextfield which simply extends JTextfield to do some custom painting. When I start the application sometimes the textfield will let me edit it, and other times it wont. I've never had this happened before so im a bit perplexed as to why its occuring...
here is the code for the panel on which this is happening..
package loginScreenGui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import customComponent.*;
import programStart.*;
public class SetupServerVariablesGUIPanel extends JPanel{
RoundJTextField setIPAddressField,setDBNameField,setUsernameField;
PasswordField setPasswordField;
RoundJButton setVariables;
JLabel setIPAddressLabel,setDBNameLabel,setPasswordLabel,setUsernameLabel;
Insets insets;
SetupServerVariablesFrame ssvf;
public SetupServerVariablesGUIPanel(SetupServerVariablesFrame ssvf){
this.ssvf = ssvf;
insets = super.getInsets();
super.setLayout(null);
init();
}
public void init(){
//This is where I initialize the components for the panel.
setUsernameField = new RoundJTextField(12);
Dimension sizesetUsernameField = setUsernameField.getPreferredSize();
setUsernameField.setBounds(175 + insets.left,58 + insets.top,
(int)sizesetUsernameField.getWidth(),(int)sizesetUsernameField.getHeight());
add(setUsernameField);
}
public class setVariablesListener implements ActionListener{
public void actionPerformed(ActionEvent e){
new
Thread(new Runnable(){
public void run(){
ServerVariables.setServerVariables(setUsernameField.getText(),new
String(setPasswordField.getPassword()),
setIPAddressField.getText(),setDBNameField.getText());
LoginScreenPanel.loginName.setText(ServerVariables.getUserName());
LoginScreenPanel.loginPassword.setText(ServerVariables.getUserPassWord());
LoginScreenPanel.setupServerVariables.isPressedDown(false);
ssvf.dispose();
}
}).start();
}
}
public void paintComponent(Graphics g){
Graphics2D g2d = (Graphics2D)g.create();
super.paintChildren(g2d);
Color color2 = new Color(11,22,33);
Color color1 = new Color(172,207,247);
GradientPaint gp = new GradientPaint(0,0,color1,getWidth(),getHeight(),color2);
Paint oldpaint = g2d.getPaint();
g2d.setPaint(gp);
g2d.fillRect(0,0,getWidth(),getHeight());
g2d.setPaint(oldpaint);
g2d.dispose();
}
}
I cant figure it out. Im thinking it must be in this code somewhere but im clueless as to where...? any suggestions?
sincerely,
Chris Dancy