Sou novato em java e preciso criar uma tela que a cada select ela dependendo do resultado ela muda de cor…
Tentei usar: this.getContentPane().setBackground(Color.ORANGE);
this.setVisible(true);
Mas ele da um erro : non-static variable this cannot be referenced from a static context
Como posso resolver esse problema???
Obrigado
Esse seu this é uma classe?
Dê esse comando num método não estático.
Mas ele está dentro do
public static void main(String args[]) {
}
ele fica verificando e era pra mudar a cor da tela se entrar no IF…
Como poderia fazer??
Mas ele está dentro do
public static void main(String args[]) {
}
ele fica verificando e era pra mudar a cor da tela se entrar no IF…
Como poderia fazer??
Se vc criou o frame assim:
JFrame meuFrame = new JFrame();
Deveria ter chamado assim:
meuFrame.getContentPane().setColor(Color.ORANGE);
E não com this.
[quote=ViniGodoy]Se vc criou o frame assim:
JFrame meuFrame = new JFrame();
Deveria ter chamado assim:
meuFrame.getContentPane().setColor(Color.ORANGE);
E não com this.
[/quote]
Talves eu não esteja conseguindo explicar…
tenho um frame e nele mesmo estou tentando mudar a cor dele…
Mas para isso eu faço um select no banco de dados…
Segue o codigo… :
public static void main(String args[]) {
@Override
public void run() {
new InicioSeparacaoView().setVisible(true);
}
});
try {
verifica();
} catch (DbfDatabaseException ex) {
Logger.getLogger(InicioSeparacaoView.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void verifica() throws DbfDatabaseException {
long i = 0;
boolean resposta = true;
while (true) {
i++;
resposta = RomaneioDBFModel.verificaRomaneio();
if (resposta == true) {
System.out.println("Existe Romaneios I = " + i);
if (i == 5) {
// getContentPane().setBackground(Color.ORANGE); <-- ERRO
} else if (i == 10) {
// getContentPane().setBackground(Color.RED); <-- ERRO
}
} else {
i = 0;
System.out.println("NAO Existe Romaneios I = " + i);
//FORM VOLTANDO AO NORMAL
}
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
Logger.getLogger(InicioSeparacaoView.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Usa a tag code, senão fica impossível ler seu código:
Usa a tag code, senão fica impossível ler seu código:
public static void main(String args[]) {
@Override
public void run() {
new InicioSeparacaoView().setVisible(true);
}
});
try {
verifica();
} catch (DbfDatabaseException ex) {
Logger.getLogger(InicioSeparacaoView.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void verifica() throws DbfDatabaseException {
long i = 0;
boolean resposta = true;
while (true) {
i++;
resposta = RomaneioDBFModel.verificaRomaneio();
if (resposta == true) {
System.out.println("Existe Romaneios I = " + i);
if (i == 5) {
// getContentPane().setBackground(Color.ORANGE); <-- ERRO
} else if (i == 10) {
// getContentPane().setBackground(Color.RED); <-- ERRO
}
} else {
i = 0;
System.out.println("NAO Existe Romaneios I = " + i);
//FORM VOLTANDO AO NORMAL
}
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
Logger.getLogger(InicioSeparacaoView.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Cadê a indentação do código?!?!?