其實,我正在嘗試做一個遊戲的「設置」窗口,我想設置另一個窗口的背景顏色。我不知道該怎麼做。有些想法請問?如何使用JComboBox從另一個JFrame爲JFrame設置backgorund顏色?
0
A
回答
0
你可以在不同的地方實現它。其中一種方法是構造函數,例如:
public YourClassPanel() {
// to set Look&Feel
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (ClassNotFoundException ex) {
Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
}
SwingUtilities.updateComponentTreeUI(this);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
ControlPanel.tgp = null;
}
});
this.setBounds(0, 0, 710, 580);
this.setTitle("Buffer Allocation Panel");
this.setPreferredSize(null);
this.setResizable(false);
this.setBackground(Color.yellow); //to set Background
this.setForeground(Color.magenta); // to set Foreground
this.setOpaque(a!=255); // to set Opaque
}
0
從Properties
中爲JPanel
背景設置不同的顏色。
+0
我是一個Java初學者 –
+0
你能解釋一下嗎? –
相關問題
- 1. 從另一個jframe啓用jframe
- 2. 如何從另一個JFrame引用一個JFrame中的變量?
- 3. 另一個JFrame內的JFrame
- 4. 如何從另一個類調用JFrame?
- 5. 用JFrame調用JComboBox
- 6. 分配一個JFrame到另一個JFrame
- 7. 在另一個JFrame中調用JFrame
- 8. 如何創建一個新的JFrame,位置設置爲另一個JFrame的中間位置?
- 9. Java - 將JFrame的一半設置爲特定顏色
- 10. 如何從另一個JFrame方法顯示JFrame?
- 11. 如何從java中的另一個JFrame更新JFrame
- 12. 如何將對象從Jframe傳輸到另一個Jframe?
- 13. 從另一個JFrame的
- 14. 如何在2秒延遲後用另一個JFrame調用JFrame?
- 15. 如何訪問一個JFrame到另一個類JFrame
- 16. 如何將一個變量從一個JFrame傳遞到另一個JFrame
- 17. 如何用來自另一個JFrame的數據更新JFrame?
- 18. 從一個jframe中的textfield傳遞參數到另一個jframe
- 19. 無法使JComboBox更新JFrame
- 20. 如何從JFrame的一個按鈕,點擊後過渡到另一個JFrame的?
- 21. Java Jframe啓動另一個X服務器的另一個JFrame
- 22. 從一個JFrame移動到另一個
- 23. 從一個JFrame切換到另一個
- 24. 如何更改JFrame的背景顏色
- 25. 從另一個類調用Jframe
- 26. 從另一個類調用JFrame
- 27. 如何使一個JFrame按鈕在Netbeans中打開另一個JFrame類?
- 28. 如何使一個JFrame按鈕在Textpad中打開另一個JFrame類
- 29. 如何設置Jframe 5秒
- 30. GUI - 更改JFrame的顏色
的可能的複製[如何顯示在我的組合框中選定的顏色(http://stackoverflow.com/questions/15995375/how-to-display-在我的組合框中選擇顏色) –