2
A
回答
2
你可以設置一個JButton
的背景圖像,你可以看看這個:Swing Tutorial: JButton這表明使用new JButton(String text,ImageIcon imgIco)
的創建具有ImageIcon
和String
一個JButton
。
要設置背景顏色和文字,你可以使用setBackground(Color c)
和setForeground(Color c)
或
或者只是定製外觀和設置適當的支持Look and Feel然後change the color scheme/size etc of its components thier數以百計的事情感到配色方案您可以更改每個組件,詳見this。
要定製的退出,最小化和最大化工具欄按鈕,這也可以通過外觀(Custom design for Close/Minimize buttons on JFrame):
import java.awt.BorderLayout;
import javax.swing.*;
public class FrameCloseButtonsByLookAndFeel {
FrameCloseButtonsByLookAndFeel() {
String[] names = {
UIManager.getSystemLookAndFeelClassName(),
UIManager.getCrossPlatformLookAndFeelClassName()
};
for (String name : names) {
try {
UIManager.setLookAndFeel(name);
} catch (Exception e) {
e.printStackTrace();
}
// very important to get the window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame(UIManager.getLookAndFeel().getName());
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JPanel gui = new JPanel(new BorderLayout());
f.setContentPane(gui);
JTree tree = new JTree();
tree.setVisibleRowCount(4);
gui.add(tree, BorderLayout.LINE_START);
gui.add(new JScrollPane(new JTextArea(3,15)));
JToolBar toolbar = new JToolBar();
gui.add(toolbar, BorderLayout.PAGE_START);
for (int ii=1; ii<5; ii++) {
toolbar.add(new JButton("Button " + ii));
if (ii%2==0) {
toolbar.addSeparator();
}
}
f.pack();
f.setLocationByPlatform(true);
f.setVisible(true);
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new FrameCloseButtonsByLookAndFeel();
}
});
}
}
0
嘛更改框架標題欄外觀的最簡單方法是在創建框架之前設置LookAndFeel。 也許這就是你要找的 - http://www.jtattoo.net/ScreenShots.html
相關問題
- 1. Win7標題欄頂部的黑色圖層(最小化/最大化/關閉)
- 2. 更改窗口圖標的最小化,關閉並最大化
- 3. c#最大化,最小化和關閉窗體上的按鈕
- 4. XAML通過SystemCommands最小化/最大化/關閉按鈕
- 5. 窗體在關閉,最小化或最大化時掛起
- 6. Qt隱藏最小化,最大化和關閉按鈕
- 7. C#自定義關閉,最小化和最大化按鈕
- 8. 最大化,最小化和關閉網頁中每個部分的按鈕
- 9. 最小化/最大化div
- 10. Electron v1.7:關閉,最大化和最大化
- 11. 如何使自定義關閉/最小化/最大化菜單停靠在右側/左側窗口10屏幕
- 12. 最小化/最大化/關閉按鈕的工具提示和DevExpress的LookAndFeel都
- 13. 獲取默認的Windows系統圖標的最小化,最大化和關閉
- 14. 如何渲染窗口關閉/最大化/最小化wpf中的按鈕?
- 15. 隱藏最大化/最小化和關閉按鈕的Matlab圖形窗口
- 16. 最小化,最大化exe的
- 17. 功能區控制顯示Windows 2000最小化/最大化/關閉按鈕
- 18. 最大化最小差異
- 19. 如何最大化/最小化iFrame?
- 20. 在android中最大化和最小化
- 21. 禁用窗口最大化/最小化
- 22. 最小化ExtJS的大小
- 23. 「x」最小化WinForm,ContextMenu關閉WinForm?
- 24. .Net WinForms - 刪除關閉,調整大小和最小化按鈕
- 25. 彈出窗口最大化和關閉,調整大小選項
- 26. Java JList刷新後才能最小化或最大化
- 27. Drupal:如何最小化日誌菜單?
- 28. 如何在Java中隱藏JFrame窗口上的默認最小化/最大化和關閉按鈕?
- 29. c#表單最小化/最大化按鈕不見了?
- 30. Java最小化依賴關係