private void validateInput() {
if (filenametextfield.getText().length() <= 3 )
{
errorMsg2.setForeground(Color.RED);
}
else if(filenametextfield.getText().length() >= 3 && filenametextfield.getText().length()<= 25)
{
errorMsg2.setForeground(frame.getBackground());
errorMsg.setForeground(frame2.getBackground());
}
else if(filenametextfield.getText().length() >= 25)
{
remove(errorMsg2);
errorMsg.setForeground(Color.RED);
filenametextfield.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
if(filenametextfield.getText().length()>=25)
{
e.consume();
e.getModifiers();
}
}
});
}
}