2
You can change the icon of a java desktop application in eclipse instead of the default icon?
2
You can change the icon of a java desktop application in eclipse instead of the default icon?
3
The problem with being able to change the icon is why your Java Desktop application generates a .jar
, and unlike files with extension .exe
the .jar
does not have its own icon, its icon is the same for all .jar
system, so you can’t change its icon the way you do with the .exe
.
The solution I suggest is to create a shortcut and set the shortcut icon, the .jar
you leave it hidden in a system folder, and hope that the user never resolves to poke around in it.
Now, if you refer to the window and taskbar icon you can change it like this:
frame.setIconImage(Toolkit.getDefaultToolkit().getImage("img\\logo.jpg"));
For example:
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class JanelaComIcone extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JanelaComIcone frame = new JanelaComIcone();
frame.setVisible(true);
frame.setIconImage(Toolkit.getDefaultToolkit().getImage("img\\logo.jpg"));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public JanelaComIcone() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
}
The briefcase img
you put at the root of the project.
Browser other questions tagged java eclipse
You are not signed in. Login or sign up in order to post.
It is an Android or Desktop application?
– Math
It is a Desktop application
– Duds