Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions test/jdk/javax/swing/JPasswordField/bug4382819.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

import java.awt.FlowLayout;
import java.awt.event.ItemListener;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPasswordField;

/*
* @test
* @bug 4382819
* @summary Tests the correctness of color used for the disabled passwordField.
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual bug4382819
*/

public class bug4382819 {
static JCheckBox enabledCheckBox;
static JPasswordField passwordField;

private static final String INSTRUCTIONS = """
Clear the "enabled" checkbox.
If the JPasswordField's foreground color changes to
light gray press Pass. If it stays black press Fail.
""";

public static void main(String[] args) throws Exception {
PassFailJFrame.builder()
.instructions(INSTRUCTIONS)
.columns(50)
.testUI(bug4382819::createTestUI)
.build()
.awaitAndCheck();
}

public static JFrame createTestUI() {
JFrame mainFrame = new JFrame("bug4382819");
enabledCheckBox = new javax.swing.JCheckBox();
enabledCheckBox.setSelected(true);
enabledCheckBox.setText("enabled");
enabledCheckBox.setActionCommand("enabled");
mainFrame.add(enabledCheckBox);

passwordField = new javax.swing.JPasswordField();
passwordField.setText("blahblahblah");
mainFrame.add(passwordField);
SymItem lSymItem = new SymItem();
enabledCheckBox.addItemListener(lSymItem);

mainFrame.setSize(300, 100);
mainFrame.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
return mainFrame;
}

static class SymItem implements ItemListener {
public void itemStateChanged(java.awt.event.ItemEvent event) {
Object object = event.getSource();
if (object == enabledCheckBox) {
passwordField.setEnabled(enabledCheckBox.isSelected());
}
}
}
}

94 changes: 94 additions & 0 deletions test/jdk/javax/swing/JSplitPane/bug4820080.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Panel;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.UIManager;

/*
* @test
* @bug 4820080 7175397
* @summary RFE: Cannot Change the JSplitPane Divider Color while dragging
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual bug4820080
*/

public class bug4820080 {
private static final String INSTRUCTIONS = """
Drag the dividers of the splitpanes (both top and bottom). If the divider
color is green while dragging then test passes, otherwise test fails.
""";

public static void main(String[] args) throws Exception {
PassFailJFrame.builder()
.instructions(INSTRUCTIONS)
.columns(50)
.testUI(bug4820080::createTestUI)
.build()
.awaitAndCheck();
}

public static JFrame createTestUI() {
JFrame frame = new JFrame("bug4820080");
UIManager.put("SplitPaneDivider.draggingColor", Color.GREEN);

Box box = new Box(BoxLayout.Y_AXIS);
frame.add(box);

JPanel jleft = new JPanel();
jleft.setBackground(Color.DARK_GRAY);
jleft.setPreferredSize(new Dimension(100, 100));
JPanel jright = new JPanel();
jright.setBackground(Color.DARK_GRAY);
jright.setPreferredSize(new Dimension(100, 100));

JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jleft, jright);
jsp.setContinuousLayout(false);
box.add(jsp);

box.add(Box.createVerticalStrut(5));
box.add(new JSeparator());
box.add(Box.createVerticalStrut(5));

Panel left = new Panel();
left.setBackground(Color.DARK_GRAY);
left.setPreferredSize(new Dimension(100, 100));
Panel right = new Panel();
right.setBackground(Color.DARK_GRAY);
right.setPreferredSize(new Dimension(100, 100));

JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
sp.setContinuousLayout(false);
box.add(sp);
frame.pack();
return frame;
}
}