-----Mensagem Original-----
Enviada em: sexta-feira, 4 de janeiro de
2002 8:37
Assunto: Re: [java-list] Arquivo
swing.properties
O que etá acontecendo é que a sua
variável strPlat não está recebendo nenhum valor porque nenhum dos if está
sendo satisfatório. Mude seus if para esta forma e funcionará.
if (objSource.equals(btnMetal)) //
<== A comparação é com o o objeto, não o texto do botão
{
strPlat =
"javax.swing.plaf.metal.MetalLookAndFeel";
}
if
(objSource.equals(btnMotif))
{
strPlat =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
}
if
(objSource.equals(btnWindows))
{
strPlat
= "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
}
Atenciosamente,
----- Original Message -----
Sent: Thursday, January 03, 2002 5:20
PM
Subject: [java-list] Arquivo
swing.properties
Pessoal,
estava testando as opções de GUI (look
and feel) e criei meu .class e nada de mudar. Daí procurei o arquivos de
configurações do swing (swing.properties, por exemplo) e não os encontrei.
Será que a falta deles influência nessa falha do programa que
criei.
Se não, por favor, vejam se fiz alguma
besteira no código abaixo. Detalhe: compilei sem problemas!
import java.awt.*;
import java.awt.event.*;
import
javax.swing.*;
class panPlat extends JPanel implements
ActionListener
{
public
panPlat()
{
btnMetal = new
JButton("Metal");
btnMotif = new
JButton("Motif");
btnWindows = new
JButton("Windows");
add(btnMetal);
add(btnMotif);
add(btnWindows);
btnMetal.addActionListener(this);
btnMotif.addActionListener(this);
btnWindows.addActionListener(this);
}
public
void actionPerformed(ActionEvent
evt)
{
Object objSource =
evt.getSource();
String strPlat =
"";
if (objSource ==
"Metal")
{
strPlat =
"javax.swing.plaf.metal.MetalLookAndFeel";
}
if
(objSource ==
"Motif")
{
strPlat =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
}
if
(objSource ==
"Windows")
{
strPlat =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
}
try
{
UIManager.setLookAndFeel(strPlat);
SwingUtilities.updateComponentTreeUI(this);
}
catch
(Exception
e)
{
}
}
private
JButton btnMetal;
private JButton
btnMotif;
private JButton
btnWindows;
}
class frmPlat extends
JFrame
{
public
frmPlat()
{
setTitle("Muda Visual do
Java");
Toolkit tk =
Toolkit.getDefaultToolkit();
Dimension d =
tk.getScreenSize();
setSize((d.width/4),
(d.height/4));
setLocation((d.width/4),
(d.height/4));
addWindowListener(new
WindowAdapter()
{
public
void windowClosing(WindowEvent
e)
{
System.exit(0);
}
});
Container
con = getContentPane();
con.add(new
panPlat());
}
}
public class
TrocaPlataforma
{
public static void main(String
args[])
{
JFrame frame = new
frmPlat();
frame.show();
}
}
Até logo!
--------------------------------------------------------------------
Jefferson
Prestes
UNIBAN - Campus MC
DSI - Divisão de Sistemas de
Informações
--------------------------------------------------------------------