jdk/test/javax/swing/JSlider/SliderTick/SliderTickTest.java
author vromero
Thu, 05 Jan 2017 11:16:39 -0800
changeset 43033 c37b643739a7
parent 41007 d48361243925
permissions -rw-r--r--
8148100: Convert lambda most specific positive tests to check runtime behavior Reviewed-by: mcimadamore Contributed-by: bsrbnd@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41007
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     1
/*
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     4
 *
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     8
 *
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    13
 * accompanied this code).
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    14
 *
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    18
 *
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    21
 * questions.
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    22
 */
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    23
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    24
 /*
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    25
 * @test
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    26
 * @bug 8009477
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    27
 * @summary Verify PageUp/PageDown key moves slider to Next/Previous minor tick.
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    28
 * @run main/manual SliderTickTest
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    29
 */
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    30
import java.awt.Color;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    31
import java.awt.GridBagConstraints;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    32
import java.awt.GridBagLayout;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    33
import java.util.concurrent.CountDownLatch;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    34
import javax.swing.BorderFactory;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    35
import javax.swing.JPanel;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    36
import javax.swing.JTextArea;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    37
import javax.swing.SwingUtilities;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    38
import javax.swing.JButton;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    39
import javax.swing.JFrame;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    40
import java.awt.event.ActionEvent;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    41
import java.awt.event.ActionListener;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    42
import java.util.concurrent.TimeUnit;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    43
import javax.swing.JSlider;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    44
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    45
public class SliderTickTest {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    46
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    47
    public static void main(String args[]) throws Exception {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    48
        final CountDownLatch latch = new CountDownLatch(1);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    49
        TestUI test = new TestUI(latch);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    50
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    51
        SwingUtilities.invokeLater(new Runnable() {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    52
            @Override
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    53
            public void run() {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    54
                try {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    55
                    test.createUI();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    56
                } catch (Exception ex) {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    57
                    throw new RuntimeException("Exception while creating UI");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    58
                }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    59
            }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    60
        });
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    61
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    62
        boolean status = latch.await(5, TimeUnit.MINUTES);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    63
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    64
        if (!status) {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    65
            System.out.println("Test timed out.");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    66
        }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    67
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    68
        SwingUtilities.invokeAndWait(new Runnable() {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    69
            @Override
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    70
            public void run() {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    71
                try {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    72
                    test.disposeUI();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    73
                } catch (Exception ex) {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    74
                    throw new RuntimeException("Exception while disposing UI");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    75
                }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    76
            }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    77
        });
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    78
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    79
        if (test.testResult == false) {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    80
            throw new RuntimeException("Test Failed.");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    81
        }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    82
    }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    83
}
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    84
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    85
class TestUI {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    86
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    87
    private static JFrame mainFrame;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    88
    private static JPanel mainControlPanel;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    89
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    90
    private static JTextArea instructionTextArea;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    91
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    92
    private static JPanel resultButtonPanel;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    93
    private static JButton passButton;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    94
    private static JButton failButton;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    95
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    96
    private static GridBagLayout layout;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    97
    private final CountDownLatch latch;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    98
    public boolean testResult = false;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
    99
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   100
    public TestUI(CountDownLatch latch) throws Exception {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   101
        this.latch = latch;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   102
    }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   103
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   104
    public final void createUI() throws Exception {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   105
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   106
        mainFrame = new JFrame("SliderTickTest");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   107
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   108
        layout = new GridBagLayout();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   109
        mainControlPanel = new JPanel(layout);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   110
        resultButtonPanel = new JPanel(layout);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   111
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   112
        GridBagConstraints gbc = new GridBagConstraints();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   113
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   114
        // Create Test instructions
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   115
        String instructions
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   116
                = "INSTRUCTIONS:"
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   117
                + "\n Click PageUp/PageDown key. If the slider indicator"
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   118
                + "\n moves to Next/Previous immediate minor tick, then "
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   119
                + "\n test passes else failed.";
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   120
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   121
        instructionTextArea = new JTextArea();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   122
        instructionTextArea.setText(instructions);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   123
        instructionTextArea.setEnabled(false);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   124
        instructionTextArea.setDisabledTextColor(Color.black);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   125
        instructionTextArea.setBackground(Color.white);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   126
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   127
        gbc.gridx = 0;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   128
        gbc.gridy = 0;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   129
        gbc.fill = GridBagConstraints.HORIZONTAL;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   130
        mainControlPanel.add(instructionTextArea, gbc);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   131
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   132
        JSlider slider = new JSlider(0, 50);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   133
        slider.setMajorTickSpacing(10);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   134
        slider.setMinorTickSpacing(2);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   135
        slider.setPaintTicks(true);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   136
        slider.setPaintLabels(true);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   137
        slider.setValue(30);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   138
        slider.setBorder(BorderFactory.createTitledBorder("Ticks"));
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   139
        gbc.gridx = 0;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   140
        gbc.gridy = 1;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   141
        mainControlPanel.add(slider, gbc);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   142
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   143
        passButton = new JButton("Pass");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   144
        passButton.setActionCommand("Pass");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   145
        passButton.addActionListener((ActionEvent e) -> {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   146
            testResult = true;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   147
            mainFrame.dispose();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   148
            latch.countDown();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   149
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   150
        });
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   151
        failButton = new JButton("Fail");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   152
        failButton.setActionCommand("Fail");
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   153
        failButton.addActionListener(new ActionListener() {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   154
            @Override
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   155
            public void actionPerformed(ActionEvent e) {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   156
                testResult = false;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   157
                mainFrame.dispose();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   158
                latch.countDown();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   159
            }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   160
        });
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   161
        gbc.gridx = 0;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   162
        gbc.gridy = 0;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   163
        resultButtonPanel.add(passButton, gbc);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   164
        gbc.gridx = 1;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   165
        gbc.gridy = 0;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   166
        resultButtonPanel.add(failButton, gbc);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   167
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   168
        gbc.gridx = 0;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   169
        gbc.gridy = 2;
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   170
        mainControlPanel.add(resultButtonPanel, gbc);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   171
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   172
        mainFrame.add(mainControlPanel);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   173
        mainFrame.pack();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   174
        mainFrame.setVisible(true);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   175
    }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   176
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   177
    public void disposeUI() {
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   178
        mainFrame.setVisible(false);
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   179
        mainFrame.dispose();
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   180
    }
d48361243925 8009477: PageUp and PageDown keyboard buttons don't move slider indicator to next minor tick
pkbalakr
parents:
diff changeset
   181
}