• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

textfield not taking in input...Occasionally

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chris Dancy:
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..



I'm not sure about the others here, but I would have a much greater chance of understanding your problem and your code if:
1) it was simplified as much as possible so that it demonstrated the error but did nothing else,
2) you used code tags so that your code retained its formatting. To do this, highlight the posted code and press the "code" button, and
) it was compilable. As it is, it has a bunch of non-standard classes that I can only guess at what they do.

Have a look at how to create an SSCCE.

Best of luck.
[ April 02, 2008: Message edited by: pete stein ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic