Answers for "howto make a button do an action on kotlin swing"

0

howto make a button do an action on kotlin swing

import java.awt.Image;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.*;

public class JButtonIcon {
    JButtonIcon(){  
        /* JFrame is a top level container (window)
         * where we would be adding our button
         */
        JFrame frame=new JFrame();  
                          
        // Creating Button          
        JButton b = new JButton();
        try {
            Image img = ImageIO.read(getClass().getResource("play.gif"));
            b.setIcon(new ImageIcon(img));
          } catch (IOException ex) {
          }
        
        b.setBounds(50,50,90, 50);  
             
        //Adding button onto the frame
        frame.add(b);  
                  
        // Setting Frame size. This is the window size
        frame.setSize(300,200);  
        
        frame.setLayout(null);  
        frame.setVisible(true);  
                  
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
                  
    }  
              
    public static void main(String[] args) {  
            new JButtonIcon();  
    }  
}
Posted by: Guest on January-20-2021

Code answers related to "howto make a button do an action on kotlin swing"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language