Sunday, April 8, 2018

Java Swing Image Icon Settnig in JFrame Java code.

Image Icon Settnig in JFrame  Java code.

package scm;

import javax.swing.ImageIcon;
import javax.swing.JFrame;


public class FrameDemo extends JFrame {
    private ImageIcon icon;
    FrameDemo(){
    initComponents();
    }
     private void initComponents() {
       
         icon = new ImageIcon(getClass().getResource("anowar.png"));
         this.setIconImage(icon.getImage());
    }
    public static void main (String[]args) {
        FrameDemo frame = new FrameDemo () ;
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
        frame.setBounds(100, 50, 400, 300);
        frame.setTitle("Frame Demo");
        frame.setResizable(false);
     
}

 
}

No comments:

Post a Comment