howto make a button do an action on kotlin swing example
Example: 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 frame=new JFrame();
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);
frame.add(b);
frame.setSize(300,200);
frame.setLayout(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new JButtonIcon();
}
}