D
D
Dmitry Posokhov2016-09-07 06:35:25
Java
Dmitry Posokhov, 2016-09-07 06:35:25

How to change LaF from Metal to Nimbus or Windows?

Good afternoon.
I just recently learned how to create programs in Java with a GUI interface. Therefore, do not judge strictly for possibly stupid questions.
As a matter of fact, I program in NetBeans v8.1, with Java v1.8.0.91 (this is so .. just in case). And the problem is this: I click on the jFrame with the right mouse button, select "Nimbus" -> "Nimbus" from the menu. I liked this design. But in the final compilation, the program opens with the Metal design. How to make it so that the program with Nimbus opens in the end, and not just in the preview?
ps1. Honestly, I do not even know how to formulate the question correctly, but I hope it will be clear.
ps2. And for some reason, the transparency of the frame does not change for me ... I do setOpasity (0.5f); And it gives an error, if anyone has time, tell me how to solve it? If at all possible.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Posokhov, 2016-09-07
@Dmitriy625

All solved the problem. It was necessary just to make the class with the form the main one. And then I did it stupidly ... I created a separate class from which I called the form. Sorry for the wasted time. Now everything works. I just change words in the lane, and laf itself changes

S
Sergey Gornostaev, 2016-09-07
@sergey-gornostaev

The Java™ Tutorials: Nimbus Look and Feel

import javax.swing.UIManager.*;

try {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }
} catch (Exception e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question