0
我重寫功能getForeGroundAt和getBackgroundAt的選項卡面板爲這樣:getBackgroundAt方法在我的程序不採取行動,通常
jtp = new JTabbedPane(SwingConstants.LEFT) {
public Color getForegroundAt(int index) {
if (getSelectedIndex() == index) {
System.out.println("ueue1");
return new Color(69, 69, 69);
}
return new Color(188, 188, 188);
}
public Color getBackgroundAt(int index) {
if (getSelectedIndex() == index) {
System.out.println("ueue2");
return new Color(247, 248, 243);
}
return new Color(255, 255, 255);
}
};
我現在面臨的問題是,在getBackgrountAt方法print語句是永遠甚至當我選擇不同的選項卡時setForegroundAt中的選項卡正常工作。結果是我無法設置所選標籤的背景顏色,但我可以設置前景顏色。我該如何解決這個問題?謝謝。