Path: blob/master/test/jdk/javax/swing/JScrollBar/8039464/Test8039464.java
41153 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.awt.Container;24import java.awt.Dimension;25import java.awt.GridBagConstraints;26import java.awt.GridBagLayout;2728import javax.swing.JApplet;29import javax.swing.JFrame;30import javax.swing.JLabel;31import javax.swing.JScrollBar;32import javax.swing.SwingUtilities;33import javax.swing.UIManager;3435/*36* @test37* @bug 803946438* @summary Tests enabling/disabling of titled border's caption39* @author Sergey Malenkov40* @run applet/manual=yesno Test8039464.html41*/4243public class Test8039464 extends JApplet {44static {45try {46UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());47} catch (Exception exception) {48throw new Error("unexpected", exception);49}50}5152@Override53public void init() {54init(this);55}5657private static void init(Container container) {58container.setLayout(new GridBagLayout());59GridBagConstraints gbc = new GridBagConstraints();60gbc.fill = GridBagConstraints.BOTH;61gbc.gridx = 0;62gbc.gridy = 1;63JLabel label = new JLabel();64Dimension size = new Dimension(111, 0);65label.setPreferredSize(size);66label.setMinimumSize(size);67container.add(label, gbc);68gbc.gridx = 1;69gbc.weightx = 1;70container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);71gbc.gridx = 2;72gbc.gridy = 0;73gbc.weightx = 0;74gbc.weighty = 1;75container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);76}7778public static void main(String[] args) throws Exception {79SwingUtilities.invokeLater(new Runnable() {80@Override81public void run() {82JFrame frame = new JFrame("8039464");83init(frame);84frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);85frame.pack();86frame.setLocationRelativeTo(null);87frame.setVisible(true);88}89});90}91}929394