frame.setBackground(颜色.BLUE); |
JFrame 包含更多技巧,您可以将其应用于 java 颜色类:
- RGB values
- 使用更亮、 更深或更亮
还有其他方法可以检索组件的颜色等。
JFrame 示例 setBackground(color)
您可以在 IDE 中测试此代码:
import java.awt.Color;
导入 java.awt.Dimension;
导入 javax.swing.JFrame;
public class Test extends JFrame{
public static void main(String[] args) {
JFrame frame = new JFrame(JFrame test”);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setPreferredSize(new Dimension(400, 300));
frame.getContentPane().setBackground(Color.ORANGE);
frame.pack();
frame.setVisible(true);
}
}
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...