package project1; import com.sun.java.swing.plaf.gtk.GTKLookAndFeel; import java.awt.Graphics; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.metal.MetalLookAndFeel; public class GTKIcon { public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { // This works UIManager.setLookAndFeel(new MetalLookAndFeel()); System.out.println(UIManager.getLookAndFeel()); JFrame f = new JFrame("Metal L&F"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(200,200); f.setLocation(100, 100); f.add(new IconPanel()); f.setVisible(true); // This doesn't work on Linux UIManager.setLookAndFeel(new GTKLookAndFeel()); System.out.println(UIManager.getLookAndFeel()); f = new JFrame("GTK L&F"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(200,200); f.setLocation(500, 100); f.add(new IconPanel()); f.setVisible(true); } private static class IconPanel extends JComponent { @Override protected void paintComponent(Graphics g) { Icon icon = UIManager.getIcon("Tree.expandedIcon"); //also collapsedIcon icon.paintIcon(this, g, 0, 0); } } }