Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ProgressBarPanel.java
41161 views
/*1* Copyright (c) 2000, 2002, 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*22*/2324package sun.jvm.hotspot.ui;2526import java.awt.*;27import javax.swing.*;2829/** A panel containing a progress bar and a label */3031public class ProgressBarPanel extends JPanel {32private JLabel text;33private JProgressBar bar;34private static final int MAX = 10000;3536public static final int VERTICAL = 0;37public static final int HORIZONTAL = 1;3839public ProgressBarPanel() {40this(VERTICAL);41}4243/** LayoutType is either VERTICAL or HORIZONTAL */44public ProgressBarPanel(int layoutType) {45super();46if (layoutType == VERTICAL) {47setLayout(new BorderLayout());48text = new JLabel();49add(text, BorderLayout.NORTH);50bar = new JProgressBar(JProgressBar.HORIZONTAL, 0, MAX);51JPanel panel = new JPanel();52panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));53panel.add(bar);54add(panel, BorderLayout.CENTER);55} else {56setLayout(new BoxLayout(this, BoxLayout.X_AXIS));57text = new JLabel();58add(text);59bar = new JProgressBar(JProgressBar.HORIZONTAL, 0, MAX);60add(bar);61}62}6364public ProgressBarPanel(String text) {65this();66setText(text);67}6869public ProgressBarPanel(int layoutType, String text) {70this(layoutType);71setText(text);72}7374public void setText(String text) {75this.text.setText(text);76}7778public void setValue(double val) {79int realVal = (int) (val * MAX);80bar.setValue(realVal);81}8283public void setIndeterminate(boolean value) {84bar.setIndeterminate(value);85}86}878889