Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Container;
- import javax.swing.ImageIcon;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- public class JLabelImage extends JFrame {
- private ImageIcon img;
- private JLabel imgLabel;
- private Container c;
- JLabelImage()
- {
- setVisible(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100,50,800,600);
- setTitle("Image Page");
- iconMethod();
- }
- public void iconMethod()
- {
- c=this.getContentPane();
- c.setLayout(null);
- c.setBackground(Color.RED);
- img=new ImageIcon(getClass().getResource("html.png"));
- this.setIconImage(img.getImage());
- imgLabel=new JLabel(img);
- c.add(imgLabel);
- imgLabel.setBounds(100,20,img.getIconWidth(),img.getIconHeight());
- //imgLabel.setBounds(1000,30,150,200);
- //c.add(imgLabel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement