Pessoal,
Peguei a Substance Look And Feel para utilização de Skin´s, porém ao tentar executar meu aplicativo ocorre este erro:
java.lang.IllegalStateException: This method must be called on the Event Dispatch Thread
org.jvnet.substance.SubstanceLookAndFeel.setSkin(SubstanceLookAndFeel.java:1954)
org.jvnet.substance.SubstanceLookAndFeel.initialize(SubstanceLookAndFeel.java:1601)
javax.swing.UIManager.setLookAndFeel(UIManager.java:540)
javax.swing.UIManager.setLookAndFeel(UIManager.java:585)
CPR.Main.main(Main.java:48)
O meu código está assim:
/*
* MAINCLASS.java
*
* Criado em 4 de Outubro de 2006, 09:02
*
*/
package CPR;
/* import contrib.ch.randelshofer.quaqua.util.Images; */
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jvnet.substance.skin.SubstanceBusinessLookAndFeel;
/**
* Classe principal do sistema MAINCLASS.
*/
public class Main extends JFrame {
public static void main(String[] args) {
try {
Splash splashInstance = Splash.getInstance("image/logo.gif");
splashInstance.addManualProgressBar(0, 14); // 14 = Número de passos a serem efetuados na inicialização
splashInstance.showSplash();
splashInstance.setProgressBarValue(0);
splashInstance.setProgressBarString("Inicializando o sistema ...");
CFGManager cfgInstance = CFGManager.getInstance();
String LAFativo = cfgInstance.getValueString("LAF_ATIVO");
String LAFName;
if (LAFativo.equals("1")) {
LAFName = "org.jvnet.substance.skin.SubstanceBusinessLookAndFeel";
} else {
LAFName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
}
try {
UIManager.setLookAndFeel(LAFName);
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
} catch (UnsupportedLookAndFeelException ulafe) {
Utilidades utilInstance = Utilidades.getInstance();
String stackMensagem = utilInstance.montaMensagemErro(ulafe.toString(),ulafe.getStackTrace());
utilInstance.exibeMensagem("Erro","Não foi possível setar o 'LookAndFeel' como '" + cfgInstance.getValueString("LOOK_AND_FEEL") + "'.",stackMensagem,utilInstance.MSGERROR);
System.exit(0);
} catch (ClassNotFoundException cnfe) {
Utilidades utilInstance = Utilidades.getInstance();
String stackMensagem = utilInstance.montaMensagemErro(cnfe.toString(),cnfe.getStackTrace());
utilInstance.exibeMensagem("Erro","Classe LookAndFeel '" + cfgInstance.getValueString("CLASS_LOOK_AND_FEEL") + "' não foi encontrada.",stackMensagem,utilInstance.MSGERROR);
System.exit(0);
} catch (InstantiationException ie) {
Utilidades utilInstance = Utilidades.getInstance();
String stackMensagem = utilInstance.montaMensagemErro(ie.toString(),ie.getStackTrace());
utilInstance.exibeMensagem("Erro","Falha ao instanciar a classe LookAndFeel '"+ cfgInstance.getValueString("CLASS_LOOK_AND_FEEL") + "'",stackMensagem,utilInstance.MSGERROR);
System.exit(0);
} catch (IllegalAccessException iae) {
Utilidades utilInstance = Utilidades.getInstance();
String stackMensagem = utilInstance.montaMensagemErro(iae.toString(),iae.getStackTrace());
utilInstance.exibeMensagem("Erro","Acesso negado a classe LookAndFeel '" + cfgInstance.getValueString("CLASS_LOOK_AND_FEEL") + "'",stackMensagem,utilInstance.MSGERROR);
System.exit(0);
} catch (Exception iae) {
Utilidades utilInstance = Utilidades.getInstance();
String stackMensagem = utilInstance.montaMensagemErro(iae.toString(),iae.getStackTrace());
utilInstance.exibeMensagem("Erro","Erro na busca da classe LookAndFeel '" + cfgInstance.getValueString("CLASS_LOOK_AND_FEEL") + "'",stackMensagem,utilInstance.MSGERROR);
System.exit(0);
}
InicializaSistema initInstance = InicializaSistema.getInstance();
initInstance.Inicializa();
splashInstance.hideSplash();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
MPrincipal menuPrinc = MPrincipal.getInstance();
menuPrinc.initApplication();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
O erro dá na linha 48:
UIManager.setLookAndFeel(LAFName);
Alguém o que causa este erro e como resolver?