1
什麼是改變與海玻璃JFrame的背景看,感覺有道,至今我都嘗試:變化Jframe的中海玻璃背景外觀和感覺
frame.getContentPane().setBackground(Color.blue);
和
JPanel x = new JPanel();
x.setBackground(Color.red);
frame.setContentPane(x);
但它沒有任何影響:
import javax.swing.*;
import com.seaglasslookandfeel.*;
import java.awt.*;
import java.awt.Color.*;
public class BORDER_TEST {
public static void main(String[] a){
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
JFrame frame = new JFrame();
JPanel x = new JPanel();
x.setBackground(Color.red);
frame.setContentPane(x);
//frame.getContentPane().setBackground(Color.blue);
frame.setPreferredSize(new Dimension(900,350));
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
負載L&F通過UIManager的。例如:http://stackoverflow.com/questions/9541045/how-to-set-jframe-look-and-feel之後,做任何你想要的,即改變其背景 – 2012-03-26 02:30:33
一些L&F可能需要你改變一些UI通過調用setProperty()或其他東西。您可能需要查看其文檔。也有L&F與一個「越野車」的實施,不允許你改變你想要的東西!如果發生這種情況,您可能需要重寫其paintComponent()以使用其默認的UI組件繪畫行爲並應用新的組件繪畫行爲。 – 2012-03-26 02:48:18