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 -------------------------------------------------------------------- |
- Re: [java-list] Arquivo swing.properties Jefferson Prestes
- Re: [java-list] Arquivo swing.properties Lincolm Ferreira de Aguiar
- Re: [java-list] Arquivo swing.properti... Jefferson Prestes