Header Ads

Header ADS

J Frame Icon add

J Frame Icon add

Let's see a simple swing example where we are creating JFrame and Icon add object inside the main() method.source package add Icone and set Icon name is Icon.jpg

J Frame Icon Add Code :


import javax.swing.ImageIcon;

import javax.swing.JFrame;

public class FrameDemo extends JFrame {
                
    private ImageIcon icon;
             
   
    FrameDemo()
    {
        initComponents();
    }
    public void initComponents()      
    {
        icon=new ImageIcon(getClass().getResource("Icon.jpg"));          
        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(200, 50, 400, 300);
        frame.setTitle("Frame Demo"); 
        frame.setResizable(false);
  
    }
       
}
Output :



No comments

URI 1070 Six Odd Numbers Solution in C++

URI 1070 Six Odd Numbers Solution in C++ Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just fin...

Powered by Blogger.