【发布时间】:2012-12-19 00:47:21
【问题描述】:
我对 java swing 很陌生,不熟悉paint()。我想用上面的样子在 java swing 中创建一个按钮。 谁能帮我做到这一点。任何指导将不胜感激。提前致谢
【问题讨论】:
-
除了
Background and Foreground Colour之外,这个JButton有什么不同?对我来说是一样的 :-) 为什么你不能使用button.setBackground(Color.BLUE.darker())和button.setForeground(Color.LIGHT_GRAY.brighter()),如果你想要更多效果,请更改 JButton 的字体? -
是的。我希望我的按钮在 facebook 上看起来很受宠若惊。避免梯度。你能帮忙吗?
-
试试这个,非常接近你的喜好:
button.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createBevelBorder( BevelBorder.RAISED, Color.BLUE.darker(), Color.BLACK), BorderFactory.createEtchedBorder(EtchedBorder.LOWERED))); button.setFont(new Font("Arial", Font.BOLD, 14));