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

The following examples show how to use javax.swing.JProgressBar#setMaximum() . 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: 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 2
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 3
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 4
Source File: PreviewComponent.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
public PreviewComponent() {
  super(new MigLayout());
  titleLabel = new JLabel(Messages.getMessage("preview.label"));
  nameLabel = new JLabel();
  contentArea = new JTextArea();
  contentArea.setEditable(false);
  border = BorderFactory.createTitledBorder(Messages.getMessage("preview.fileContent"));
  contentArea.setBorder(border);
  contentArea.setAutoscrolls(false);
  contentArea.setFont(new Font("Courier New", Font.PLAIN, contentArea.getFont().getSize()));

  contentScrollPane = new JScrollPane(contentArea);
  contentScrollPane.setAutoscrolls(false);

  progressBar = new JProgressBar();
  progressBar.setStringPainted(true);
  progressBar.setMaximum(1);
  enabledCheckBox = new JCheckBox(Messages.getMessage("preview.enable"), true);
  enabledCheckBox.setMnemonic(Messages.getMessage("preview.enable.mnemonic").charAt(0));
  enabledCheckBox.setRolloverEnabled(true);
  enabledCheckBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
      boolean enabled = enabledCheckBox.isSelected();
      progressBar.setEnabled(enabled);
      contentScrollPane.setEnabled(enabled);
      contentArea.setEnabled(enabled);
      nameLabel.setEnabled(enabled);
      titleLabel.setEnabled(enabled);
    }
  });

  add(titleLabel, "dock north, gap 5 5 5 5, center");
  add(nameLabel, "dock north, gap 5 5 5 5");
  add(contentScrollPane, "dock center, gap 5 5 5 5");
  add(enabledCheckBox, "dock south, gap 0 5 5 5");
  add(progressBar, "dock south, gap 5 5 5 5");
}
 
Example 5
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 6
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 7
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) {
                }
            }
        }
    }
 
Example 8
Source File: DeckDetailsPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public DeckDetailsPanel() {
	GridBagLayout gridBagLayout = new GridBagLayout();
	gridBagLayout.columnWidths = new int[] { 0, 140, 0, 0, 0 };
	gridBagLayout.rowHeights = new int[] { 28, 30, 35, 0, 132, 31, 0, 0, 0, 0 };
	gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 1.0E-4 };
	gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0E-4 };
	setLayout(gridBagLayout);

	add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("DECK_NAME") + " :"), UITools.createGridBagConstraints(null, null, 1, 0));
	nameJTextField = new JTextField();
	add(nameJTextField, UITools.createGridBagConstraints(null, GridBagConstraints.HORIZONTAL, 2, 0));

	add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("CARD_LEGALITIES") + " :"), UITools.createGridBagConstraints(null, null, 1, 1));
	panelLegalities = new JPanel();
	FlowLayout flowLayout = (FlowLayout) panelLegalities.getLayout();
	flowLayout.setHgap(10);
	flowLayout.setAlignment(FlowLayout.LEFT);
	add(panelLegalities, UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 1));

	add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("CARD_COLOR") + " :"), UITools.createGridBagConstraints(null, null, 1, 2));
	manaPanel = new ManaPanel();
	add(manaPanel, UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 2));

	lblDate = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("DATE") + " :");
	add(lblDate, UITools.createGridBagConstraints(null, null, 1, 3));

	lblDateInformation = new JLabel("");
	add(lblDateInformation, UITools.createGridBagConstraints(GridBagConstraints.WEST, null, 2, 3));

	add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("DESCRIPTION") + " :"), UITools.createGridBagConstraints(null, null, 1, 4));

	textArea = new JTextArea();
	textArea.setLineWrap(true);
	textArea.setWrapStyleWord(true);

	add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("QTY") + " :"), UITools.createGridBagConstraints(null, null, 1, 5));
	nbCardsProgress = new JProgressBar();
	nbCardsProgress.setStringPainted(true);
	add(nbCardsProgress, UITools.createGridBagConstraints(null, GridBagConstraints.HORIZONTAL, 2, 5));

	lbstd = new JLabel(" STD ");
	lbstd.setOpaque(true);
	lbstd.setBackground(Color.GREEN);
	lbmnd = new JLabel(" MDN ");
	lbmnd.setOpaque(true);
	lbmnd.setBackground(Color.GREEN);
	lbvin = new JLabel(" VIN ");
	lbvin.setOpaque(true);
	lbvin.setBackground(Color.GREEN);
	lbcmd = new JLabel(" CMD ");
	lbcmd.setOpaque(true);
	lbcmd.setBackground(Color.GREEN);
	lbLeg = new JLabel(" LEG ");
	lbLeg.setOpaque(true);
	lbLeg.setBackground(Color.GREEN);

	panelLegalities.add(lbvin);
	panelLegalities.add(lbLeg);
	panelLegalities.add(lbstd);
	panelLegalities.add(lbmnd);
	panelLegalities.add(lbcmd);

	add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("SIDEBOARD") + " :"), UITools.createGridBagConstraints(null, null, 1, 6));

	nbSideProgress = new JProgressBar();
	nbSideProgress.setMaximum(15);
	nbSideProgress.setStringPainted(true);
	add(nbSideProgress, UITools.createGridBagConstraints(null, GridBagConstraints.HORIZONTAL, 2, 6));

	add(new JScrollPane(textArea), UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 4));

	add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("TAGS") + " :"), UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 1, 7));

	tagsPanel = new JTagsPanel();
	add(tagsPanel, UITools.createGridBagConstraints(GridBagConstraints.WEST, GridBagConstraints.VERTICAL, 2, 7));

	panel = new JPanel();
	add(panel, UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 8));

	if (magicDeck != null) {
		mBindingGroup = initDataBindings();
	}
}
 
Example 9
Source File: DownloadDialog.java    From LoboBrowser with MIT License 4 votes vote down vote up
private void updateProgress(final ProgressType progressType, final int value, final int max) {
  final String sizeText = getSizeText(value);
  this.transferSizeField.setValue(sizeText);

  final long newTimestamp = System.currentTimeMillis();
  final double lastTransferRate = this.lastTransferRate;
  final long lastProgressValue = this.lastProgressValue;
  final long lastTimestamp = this.lastTimestamp;
  final long elapsed = newTimestamp - lastTimestamp;
  double newTransferRate = Double.NaN;
  if (elapsed > 0) {
    newTransferRate = (value - lastProgressValue) / elapsed;
    if (!Double.isNaN(lastTransferRate)) {
      // Weighed average
      newTransferRate = (newTransferRate + (lastTransferRate * 5.0)) / 6.0;
    }
  }
  if (!Double.isNaN(newTransferRate)) {
    this.transferRateField.setValue(round1(newTransferRate) + " Kb/sec");
    final int cl = this.knownContentLength;
    if ((cl > 0) && (newTransferRate > 0)) {
      this.timeLeftField.setValue(Timing.getElapsedText((long) ((cl - value) / newTransferRate)));
    }
  }
  this.lastTimestamp = newTimestamp;
  this.lastProgressValue = value;
  this.lastTransferRate = newTransferRate;

  final JProgressBar pb = this.progressBar;
  if (progressType == ProgressType.CONNECTING) {
    pb.setIndeterminate(true);
    pb.setStringPainted(true);
    pb.setString("Connecting...");
    this.setTitle(this.destinationField.getValue() + ": Connecting...");
  } else if (max <= 0) {
    pb.setIndeterminate(true);
    pb.setStringPainted(false);
    this.setTitle(sizeText + " " + this.destinationField.getValue());
  } else {
    final int percent = (value * 100) / max;
    pb.setIndeterminate(false);
    pb.setStringPainted(true);
    pb.setMaximum(max);
    pb.setValue(value);
    final String percentText = percent + "%";
    pb.setString(percentText);
    this.setTitle(percentText + " " + this.destinationField.getValue());
  }
}
 
Example 10
Source File: TransferProgressRenderer.java    From swift-k with Apache License 2.0 4 votes vote down vote up
public TransferProgressRenderer() {
	pbar = new JProgressBar();
	pbar.setMaximum(100);
	pbar.setStringPainted(true);
}
 
Example 11
Source File: SplashScreen.java    From importer-exporter with Apache License 2.0 4 votes vote down vote up
private void init(int numberOfSteps, int messageX, int messageY, Color messageColor) {
	JPanel content = new JPanel() {
		public boolean isOptimizedDrawingEnabled() {
			return false;
		}
	};
	
	content.setLayout(new OverlayLayout(content));
	content.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
	
	JPanel dynamicContent = new JPanel();
	dynamicContent.setOpaque(false);
	dynamicContent.setLayout(new GridBagLayout());
		
	message = new JLabel();
	message.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
	message.setForeground(messageColor);
	
	progressBar = new JProgressBar();
	progressBar.setPreferredSize(new Dimension(icon.getIconWidth(), 18));
	progressBar.setIndeterminate(false);
	progressBar.setMaximum(numberOfSteps);
	progressBar.setVisible(false);
	
	GridBagConstraints c = GuiUtil.setConstraints(0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 5 + messageY, 5 + messageX, 0, 5);
	c.anchor = GridBagConstraints.NORTH;
	dynamicContent.add(message, c);
	
	c = GuiUtil.setConstraints(0, 1, 1, 1, GridBagConstraints.HORIZONTAL, 5, 5, 5, 5);
	c.anchor = GridBagConstraints.SOUTH;
	dynamicContent.add(progressBar, c);
	
	dynamicContent.setAlignmentX(0f);
	dynamicContent.setAlignmentY(0f);
	content.add(dynamicContent);
	
	JLabel image = new JLabel(icon);
	image.setAlignmentX(0f);
	image.setAlignmentY(0f);
	content.add(image);
	
	add(content, BorderLayout.CENTER);
	
	// center on screen
	Toolkit t = Toolkit.getDefaultToolkit();
	Insets frame_insets = t.getScreenInsets(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration());
	int frame_insets_x = frame_insets.left + frame_insets.right;
	int frame_insets_y = frame_insets.bottom + frame_insets.top;
	
	Dimension dim = t.getScreenSize();
	int x = (dim.width - icon.getIconWidth() - frame_insets_x) / 2;
	int y = (dim.height - icon.getIconHeight() - frame_insets_y) / 2;		
	setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
	setLocation(x, y);
	setAlwaysOnTop(true);
}