0

I'm currently building a file Manager just Like mac os own Finder. For Each Button's icon, i'd prefer to use mac os own icons rather than downloading them from internet. I've seen this answer and this post. But the problem is when calling most of these icons, all frame shows is Finder icon. For Example for this code :

import javax.swing.*;
public class GUI {
    public GUI() {
        JFrame mainFrame = new JFrame();
        mainFrame.setSize(600, 600);
        JButton button = new JButton(UIManager.getIcon("FileChooser.listViewIcon"));
        mainFrame.add(button);
        mainFrame.setVisible(true);

    }
}

shows this : Frame Any ideas to get systems default icons or fix this?

Also i tried downloading image icons from internet, for example this icon. But when putting it as icon of a Jbutton it is not in the right size and blurry. any ideas to how to put it at its perfect size?

Danial
  • 362
  • 4
  • 18
  • You sure you want to do this? Portability is a big part of Java, meaning your code should look and run the same regardless of platform (with some minor look and feel differences). What happens when someone runs your code on a Windows machine? Are you going to give those users the icons that they're used to seeing too? – MarsAtomic Dec 06 '19 at 07:39
  • yeah i'm sure. The thing is i'm not building a product or anything like that, it's just a project for learning. and i'd like to build it as beautiful as possible in my own laptop :D – Danial Dec 06 '19 at 08:24
  • @MarsAtomic *your code should look and run the same regardless of platform* - not if you are using the "platform LAF" for your application. Yes it should run the same, but the LAF should be based on the platform, which is why you would try to use the Icons of the platform. – camickr Dec 06 '19 at 15:33
  • @Danialz, I don't use a Mac so I don't know what the proper Icons should be. Maybe the problem is you are trying to get the Icon before the LAF has been set and you are not executing your code on the Event Dispatch Thread (EDT). Check out [UIManager Defaults](https://tips4java.wordpress.com/2008/10/09/uimanager-defaults/). See what it displays as the Icons for the Mac LAF. – camickr Dec 06 '19 at 15:38

0 Answers0