setLineWrap(true) faz minha JTextArea aumentar

4 respostas
felipefvs

Fala galera!!

Então, tenho uma JTextArea, com setLineWrap(true), e alguns botões abaixo dela. Tudo dentro de um frame.
Mas quando ela faz a quebra de linha, os botões vão para baixo, saindo da area do frame.

Tem como travar o tamanho(high) da JTextArea nesse caso???

faloww
valew!

4 Respostas

aguiaMen

Não tenho certeza mas vc pode usar o setPreferredSize();

felipefvs
Dimension s = new Dimension();

s.setSize(735, 645);

aTxt = new JTextArea();

aTxt.setPreferredSize(s);

aTxt.setLocation(0, 5);

aTxt.setFont(new Font(Times, 0, 14));

aTxt.setEditable(true);

aTxt.setLineWrap(true);
panel.add(aTxt);

Cara, fiz o que vc falo. Como eu estava usando aTxt.setBounds(0, 5, 732, 645); , tive q colocar esse setLocation certo??
Mas ñ deu…não aparece a area de texto…

felipefvs

Putssss…esquece cara, na verdade minha text area não tava aumentando…meus botões q tavam sumindo…dai eu tenho q passa com o mouse sobre eles para aparecerem d novo!!

valew a ajuda!

aguiaMen

Felipe baseado neste código que vc passou fiz um teste aki e saiu tudo mui bem.
Olha só :
public class ExJTextArea extends JFrame {

private static final long serialVersionUID = 6722818656747253789L;

public ExJTextArea() throws HeadlessException {
	super();
	JTextArea aTxt = new JTextArea();
	aTxt.setPreferredSize(new Dimension(300,500));
	aTxt.setLocation(0, 5);
	aTxt.setFont(new Font("Times", 0, 14));
	aTxt.setEditable(true);
	aTxt.setLineWrap(true);
	Panel panel = new Panel();
	panel.add(aTxt); 
	add(panel);
}

public static void main(String[] args) {
	ExJTextArea formInicial = new ExJTextArea();
	Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
	formInicial.setSize(480, 600);
	formInicial.setLocation((dim.width -450)/2 , (dim.height -500)/2);
	formInicial.setTitle(">>- Exemplos JTextArea -");
	formInicial.setResizable(false);
	formInicial.setVisible(true);
	formInicial.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

q qwr duvida posta aí (o main e extends de Jframe é só para poder conferir visualmente- Blza)

Criado 2 de outubro de 2008
Ultima resposta 2 de out. de 2008
Respostas 4
Participantes 2