Add the following code inside your main()
:
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Throwable e) {
e.printStackTrace();
}
For example leaving so:
public class Tela extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Throwable e) {
e.printStackTrace();
}
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Tela frame = new Tela();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Tela() {
...
}
}
By adding the code in question, you are applying the Look and Feel of your system, otherwise the application will choose the standard that is Metal.
Crossplatformlookandfeel-this is the "Java L&F" (also called "Metal") that looks the same on all Platforms. It is part of the Java API (javax.swing.plaf.metal) and is the default that will be used if you do Nothing in your code to set a Different L&F.
Source: The Java Tutorials - How to Set the Look and Feel
Thanks @Math. Solved in parts my problem. The look and Feel components have been changed. However the problem of spacing still continues. :/
– Maicon Funke
Spacing between the components? Could [Edit] your question and put a print to understand how it looks? 'Cause I can’t see that difference running my own project.
– Math
Take a look at figure 1, the buttons below "clean", "save" and "save and exit" are aligned, already in figure 2 after compilation these spacings are lost.
– Maicon Funke
Oh yes, now I noticed this. Which Layout Manager is using in the footer? For example, Borderlayout, Gridbaglayout, Miglayout, etc..
– Math
I solved it. Just pay a little more attention on the grid! Thanks!
– Maicon Funke