Imagem duplicada nocframe

0 respostas
IsaelCoelho

[b]Boa tarde gostari de ajuda.

[color=red]fiz um programinha no netbeans quado compilo ele abre um frame com a imagem que coloque nele mais se eu maximizar a janela a imagem duplica quero que apenas uma imagem aparecer mesmo quando a janela for maximizada
o codgo fonte segue abaixo[/color][/b]

import java.awt.FlowLayout; //especifica como os componentes são organixados
import javax.swing.JFrame;//fornece recursos basicos da janela
import javax.swing.JLabel;//exibe textos e imagem
import javax.swing.SwingConstants;//cosntantes comuns utilizadas com swing
import javax.swing.Icon;//interfaces utilizadas para manipular imagens
import javax.swing.ImageIcon;//Carrega Image

public class JLabelFrame extends JFrame
{
private JLabel Label1;//JLabel com texto
private JLabel Label2;//JLabel com construtor de icon
private JLabel Label3;////Jlabel com texto e icon adicionados

//construtor  LabelFrame adiciona JLabel e Frane
public JLabelFrame()
{
    super("Testing JLabel");
    setLayout(new FlowLayout());//configuar o layout do frame

    //Cosntrutor Jlabel com argumentos de Stirng
    Label1 = new JLabel("label With Text");
    Label1.setToolTipText("This is text");//
    add(Label1);//adiciona label ao frame


    //Construtor JLabel com string, Icon e argumento de alinhamento
    Icon bug = new ImageIcon(getClass().getResource("moto.JPG"));
    Label2 = new JLabel("Label with text and icon",bug,SwingConstants.LEFT);//construtor JLabel  sem argumentos
    Label2.setToolTipText("This is Label2");
    add(Label2);//adicionar ao frame


    Label3 = new JLabel();//construtor JLabel sem argumentos
    Label3.setText("Label width icon and text at botton");
    Label3.setIcon(bug);//adiciona o icon ao JLabel
    Label3.setHorizontalTextPosition(SwingConstants.CENTER);
    Label3.setVerticalTextPosition(SwingConstants.BOTTOM);
    Label3.setToolTipText("This is Label3");
    add(Label3);//adiciona  Label3 ao  JFrame

}//fim do construtor LabelFrame
}//Fim da classe labelFrame
Criado 9 de setembro de 2010
Respostas 0
Participantes 1