I'm using the Eclipse IDE and I have this code:
package br.com.caelum.argentum.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class ArgentumUI {
private JFrame janela;
private JPanel painelPrincipal;
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("napkin.NapkinLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
new ArgentumUI().montaTela();
}
public void montaTela() {
preparaJanela();
preparaPainelPrincipal();
preparaBotaoCarregar();
preparaBotaoSair();
mostraJanela();
}
private void mostraJanela() {
// TODO Auto-generated method stub
janela.pack();
janela.setSize(540, 540);
janela.setVisible(true);
}
private void preparaBotaoSair() {
// TODO Auto-generated method stub
JButton botaoSair = new JButton("Sair");
botaoSair.setMnemonic(KeyEvent.VK_S);
botaoSair.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
painelPrincipal.add(botaoSair);
}
private void preparaBotaoCarregar() {
// TODO Auto-generated method stub
JButton botaoCarregar = new JButton("Carregar XML");
botaoCarregar.setMnemonic(KeyEvent.VK_C);
botaoCarregar.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new EscolhedorDeXML().escolhe();
}
});
painelPrincipal.add(botaoCarregar);
}
private void preparaPainelPrincipal() {
// TODO Auto-generated method stub
painelPrincipal = new JPanel();
janela.add(painelPrincipal);
}
private void preparaJanela() {
// TODO Auto-generated method stub
janela = new JFrame("Argentum");
janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Napkin is already in Referenced Libraries, however I'm getting these errors:
keys we didn't overwrite: []
Exception in thread "main" java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setBackground(Frame.java:986)
at javax.swing.JFrame.frameInit(JFrame.java:253)
at javax.swing.JFrame.<init>(JFrame.java:219)
at br.com.caelum.argentum.ui.ArgentumUI.preparaJanela(ArgentumUI.java:77)
at br.com.caelum.argentum.ui.ArgentumUI.montaTela(ArgentumUI.java:26)
at br.com.caelum.argentum.ui.ArgentumUI.main(ArgentumUI.java:22)
How to fix?