gpt4 book ai didi

java - 无法在我的自定义 jdialog 中更改 jseparator 的背景前景色

转载 作者:行者123 更新时间:2023-11-30 05:35:26 25 4
gpt4 key购买 nike

我在自定义 jdialog 中使用 JSeparator

这是我的代码:

public class CheckDialog extends javax.swing.JDialog {
private boolean setuju =false;

public CheckDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
JSeparator jSeparator4 = new JSeparator(SwingConstants.HORIZONTAL);
JSeparator jSeparator6 = new JSeparator(SwingConstants.HORIZONTAL);
JSeparator jSeparator7 = new JSeparator(SwingConstants.HORIZONTAL);
jSeparator4.setBackground(new java.awt.Color(0, 0, 51));
jSeparator4.setForeground(new java.awt.Color(0, 0, 51));
jPanel2.add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 280, 10));
jSeparator6.setBackground(new java.awt.Color(0, 0, 51));
jSeparator6.setForeground(new java.awt.Color(0, 0, 51));
jPanel10.add(jSeparator6, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 40, 10));
jSeparator7.setBackground(new java.awt.Color(0, 0, 51));
jSeparator7.setForeground(new java.awt.Color(0, 0, 51));
jPanel1.add(jSeparator7, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 110, 10));
}

public boolean showDialog() {
this.setUndecorated(true);
this.pack();
this.setBackground(new Color(0,0,0,0));
this.setLocationRelativeTo(null);
this.setVisible(true);
return setuju;
}
}

my result

我预计分隔符颜色应为 (0, 0, 51),但分隔符保留其默认颜色,例如 (212, 212, 212)。

最佳答案

发生这种情况是因为我忘记在我的类中设置Look-and-Feel

感谢@SergiyMedvynskyy

关于java - 无法在我的自定义 jdialog 中更改 jseparator 的背景前景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56738431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com