Problemas com JTextPane!

2 respostas
R

Galera to com um problema com o JTextPane, ele simplesmente não que mudar de lugar, no código abaixo mostra ele, nele no caso to usando o setSize() e o setLocation() para redimensiona-lo e posiciona-lo mas também já tentei com reshape!

Agradeço desde já!

import javax.swing.*;

class Popup_Cell {
	JFrame    frame;
	JLabel    label;
	JTextPane text;
	ImageIcon image, icon;

	Popup_Cell(String _title, String _text, String _image) {
		frame = new JFrame(_title);
		text  = new JTextPane();
		image = new ImageIcon(_image);
		icon  = new ImageIcon("icon.jpg");
		label = new JLabel(image);

		text.setText(_text);
		text.setEditable(false);

		text.setSize(20,20);
		text.setLocation(20,20);

		frame.getContentPane();

		frame.add(label);
		frame.add(text);

		frame.setSize(500,400);
		frame.setVisible(true);
		frame.setIconImage(icon.getImage());
	}
}

2 Respostas

ViniGodoy

Faltou fazer setLayout(null) no seu JFrame e no seu JPanel. Embora o melhor mesmo fosse você aprender como funciona os gerenciadores de layout:
http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html
http://download.oracle.com/javase/tutorial/uiswing/layout/using.html
http://www.di.ufpe.br/~java/jai/aula5/layout.html
http://www.miglayout.com/QuickStart.pdf

R

Obrigado pela dica, vou botar em pratica já!

Criado 23 de setembro de 2010
Ultima resposta 23 de set. de 2010
Respostas 2
Participantes 2