im a begginer with the gui code , i tried to add an image by making an imageicon then adding it to a Jlabel nd finally adding it to my frame all this while trying to put a button in front of the label but i cant seem to get it right , plz help

package eg.edu.guc.dvonn.gui;

import java.awt.event.*;
import java.awt.image.ImageObserver;

import javax.swing.*;
import java.awt.*;

@SuppressWarnings("serial")
public class window extends JFrame implements ActionListener{
 private ImageIcon image ;
 private JLabel imglabel;

public window (String s){
    this.setTitle(s);   
    this.setVisible(true);
    this.setSize(500, 500);
    this.setLayout(null);
    this.setDefaultCloseOperation(3);

image = new ImageIcon(getClass().getResource("dvonn_logo.gif"));
    imglabel= new JLabel(image);
    add(imglabel);


}



public static void main(String[]args){
    window w=new window("DVONN");

    JButton click= new JButton();
    click.setBounds(255,189,100,50);
    w.add(click);
    click.addActionListener(w);
    click.setVisible(true);
    click.setText("START");

}
}

First you have setBound for your label...
Second , you need to repaint frame, you can see ur label if u resize by clicking resize button in title bar.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.