hlds
Setembro 11, 2006, 11:47am
#1
Pessoal, tava mexendo c swing e tals, mas nunca tinha precisado mexer na aparência das janelas e tals, agora to precisando, seguinte, geralmente aplicações swing usam aquele botao metalico, campos de texto um pouco grande, cor de fundo cinza e tals, eu queria uma aparência mais puxada p windows, com botoes menores, fundo puxado mais p/ um bege claro, etc, etc, etc(vide fotos):
Como faco p conseguir isto, qual opcao q mexo, tem a ver c Look and Feel? Vlws…
cassio
Setembro 11, 2006, 11:53am
#2
Pesquisa sobre LookandFeel
neste site http://www.javootoo.com voce encontra diversos look & feels gratuitos e comerciais.
E no caso de um look proximo ao do windows, tem o do JGoodies que possui suporte a temas http://www.jgoodies.com/downloads/libraries.html
abraços,
Gyowanny Queiroz
hlds
Setembro 11, 2006, 2:25pm
#4
mas esta “aparencia windows” do L&F eh setada por uma biblioteca .jar q anexamos ao porgrama (dai sera visualizada independete de sistema operacional) ou ele usa as janelas do sistema operacional (dai sim, no Linux n exibe) ou podemos fazer pelos 2 metodos?
hlds
Setembro 11, 2006, 10:33pm
#5
Eu coloquei um L&F tipo Xp q peguei na net e testei o pacote q colocaram ai tb, mas n saiu oi layout do Xp n (mudou 1 pouco, mas n como o do Xp), vcs sabem o q foi q aconteceu?
[code]/*
Main.java
Created on 11 de Setembro de 2006, 14:44
*/
package look_feel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/**
*
@author heverton
*/
public class Main extends javax.swing.JFrame {
/** Creates new form Main */
public Main() {
initComponents();
}
/** This method is called from within the constructor to
initialize the form.
WARNING: Do NOT modify this code. The content of this method is
always regenerated by the Form Editor.
*/
//
private void initComponents() {
jTabbedPane3 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jSlider2 = new javax.swing.JSlider();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField1.setText(“jTextField1”);
jButton1.setText(“jButton1”);
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(114, 114, 114)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jPanel1Layout.createSequentialGroup()
.add(141, 141, 141)
.add(jButton1)))
.addContainerGap(145, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(63, 63, 63)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(56, 56, 56)
.add(jButton1)
.addContainerGap(111, Short.MAX_VALUE))
);
jTabbedPane3.addTab(“tab1”, jPanel1);
org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.add(84, 84, 84)
.add(jSlider2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(91, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.add(120, 120, 120)
.add(jSlider2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(127, Short.MAX_VALUE))
);
jTabbedPane3.addTab(“tab2”, jPanel2);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jTabbedPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jTabbedPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}//
/**
@param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
try {
UIManager.setLookAndFeel(“com.stefankrause.xplookandfeel.XPLookAndFeel”);
} catch (Exception e) {
JOptionPane.showMessageDialog(null,“Não foi possível carregar o “Skin” padrão. Definindo o padrão original.”,
“Erro”, JOptionPane.ERROR_MESSAGE);
}
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSlider jSlider2;
private javax.swing.JTabbedPane jTabbedPane3;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}[/code]
Pq n deu?
wes_00
Outubro 8, 2008, 2:11pm
#6
tem como eu faser no menu bar uma opçao para que o usuario escolha qual lok ele qer…
tipow…
ai em cima mostra um look de tema do windows… dae eu colocar mais algumas opçoes e o usuario que escolhe o tema do programa que ele qer…
vlws
Spool
Setembro 11, 2006, 1:11pm
#7
hlds, adicione o seguinte codigo no seu método main():
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
JOptionPane.showMessageDialog(null,
"Não foi possível carregar o \"Skin\" padrão. Definindo o padrão original.", "Erro",
JOptionPane.ERROR_MESSAGE);
}
// restante do seu codigo aqui.
Lembrando que esse Look And Feel só funcionará no Windows. Linux não aceita.
sendAbraços();