How to install/configure custom Java Look-And-Feel?
Asked Answered
S

3

5

I'm trying to install Sea Glass Look and Feel. I want to install/configure the LaF using a property file, but the tutorial that outlines this process is quite confusing.

That being said, can anyone provide a simple step-by-step guide on installing/configuring a custom LaF using a property file?

Solvent answered 3/2, 2012 at 2:40 Comment(0)
R
6

From their website:

To use the Sea Glass Look and Feel, you must either include our Maven repository in your pom.xml file or download the jar file and include it in your class path. See the downloads page for more details.

To enable the Sea Glass Look and Feel, include the following in your application before creating any controls:

try {
    UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
} catch (Exception e) {
    e.printStackTrace();
}

We also support setting the user interface on the command line using the VM option

-Dswing.defaultlaf=com.seaglasslookandfeel.SeaGlassLookAndFeel
Recurved answered 3/2, 2012 at 2:51 Comment(0)
L
4

Here are the steps to install the Sea Glass L&F using the jar file (Note that i use eclipse so the instructions will be in eclipse)

  1. Download the LaF jar file in their Maven repository.
  2. Put the .jar file in a designated folder in your project
  3. Right click your project folder in eclipse the go to 'Build Path' then select 'Configure Build Path'
  4. Under Libraries tab, click 'Add External Jar' and go to the folder that contains the jar file
  5. Click Ok then in your code go to your public static void main(String[] args) and copy paste this snippet:

    try {
        UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
    } catch (Exception e) {
        e.printStackTrace();
    }
    

There you go, the L&F is now applied. If you have questions just ask it

Leanto answered 22/8, 2014 at 12:30 Comment(0)
T
2

I haven't any issue running that from NB IDE

enter image description here

from code

import java.awt.*;
import javax.swing.*;
//import javax.swing.plaf.InsetsUIResource;

public class NimbusJPanelBackGround {

    public NimbusJPanelBackGround() {
        JFrame f = new JFrame();
        JButton btn = new JButton("  Whatever  ");
        JButton btn1 = new JButton("  Whatever  ");
        JPanel p = new JPanel();
        p.add(btn);
        //UIManager.getLookAndFeelDefaults().put("Button.contentMargins", new InsetsUIResource(0, 0, 0, 0));
        //SwingUtilities.updateComponentTreeUI(f);
        p.add(btn1);
        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        f.add(p, BorderLayout.CENTER);
        f.setSize(200, 100);
        f.setLocation(150, 150);
        f.setVisible(true);
    }

    public static void main(String[] args) {

        /*try {
        for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(laf.getName())) {
        UIManager.setLookAndFeel(laf.getClassName());
        UIManager.getLookAndFeelDefaults().put("Panel.background", Color.white);
        }
        }
        } catch (Exception e) {
        e.printStackTrace();
        }*/

        try {
            UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }


        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                NimbusJPanelBackGround nimbusJPanelBackGround = new NimbusJPanelBackGround();
            }
        });
    }
}

EDIT:

nor from Substance L&F emulator notice for viewing my answer is required users reputation >10k, answer is deleted by community as not an answer :-)

Tilton answered 3/2, 2012 at 8:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.