Example usage for javax.swing JProgressBar JProgressBar

List of usage examples for javax.swing JProgressBar JProgressBar

Introduction

In this page you can find the example usage for javax.swing JProgressBar JProgressBar.

Prototype

public JProgressBar(int min, int max) 

Source Link

Document

Creates a horizontal progress bar with the specified minimum and maximum.

Usage

From source file:ProgressBarDemo2.java

public ProgressBarDemo2() {
    super(new BorderLayout());

    // Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);

    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);/*  w  ww.  j  a v  a 2s .c  om*/

    // Call setStringPainted now so that the progress bar height
    // stays the same whether or not the string is shown.
    progressBar.setStringPainted(true);

    taskOutput = new JTextArea(5, 20);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);

    JPanel panel = new JPanel();
    panel.add(startButton);
    panel.add(progressBar);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:e3fraud.gui.MainWindow.java

public MainWindow() {
    super(new BorderLayout(5, 5));

    extended = false;//w w w.  j  av  a  2  s.  c  om

    //Create the log first, because the action listeners
    //need to refer to it.
    log = new JTextArea(10, 50);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    logScrollPane = new JScrollPane(log);
    DefaultCaret caret = (DefaultCaret) log.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    //        create the progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(progressBar.getMinimum());
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    //Create the settings pane
    generationSettingLabel = new JLabel("Generate:");
    SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1);
    collusionSettingsPanel = new JPanel(new FlowLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS));
    collusionsButton = new JSpinner(collusionsSpinnerModel);
    collusionsLabel = new JLabel("collusion(s)");
    collusionSettingsPanel.add(collusionsButton);
    collusionSettingsPanel.add(collusionsLabel);

    rankingSettingLabel = new JLabel("Rank by:");
    lossButton = new JRadioButton("loss");
    lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)");
    gainButton = new JRadioButton("gain");
    gainButton.setToolTipText(
            "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)");
    lossGainButton = new JRadioButton("loss + gain");
    lossGainButton.setToolTipText(
            "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment");
    //gainLossButton = new JRadioButton("gain + loss");
    lossGainButton.setSelected(true);
    rankingGroup = new ButtonGroup();
    rankingGroup.add(lossButton);
    rankingGroup.add(gainButton);
    rankingGroup.add(lossGainButton);
    //rankingGroup.add(gainLossButton);
    groupingSettingLabel = new JLabel("Group by:");
    groupingButton = new JCheckBox("collusion");
    groupingButton.setToolTipText(
            "Groups sub-ideal models based on the pair of actors colluding before ranking them");
    groupingButton.setSelected(false);
    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(this);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(generationSettingLabel);
    collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(collusionSettingsPanel);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT);
    settingsPanel.add(rankingSettingLabel);
    settingsPanel.add(lossButton);
    settingsPanel.add(gainButton);
    settingsPanel.add(lossGainButton);
    //settingsPanel.add(gainLossButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(groupingSettingLabel);
    settingsPanel.add(groupingButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(refreshButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 20)));
    progressBar.setPreferredSize(
            new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height));
    settingsPanel.add(progressBar);

    //Create the result tree
    root = new DefaultMutableTreeNode("No models to display");
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    //tree.setUI(new CustomTreeUI());
    tree.setCellRenderer(new CustomTreeCellRenderer(tree));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setLargeModel(true);
    resultScrollPane = new JScrollPane(tree);
    tree.addTreeSelectionListener(treeSelectionListener);

    //tree.setShowsRootHandles(true);
    //Create a file chooser for saving
    sfc = new JFileChooser();
    FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" });
    sfc.addChoosableFileFilter(jpegFilter);
    sfc.setFileFilter(jpegFilter);

    //Create a file chooser for loading
    fc = new JFileChooser();
    FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF");
    fc.addChoosableFileFilter(rdfFilter);
    fc.setFileFilter(rdfFilter);

    //Create the open button.  
    openButton = new JButton("Load model", createImageIcon("images/Open24.png"));
    openButton.addActionListener(this);
    openButton.setToolTipText("Load a e3value model");

    //Create the ideal graph button. 
    idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png"));
    idealGraphButton.setToolTipText("Display ideal profitability graph");
    idealGraphButton.addActionListener(this);

    Dimension thinButtonDimension = new Dimension(15, 420);

    //Create the expand subideal graph button. 
    expandButton = new JButton(">");
    expandButton.setPreferredSize(thinButtonDimension);
    expandButton.setMargin(new Insets(0, 0, 0, 0));
    expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model");
    expandButton.addActionListener(this);

    //Create the collapse sub-ideal graph button. 
    collapseButton = new JButton("<");
    collapseButton.setPreferredSize(thinButtonDimension);
    collapseButton.setMargin(new Insets(0, 0, 0, 0));
    collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model");
    collapseButton.addActionListener(this);

    //Create the generation button. 
    generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png"));
    generateButton.addActionListener(this);
    generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded");

    //Create the chart panel
    chartPane = new JPanel();
    chartPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    chartPane.add(expandButton);

    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(openButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    buttonPanel.add(generateButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPanel.add(idealGraphButton);

    //Add the buttons, the ranking options, the result list and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(settingsPanel, BorderLayout.LINE_START);
    add(resultScrollPane, BorderLayout.CENTER);

    add(logScrollPane, BorderLayout.PAGE_END);
    add(chartPane, BorderLayout.LINE_END);
    //and make a nice border around it
    setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
}

From source file:edu.ku.brc.af.ui.PasswordStrengthUI.java

/**
 * Constructor./*from  w  w w .j  a  v a 2s. com*/
 */
public PasswordStrengthUI(final int minPwdLen) {
    super(new BorderLayout());

    this.minPwdLen = minPwdLen;

    progress = new JProgressBar(0, 100);
    //add(progress, BorderLayout.CENTER);

    UIRegistry.loadAndPushResourceBundle("specify_plugins");
    scoreStrings = new String[SCORE_KEYS.length];
    for (int i = 0; i < SCORE_KEYS.length; i++) {
        scoreStrings[i] = UIRegistry.getResourceString(getKey(SCORE_KEYS[i]));
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder pbi = new PanelBuilder(
            new FormLayout(UIHelper.createDuplicateJGoodiesDef("p", "4px", cbxs.length), "p"));
    errorStrings = new String[ERR_KEYS.length];
    int x = 1;
    for (int i = 0; i < ERR_KEYS.length; i++) {
        errorStrings[i] = UIRegistry.getResourceString(getKey(ERR_KEYS[i]));
        cbxs[i] = UIHelper.createCheckBox(errorStrings[i]);
        pbi.add(cbxs[i], cc.xy(x, 1));
        cbxs[i].setEnabled(false);
        x += 2;
    }
    UIRegistry.popResourceBundle();

    colorPanel = new ColorPanel();
    colorPanel.setBorder(BorderFactory.createLoweredBevelBorder());

    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,p"), this);
    pb.add(colorPanel, cc.xy(1, 1));
    pb.add(pbi.getPanel(), cc.xy(1, 3));
}

From source file:com.dfki.av.sudplan.vis.VisualizationPanel.java

/**
 * Constructs a visualization panel of the defined
 * <code>Dimension</code>.//from   www . j a va2  s .  c  om
 *
 * @param canvasSize size of the
 * <code>WorldWindowGLCanvas</code>.
 */
public VisualizationPanel(Dimension canvasSize) {
    super(new BorderLayout());

    this.wwd = new WorldWindowGLCanvas();
    this.wwd.setPreferredSize(canvasSize);

    // Create the default model as described in the current worldwind properties.
    Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
    this.wwd.setModel(m);

    // Setup a select listener for the worldmap click-and-go feature
    this.wwd.addSelectListener(new ClickAndGoSelectListener(this.wwd, WorldMapLayer.class));

    ViewControlsLayer viewControlsLayer = new ViewControlsLayer();
    this.wwd.getModel().getLayers().add(viewControlsLayer);
    this.wwd.addSelectListener(new ViewControlsSelectListener(this.wwd, viewControlsLayer));
    this.add(this.wwd, BorderLayout.CENTER);

    this.progressBar = new JProgressBar(0, 100);
    this.progressBar.setVisible(false);

    this.statusBar = new StatusBar();
    this.statusBar.setEventSource(wwd);
    this.statusBar.add(progressBar);
    this.add(statusBar, BorderLayout.SOUTH);

    this.progressChange = new PropertyChangeSupport(this);

    this.layerPanel = new LayerPanel(this.wwd);
    this.wwd.getModel().addPropertyChangeListener(layerPanel);

    initCustomElevationModels();
}

From source file:org.mn.z80util.testbench.MZ80TestBench.java

private void createAndShowGUI() {

    // See above/*w  ww.j ava 2 s .c o  m*/
    if (!SwingUtilities.isEventDispatchThread()) {
        System.err.println("Attempting to construct the GUI from outside "
                + "of event dispatch thread! This is an error. Please check " + "your code modifications.");
        System.exit(1);
    }

    /* Initializes the GUI frame */
    GUI = new JFrame("Mikko's Z80 Testbench - (C) Mikko Nummelin, 2009");
    GUI.setLayout(new BorderLayout());
    GUI.setIconImage(LogoFactory.createLogo());
    GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    leftPanel = new JPanel();
    leftPanel.setLayout(new GridLayout(3, 1));

    // The first processor information
    firstProcessorPanel = new JPanel();
    firstProcessorPanel.setLayout(new GridLayout(2, 1));
    firstProcessorPanel.setBorder(BorderFactory.createTitledBorder("Processor 1"));
    firstProcessorPanel.add(new JLabel(processor1.getClass().getName()));
    firstProcessorStatus = new JLabel("-");
    firstProcessorPanel.add(firstProcessorStatus);
    leftPanel.add(firstProcessorPanel);

    // The second processor information
    secondProcessorPanel = new JPanel();
    secondProcessorPanel.setLayout(new GridLayout(2, 1));
    secondProcessorPanel.setBorder(BorderFactory.createTitledBorder("Processor 2"));
    secondProcessorPanel.add(new JLabel(processor2.getClass().getName()));
    secondProcessorStatus = new JLabel("-");
    secondProcessorPanel.add(secondProcessorStatus);
    leftPanel.add(secondProcessorPanel);

    // The progress bar panel
    progressBarPanel = new JPanel();
    progressBarPanel.setLayout(new GridLayout(3, 1));
    progressBarPanel.setBorder(BorderFactory.createTitledBorder("Progress"));
    progressBar = new JProgressBar(0, 0x6bf);
    progressBarPanel.add(progressBar);
    statusMessage = new JLabel("-");
    progressBarPanel.add(statusMessage);
    executedCommand = new JLabel("-");
    progressBarPanel.add(executedCommand);
    leftPanel.add(progressBarPanel);

    GUI.add(leftPanel, BorderLayout.WEST);

    // The action button panel
    actionPanel = new JPanel();
    okCancelButton = new JButton("Cancel");
    okCancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    actionPanel.add(okCancelButton);
    GUI.add(actionPanel, BorderLayout.SOUTH);

    // The image panel
    imagePanel = new JPanel();
    java.net.URL imgURL = getClass().getResource("/Z80-pinout.png");
    img = new ImageIcon(imgURL);
    imagePanel.add(new JLabel(img));
    GUI.add(imagePanel, BorderLayout.EAST);

    GUI.pack();
    GUI.setResizable(false);
    GUI.setVisible(true);
}

From source file:UI.MainViewPanel.java

public JProgressBar getPanel7(Metric7 m7) {

    JProgressBar openPortBar = new JProgressBar(0, 100);
    openPortBar.setValue(m7.totalCriticalCount);
    openPortBar.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    UIDefaults defaults = new UIDefaults();

    Painter foregroundPainter = new MyPainter(new Color(230, 219, 27));
    Painter backgroundPainter = new MyPainter(chartBackgroundColor);
    defaults.put("ProgressBar[Enabled].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled+Finished].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled].backgroundPainter", backgroundPainter);

    openPortBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
    openPortBar.putClientProperty("Nimbus.Overrides", defaults);

    openPortBar.setString("" + m7.totalCriticalCount);
    openPortBar.setStringPainted(true);/*from ww w  . ja  va 2  s  .  c  om*/

    return openPortBar;
}

From source file:customprogressindicator.CustomProgress.java

private JPanel createComponents() {
    JPanel top = new JPanel();
    top.setBackground(Color.WHITE);
    top.setLayout(new BorderLayout(20, 20));

    // get applet parameter using an instance of the AppletStub class
    // "tagLine" parameter specified in applet's JNLP file
    String tagLine = "";
    if (appletStub != null) {
        tagLine = appletStub.getParameter("tagLine");
    }// w  w w .j  a v a 2s .  c  o m
    String lblText = "<html><font color=red size=+2>JDK Documentation</font><br/>" + tagLine + " <br/></html>";
    JLabel lbl = new JLabel(lblText);
    top.add(lbl, BorderLayout.NORTH);

    // use JSObject.getWindow(null) method to retrieve a reference to
    // the web page and make JavaScript calls. Duke logo displayed if
    // displayLogo variable set to "true" in the web page
    String displayLogo = "false";
    JSObject window = JSObject.getWindow(null);
    if (window != null) {
        displayLogo = (String) window.getMember("displayLogo");
    }
    if (displayLogo.equals("true")) {
        lbl = new JLabel();
        ImageIcon logo = createImageIcon("images/DukeWave.gif", "logo");
        lbl.setIcon(logo);
        top.add(lbl, BorderLayout.EAST);
    }

    statusLabel = new JLabel("<html><font color=green size=-2>Loading applet...</font></html>");
    top.add(statusLabel, BorderLayout.CENTER);

    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
    top.add(progressBar, BorderLayout.SOUTH);

    return top;
}

From source file:jchrest.gui.VisualSearchPane.java

private JPanel runTrainingButtons() {
    JPanel panel = new JPanel();

    _trainingTimes = new XYSeries("CHREST model");
    _trainAction = new TrainAction();
    JButton trainButton = new JButton(_trainAction);
    trainButton.setToolTipText("Train a fresh CHREST model up to the given network size");
    _stopAction = new StopAction();
    _stopAction.setEnabled(false);//from   w  w  w  . j  a  va  2s.  co  m
    JButton stopButton = new JButton(_stopAction);
    stopButton.setToolTipText("Stop the current training");
    _feedback = new JProgressBar(0, 100);
    _feedback.setToolTipText("Proportion of target network size");
    _feedback.setValue(0);
    _feedback.setStringPainted(true);
    panel.add(trainButton);
    panel.add(stopButton);
    panel.add(_feedback);

    return panel;
}

From source file:edu.ku.brc.specify.tasks.StatsTrackerTask.java

@Override
protected void showClosingFrame() {
    if (hasChanged) {
        ImageIcon img = IconManager.getIcon("SpecifySplash");

        CellConstraints cc = new CellConstraints();
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,150px", "f:p:g,2px,p"));
        pb.setDefaultDialogBorder();//from  w  w  w  .j a v a 2s  . c o m

        JLabel lbl = new JLabel(img);
        pb.add(lbl, cc.xyw(1, 1, 2));
        lbl = UIHelper.createI18NLabel("SPECIFY_SHUTDOWN", SwingConstants.CENTER);
        lbl.setFont(lbl.getFont().deriveFont(18.0f));
        pb.add(lbl, cc.xy(1, 3));

        progress = new JProgressBar(0, 100);
        pb.add(progress, cc.xy(2, 3));

        JFrame frame = new JFrame();
        frame.setUndecorated(true);
        frame.setContentPane(pb.getPanel());
        frame.pack();
        UIHelper.centerAndShow(frame);
    }
}

From source file:uk.co.petertribble.jangle.SnmpTreePanel.java

/**
 * Start exploring the snmp tree.//from  w  w w.  j  a v a 2s  .  c  o m
 *
 * @param params details of the snmp server to query
 */
public void exploreServer(SnmpParams params) {
    sc = new SnmpController(params);
    snl = new SnmpList(sc);
    jpb = new JProgressBar(0, 1);
    jpb.setValue(0);
    jpb.setIndeterminate(true);
    jp2.add(jpb, BorderLayout.SOUTH);
    jp2.validate();
    // load data in background
    (new ExploreWorker()).execute();
}