Alguem poderia me ajudar ..
a) Nao esta limitando o tamanho do campo.
b) Gostaria sair do aplicativo pelas duas maneiras.
Clicando no canto superior direito
Clicando no canto superior esquerdo ( fechar )
b) Gostaria sair do aplicativo pelas duas maneiras.
Clicando no canto superior direito
Clicando no canto superior esquerdo ( fechar )
obs.: Deve ser alguma coisa relacionado com a
declaracao
dos eventos.
dos eventos.
Como fazer eh a questao
!!!!!!
//principal
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Teste11
{
public static void main(String args[]) throws
Exception
{
Teste1 teste = new Teste1();
teste.addWindowListener(new TratadorWindowEvent(teste));
teste.setSize(400,400);
teste.show();
{
Teste1 teste = new Teste1();
teste.addWindowListener(new TratadorWindowEvent(teste));
teste.setSize(400,400);
teste.show();
}
}
//teste1
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Teste1 extends Frame
{
GridBagLayout layoutmangler = new GridBagLayout();
GridBagLayout layoutmangler = new GridBagLayout();
public Teste1()
{
{
this.setLayout(layoutmangler);
TextField[] Nome = new TextField[6];
TextField[] Nome = new TextField[6];
int c = 0 ;
int lin = 0;
for (int i = 0 ; i < 6 ; i++ )
{
Nome[i] = new LimitedTextField(10,9);
//Nome[i].minimumSize(i);
//Nome[i].preferredSize(i);
if ( c <= 1)
{
c++;
}
else
{
c = 1;
lin++;
}
AddtoFrame(Nome[i],c,lin);
int lin = 0;
for (int i = 0 ; i < 6 ; i++ )
{
Nome[i] = new LimitedTextField(10,9);
//Nome[i].minimumSize(i);
//Nome[i].preferredSize(i);
if ( c <= 1)
{
c++;
}
else
{
c = 1;
lin++;
}
AddtoFrame(Nome[i],c,lin);
}
}
}
//public void
destroy()
//{
// System.exit(0);
//}
//{
// System.exit(0);
//}
public void AddtoFrame(Component item, int x,
int y )
{
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = 1;
c.gridheight =1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 0.0 ;
c.weighty = 0.0 ;
c.gridx = x;
c.gridy = y;
((GridBagLayout)this.getLayout()).setConstraints(item,c);
this.add(item);
}
{
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = 1;
c.gridheight =1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 0.0 ;
c.weighty = 0.0 ;
c.gridx = x;
c.gridy = y;
((GridBagLayout)this.getLayout()).setConstraints(item,c);
this.add(item);
}
//public void processWindowEvent ( WindowEvent
we )
//{
// IF ( we.WINDOW_DESTROY )
// {
// dispose();
// setVisible(false);
// super.processWindowEvent(we);
// }
//}
//{
// IF ( we.WINDOW_DESTROY )
// {
// dispose();
// setVisible(false);
// super.processWindowEvent(we);
// }
//}
//public void processMouseEvent ( MouseEvent me
)
//{
// super.processMouseEvent(me);
//}
//{
// super.processMouseEvent(me);
//}
}
//Classe limitar texto
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
class LimitedTextField extends
TextField
{
private int maxLen;
public LimitedTextField(int cols, int len)
{
super(cols);
maxLen = len;
}
public void processKeyEvent(KeyEvent e)
{
if (e.getID() == KeyEvent.KEY_TYPED && super.getText().length() >= maxLen)
{
//beep
return;
}
super.processKeyEvent(e);
}
}
{
private int maxLen;
public LimitedTextField(int cols, int len)
{
super(cols);
maxLen = len;
}
public void processKeyEvent(KeyEvent e)
{
if (e.getID() == KeyEvent.KEY_TYPED && super.getText().length() >= maxLen)
{
//beep
return;
}
super.processKeyEvent(e);
}
}
Desde ja agradeco
[]'s
Lyllian
