0

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");

}
}
2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by Majestics
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.