Studyon Minte9.com
Java SE




Image embeded




package testexample; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.imageio.ImageIO; import javax.swing.*; public class Test extends JFrame { Image imageStop = ImageIO.read(getClass().getResource("/stop.png")); // --- Look Here --- // public static void main(String[] args) throws Exception { Test frame = new Test(); frame.setBounds(200, 200, 300, 300); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setLayout(new FlowLayout()); frame.setVisible(true); } public Test() throws Exception { setIconImage(imageStop); // --- Look Here --- // setTitle("Java Test"); add(new JButton(){{ ImageIcon iconStop = new ImageIcon(imageStop); // --- Look Here --- // setIcon(iconStop); setBorderPainted(false); setContentAreaFilled(false); setFocusPainted(false); setCursor(new Cursor(Cursor.HAND_CURSOR)); addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("button clicked"); } }); }}); } }
 


http://stackoverflow.com/questions/19927509/set-icon-for-executable-jar-file