1
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, but 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 correct?
Thanks for the help Anthony, but another problem has arisen now ... When you click XML load the new Chooserdexml.choose() line is executed, and it generates a dialog box with nothing... Not to abuse your goodwill, but could you give me a hand? I’ll leave the link to Gist with the code of that class. Thank you https://gist.github.com/VictorGee/430474575c68c04d3212
– Victor G
Hi Victor, it’s the same problem only inside a
JDialog
created byJFileChooser
, I don’t see any simple way to make it spin. You can try opening another question, but I think you should try running the app with another Look And Feel.– Anthony Accioly
Okay, Anthony, thank you !
– Victor G