Java Code Examples for javax.swing.JProgressBar#setMinimum()

The following examples show how to use javax.swing.JProgressBar#setMinimum() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskList.java    From swift-k with Apache License 2.0 6 votes vote down vote up
public TaskList() {
	super("Task List");
	getContentPane().setLayout(new BorderLayout());
	mem = new JProgressBar();
	mem.setStringPainted(true);
	queue = new JProgressBar();
	queue.setStringPainted(true);
	mem.setMinimum(0);
	queue.setMinimum(0);
	JPanel p = new JPanel(new GridLayout(3,1));
	JPanel q = new JPanel(new FlowLayout());
	p.add(q);
	kill = new JButton("Kill task");
	q.add(kill);
	kill.addActionListener(this);
	p.add(mem);
	p.add(queue);
	getContentPane().add(p, BorderLayout.SOUTH);
}
 
Example 2
Source File: StatusMonitor.java    From DeconvolutionLab2 with GNU General Public License v3.0 5 votes vote down vote up
public StatusMonitor(JProgressBar progress) {
	super();
	this.progress = progress;
	progress.setMinimum(0);
	progress.setMaximum(100);
	progress.setStringPainted(true);
}
 
Example 3
Source File: JBuzyProgress.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public JBuzyProgress() {
	super();
	progress = new JProgressBar();
	progress.setMinimum(0);
	progress.setStringPainted(true);
	add(progress,BorderLayout.CENTER);
	
}
 
Example 4
Source File: MTGSplashScreen.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public MTGSplashScreen() {
	JPanel panel = new JPanel() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		protected void paintComponent(Graphics g) {
			if (g instanceof Graphics2D) {
				final int R = 240;
				final int G = 240;
				final int B = 240;
				Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0), 0.0f, getHeight(),
						new Color(R, G, B, 0), true);
				Graphics2D g2d = (Graphics2D) g;
				g2d.setPaint(p);
				g2d.fillRect(0, 0, getWidth(), getHeight());
			}
		}
	};
	setBackground(new Color(0, 0, 0, 0));

	getContentPane().add(panel);
	panel.setLayout(new BorderLayout(0, 0));

	JLabel lblIcons = new JLabel(MTGConstants.ICON_SPLASHSCREEN);
	panel.add(lblIcons, BorderLayout.CENTER);
	lblIcons.setOpaque(false);

	progressBar = new JProgressBar();
	panel.add(progressBar, BorderLayout.SOUTH);
	progressBar.setMinimum(0);
	progressBar.setIndeterminate(true);
	progressBar.setStringPainted(true);
	progressBar.setForeground(new Color(101,13,136));
	pack();
	setLocationRelativeTo(null);
}
 
Example 5
Source File: JVMemoryPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public JVMemoryPanel() {
	setLayout(new BorderLayout(0, 0));
	progressBar = new JProgressBar();
	progressBar.setMinimum(0);
	progressBar.setMaximum(toMB(Runtime.getRuntime().totalMemory()));
	progressBar.setStringPainted(true);
	progressBar.setToolTipText(tooltip);
	add(progressBar);
	defaultBack = progressBar.getBackground();
	defaultFront = progressBar.getForeground();
	refresh();
}
 
Example 6
Source File: GuiMain.java    From google-sites-liberation with Apache License 2.0 5 votes vote down vote up
private void initProgressFrame() {
  progressFrame = new JFrame("Progress");
  JPanel mainPanel = new JPanel();
  mainPanel.setLayout(new BorderLayout());
  progressBar = new JProgressBar();
  progressBar.setMinimum(0);
  progressBar.setMaximum(100);
  progressBar.setPreferredSize(new Dimension(500, 25));
  JPanel progressPanel = new JPanel();
  progressPanel.add(progressBar);
  progressPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
  mainPanel.add(progressPanel, BorderLayout.NORTH);
  textArea = new JTextArea();
  textArea.setRows(20);
  textArea.setEditable(false);
  JScrollPane scrollPane = new JScrollPane(textArea);
  scrollPane.setBorder(new EmptyBorder(10, 10, 10, 10));
  mainPanel.add(scrollPane, BorderLayout.CENTER);
  doneButton = new JButton("Done");
  doneButton.setPreferredSize(new Dimension(495, 25));
  doneButton.setEnabled(false);
  doneButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      doneButton.setEnabled(false);
      progressFrame.setVisible(false);
      optionsFrame.setVisible(true);
    }
  });
  JPanel donePanel = new JPanel();
  donePanel.setLayout(new BorderLayout());
  donePanel.add(doneButton, BorderLayout.CENTER);
  donePanel.setBorder(new EmptyBorder(0, 10, 10, 10));
  mainPanel.add(donePanel, BorderLayout.SOUTH);
  progressFrame.getContentPane().add(mainPanel);
  progressFrame.pack();
  progressFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example 7
Source File: SecondaryPanel.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
protected void makeBottomPanel() {
	// setup the elements
	progress=new JProgressBar();
	progress.setMaximum(100);
	progress.setMinimum(0);
	
	rewind=new JButton("Rewind");
	rewind.addActionListener(this);
	
	playStop=new JButton("Play");
	playStop.addActionListener(this);
	
	// create the panel
	bottom = new JPanel();
	bottom.setLayout(new GridBagLayout());
	
	// connect them all together
	GridBagConstraints c = new GridBagConstraints();
	c.gridx=0;
	c.gridy=0;
	c.weightx=1.0;
	c.weighty=1.0;
	c.fill=GridBagConstraints.HORIZONTAL;
	
	c.weightx=0.05;		c.gridwidth=1;		bottom.add(rewind,c);	c.gridx+=1;
	c.weightx=0.05;		c.gridwidth=1;		bottom.add(playStop,c);		c.gridx+=1;
	
	c.weightx=1.0 - (c.gridx/10);
	c.gridwidth=10 - c.gridx;
	c.ipady=5;
	c.insets = new Insets(0,3,3,0);
	bottom.add(progress,c);
}
 
Example 8
Source File: UpdateIDE.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ProgressBar() {
     frame = new JFrame("APICloud Studio\u66F4\u65B0\u7BA1\u7406\u5668");
     frame.setBounds(100, 100, 400, 130);
     frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
     frame.setResizable(false);
     Image image= null;
try {
  	InputStream is=UpdateIDE.class.getResourceAsStream("32_32.png");    
	image = ImageIO.read(is);
} catch (IOException e) {
	e.printStackTrace();
}
if(image != null) {
	frame.setIconImage(image);
}

     Container contentPanel = frame.getContentPane();
     JLabel label_txt = new JLabel("\u7A0B\u5E8F\u66F4\u65B0\u4E2D\uFF0C\u8BF7\u4E0D\u8981\u624B\u52A8\u542F\u52A8APICloud Studio\u4EE5\u514D\u66F4\u65B0\u5931\u8D25\uFF01", JLabel.CENTER);
    
     label_txt.setForeground(Color.red);
     label = new JLabel("", JLabel.CENTER);
     progressbar = new JProgressBar();
     progressbar.setOrientation(JProgressBar.HORIZONTAL);
     progressbar.setMinimum(0);
     progressbar.setMaximum(100);
     progressbar.setValue(0);
     progressbar.setStringPainted(true);
     progressbar.addChangeListener(this);
     progressbar.setPreferredSize(new Dimension(300, 20));
     progressbar.setBorderPainted(true);
     progressbar.setBackground(Color.green);

     timer = new Timer(700, this);
     contentPanel.add(label_txt, BorderLayout.NORTH);
     contentPanel.add(label, BorderLayout.CENTER);
     contentPanel.add(progressbar, BorderLayout.SOUTH);
     frame.setVisible(true);
     timer.start();
  }
 
Example 9
Source File: SplashWindow.java    From Rails with GNU General Public License v2.0 4 votes vote down vote up
public SplashWindow(boolean isLoad, String initDetailsText) {
    //quit directly when no visualization required
    //all visualization related attributes remain null then
    if ("no".equals(Config.get("splash.window.open"))) return;

    //calculate estimated duration for the respective steps
    cumulativeDuration = new long[STEP_DURATION.length];
    boolean isDockingLayout = "yes".equals(Config.get("or.window.dockablePanels"));
    for ( int i = 0; i < STEP_DURATION.length ; i++) {
        //only consider step if relevant for this setup
        if ( (isLoad || !STEP_GROUP_LOAD.contains(STEP_DURATION[i].labelConfigKey))
                &&
             (isDockingLayout || !STEP_GROUP_DOCKING_LAYOUT.contains(STEP_DURATION[i].labelConfigKey)) ) {
            totalDuration += STEP_DURATION[i].expectedDurationInMillis;
        }
        cumulativeDuration[i] = totalDuration;
    }

    //set up dynamic elements

    myWin = new JWindow();

    leftIcon = new JLabel();
    setIcon(leftIcon, ICONS[currentIconIndex][0]);
    leftIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder()));
    rightIcon = new JLabel();
    setIcon(rightIcon, ICONS[currentIconIndex][1]);
    rightIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder()));

    progressBar = new JProgressBar(0,(int)totalDuration);
    progressBar.setStringPainted(true);
    progressBar.setMinimum(0);

    stepLabel = new JLabel(" "); // needed in order to allocate vertical space
    stepLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
    stepLabel.setBorder(new EmptyBorder(5,5,5,5));

    //set up static elements

    JLabel railsLabel = new JLabel("Rails " +Config.getVersion());
    railsLabel.setFont(railsLabel.getFont().deriveFont(
            (float)2.0 * railsLabel.getFont().getSize()));
    railsLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

    String commandTextKey = isLoad ? "Splash.command.loadGame" : "Splash.command.newGame";
    JLabel commandLabel = new JLabel(
            LocalText.getText(commandTextKey,initDetailsText));
    commandLabel.setFont(commandLabel.getFont().deriveFont(Font.BOLD));
    commandLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

    //plug elements together and set up layout

    JPanel railsCommandPanel = new JPanel();
    railsCommandPanel.setLayout(new BoxLayout(railsCommandPanel, BoxLayout.Y_AXIS));
    railsCommandPanel.add(railsLabel);
    railsCommandPanel.add(commandLabel);
    railsCommandPanel.setBorder(new EmptyBorder(3,3,3,3));

    JPanel idPanel = new JPanel();
    idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS));
    idPanel.add(leftIcon);
    idPanel.add(railsCommandPanel);
    idPanel.add(rightIcon);
    idPanel.setBorder(new EmptyBorder(3,3,3,3));

    JComponent contentPane = (JComponent)myWin.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.add(idPanel);
    contentPane.add(progressBar);
    contentPane.add(stepLabel);
    contentPane.setBorder(new CompoundBorder(new EtchedBorder(),new EmptyBorder(5,5,5,5)));

    //perform layout within the EDT
    //blocking call as further initialization requires the layout to be frozen
    try {
        SwingUtilities.invokeAndWait(new Thread() {
            @Override
            public void run() {
                myWin.pack();
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                myWin.setLocation(
                      (dim.width - myWin.getSize().width) / 2,
                      (dim.height - myWin.getSize().height) / 2
                );
                myWin.setVisible(true);
            }
        });
    } catch (Exception e) {}

    progressVisualizer = new ProgressVisualizer();
    notifyOfStep(DUMMY_STEP_START);
    progressVisualizer.start();
}
 
Example 10
Source File: MavenDownloader.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
public static void downloadFully(URL url, File target, JProgressBar progressBar) throws IOException {

        // We don't use the settings here explicitly, since HttpRequests picks up the network settings from studio directly.
        try {
            URLConnection connection = url.openConnection();
            if (connection instanceof HttpsURLConnection) {
                ((HttpsURLConnection) connection).setInstanceFollowRedirects(true);
                ((HttpsURLConnection) connection).setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.3.1)");
                ((HttpsURLConnection) connection).setRequestProperty("Accept-Charset", "UTF-8");
                ((HttpsURLConnection) connection).setDoOutput(true);
                ((HttpsURLConnection) connection).setDoInput(true);
            }
            connection.setConnectTimeout(3000);
            connection.connect();
            int contentLength = connection.getContentLength();
            if (contentLength < 1) {
                throw new FileNotFoundException();
            }
            if (progressBar != null) {
                progressBar.setMinimum(0);
                progressBar.setMaximum(contentLength);
            }
            OutputStream dest = new FileOutputStream(target);
            InputStream in = connection.getInputStream();
            int count;
            int done = 0;
            byte data[] = new byte[BUFFER_SIZE];
            while ((count = in.read(data, 0, BUFFER_SIZE)) != -1) {
                done += count;
                if (progressBar != null) {
                    progressBar.setValue(done);
                }
                dest.write(data, 0, count);
            }
            dest.close();
            in.close();
        } finally {
            if (target.length() == 0) {
                try {
                    target.delete();
                } catch (Exception e) {
                }
            }
        }
    }