Example usage for javax.swing JProgressBar setValue

List of usage examples for javax.swing JProgressBar setValue

Introduction

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

Prototype

@BeanProperty(bound = false, preferred = true, description = "The progress bar's current value.")
public void setValue(int n) 

Source Link

Document

Sets the progress bar's current value to n .

Usage

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JProgressBar Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JProgressBar progressBar = new JProgressBar();
    progressBar.setValue(25);
    progressBar.setStringPainted(true);/*from   w w  w. j av  a 2 s.  co m*/
    Border border = BorderFactory.createTitledBorder("Reading...");
    progressBar.setBorder(border);
    f.add(progressBar, BorderLayout.NORTH);
    f.setSize(300, 100);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("ProgressBars");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JProgressBar dJProgressBar = new JProgressBar();
    dJProgressBar.setValue(100);
    dJProgressBar.setBorderPainted(false);
    dJProgressBar.setString("Ack");
    dJProgressBar.setStringPainted(true);

    frame.add(dJProgressBar, BorderLayout.WEST);
    frame.setSize(300, 200);/*from   ww w. j a v  a  2 s. co  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Create a horizontal progress bar
    int min = 0;/*from ww w.  jav  a 2 s . co m*/
    int max = 100;
    JProgressBar progress = new JProgressBar(min, max);
    int value = 33;

    progress.setValue(value);
    progress.setIndeterminate(false);

}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("ProgressBars");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JProgressBar dJProgressBar = new JProgressBar(JProgressBar.VERTICAL);
    dJProgressBar.setValue(100);
    dJProgressBar.setBorderPainted(false);
    dJProgressBar.setString("Ack");
    dJProgressBar.setStringPainted(true);

    frame.add(dJProgressBar, BorderLayout.WEST);
    frame.setSize(300, 200);//from w w  w.  j a  v a2s.  c om
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();

    JButton button = new JButton();

    Main f = null;/* w  w  w  .j  av  a  2 s  . co m*/
    f = new Main();

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(700, 400);

    panel1.setLayout(new BorderLayout());
    panel1.setForeground(Color.white);
    button.setText("Convert");
    panel1.add(button, BorderLayout.SOUTH);

    f.setContentPane(panel1);
    f.setVisible(true);

    f1 = new Main();

    f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f1.setSize(457, 100);
    f1.setTitle("Conversion Progress");
    f1.setLocationRelativeTo(null);

    panel2.setLayout(new BorderLayout());
    panel2.setForeground(Color.white);

    JProgressBar progressBar = new JProgressBar();
    progressBar.setValue(35);
    progressBar.setStringPainted(true);

    panel2.add(progressBar, BorderLayout.SOUTH);

    f1.setContentPane(panel2);

    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            f1.setVisible(true);
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    progress.setOrientation(SwingConstants.HORIZONTAL);
    int newValue = 33;
    progress.setValue(newValue);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    progress.setOrientation(SwingConstants.HORIZONTAL);
    int newValue = 33;
    progress.setValue(newValue);
    progress.setString("value");
    System.out.println(progress.getString());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    progress.setOrientation(SwingConstants.HORIZONTAL);
    int newValue = 33;
    progress.setValue(newValue);

    System.out.println(progress.isStringPainted());
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JProgressBar bar = new JProgressBar(JProgressBar.VERTICAL);
    bar.setEnabled(true);/*from  w w  w .ja  va 2 s.  com*/

    bar.setBackground(Color.YELLOW);
    bar.setForeground(Color.GREEN);

    bar.setStringPainted(true);
    bar.setString("2000 g");
    bar.setValue(65);
    frame.setLayout(new BorderLayout());
    frame.add(bar, BorderLayout.CENTER);
    frame.setSize(500, 400);
    frame.setVisible(true);
}

From source file:BoundedChangeListener.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("Stepping Progress");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL);
    aJProgressBar.setStringPainted(true);

    aJProgressBar.addChangeListener(new BoundedChangeListener());

    for (int i = 0; i < 10; i++) {
        aJProgressBar.setValue(i++);
        Thread.sleep(100);//from   w  w w . ja va2  s.  com
    }

    frame.add(aJProgressBar, BorderLayout.NORTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}