當前位置: 首頁>>代碼示例>>Java>>正文


Java JProgressBar.repaint方法代碼示例

本文整理匯總了Java中javax.swing.JProgressBar.repaint方法的典型用法代碼示例。如果您正苦於以下問題:Java JProgressBar.repaint方法的具體用法?Java JProgressBar.repaint怎麽用?Java JProgressBar.repaint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JProgressBar的用法示例。


在下文中一共展示了JProgressBar.repaint方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: saveSEGY

import javax.swing.JProgressBar; //導入方法依賴的package包/類
private void saveSEGY(OutputStream out) throws IOException {
	if(image==null) throw new IOException("no image loaded");

	String mcsPath = PathUtil.getPath("PORTALS/MULTI_CHANNEL_PATH",
			MapApp.BASE_URL+"/data/portals/mcs/");

	URL url = URLFactory.url( mcsPath + line.getCruiseID().trim() + "/segy/" +
			line.getCruiseID().trim() +"-"+ 
			line.getID().trim() + ".segy" );
	URLConnection urlCon = url.openConnection();
	BufferedInputStream in = new BufferedInputStream(urlCon.getInputStream());
	int length = urlCon.getContentLength();

	// Create a JProgressBar + JDialog
	JDialog d = new JDialog((Frame)null, "Saving SEGY");
	JPanel p = new JPanel(new BorderLayout());
	p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
	d.setLocationRelativeTo(null);
	JProgressBar pb = new JProgressBar(0,length);
	p.add(new JLabel("Saving " + (length / 1000000) + "mb segy file"), BorderLayout.NORTH);
	p.add(pb);
	d.getContentPane().add(p);

	d.pack();
	d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	d.setVisible(true);

	byte[] b = new byte[16384];
	int read = in.read(b);
	while (read != -1) {
		out.write(b, 0, read);
		pb.setValue(pb.getValue() + read);
		pb.repaint();
		read = in.read(b);
	}

	out.flush();
	in.close();
	d.dispose();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:41,代碼來源:XMImage.java

示例2: loadFile

import javax.swing.JProgressBar; //導入方法依賴的package包/類
public void loadFile(File f){
		try {
			int length = (int)f.length();
			JDialog d = new JDialog((Frame)null, "Loading File");
			JPanel p = new JPanel(new BorderLayout());
			p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
			d.setLocationRelativeTo(null);
			JProgressBar pb = new JProgressBar(0,length);
			p.add(new JLabel("Loading " + (length / 1000) + " kb file"), BorderLayout.NORTH);
			p.add(pb);
			d.getContentPane().add(p);
			d.pack();
			d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			d.setVisible(true);
			d.setAlwaysOnTop(true);
			BufferedReader in = new BufferedReader(new FileReader(f));
			StringBuffer strBuff = new StringBuffer();
			String i = in.readLine();
			
//			GMA 1.4.8: Test for '\t' in first line of input to set proper delimiting
			if ( i != null && i.indexOf("\t") != -1 ) {
				delim.setSelectedItem("Tab");
			}
			else {
				delim.setSelectedItem("Comma");
			}
			
			while (i!=null) {
				pb.setValue(pb.getValue() + (2*i.length() + 36));
				pb.repaint();
				strBuff.append(i+"\n");
				i=in.readLine();
			}
			name.setText(f.getName().substring(0, f.getName().lastIndexOf('.')));
			in.close();
			d.dispose();
			input.setText(strBuff.toString());
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, "Error loading file:\n"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
		}

	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:43,代碼來源:OtherDBInputDialog.java

示例3: loadExcelFile

import javax.swing.JProgressBar; //導入方法依賴的package包/類
public void loadExcelFile(File f){
	try {
		int length = (int)f.length();
		JDialog d = new JDialog((Frame)null, "Loading File");
		JPanel p = new JPanel(new BorderLayout());
		p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
		d.setLocationRelativeTo(null);
		JProgressBar pb = new JProgressBar(0,length);
		p.add(new JLabel("Loading " + (length / 1000) + " kb file"), BorderLayout.NORTH);
		p.add(pb);
		d.getContentPane().add(p);
		d.pack();
		d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		d.setVisible(true); 
		d.setAlwaysOnTop(true);

		Workbook wb = Workbook.getWorkbook(new ProgressMonitorInputStream(this,"Loading",new FileInputStream(f)));
		if (wb.getNumberOfSheets()==0)return;
		Sheet s = wb.getSheet(0);
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.getRows(); i++) {
			for (int j = 0; j < s.getColumns(); j++)
			{
					if (s.getCell(j, i).getType() == CellType.NUMBER && !s.getCell(j, i).getContents().matches("\\d*"))
					{
						pb.setValue(pb.getValue()+ 16);
						pb.repaint();
						sb.append(((NumberCell)s.getCell(j, i)).getValue()+"\t");
					}
					else
					{
						pb.setValue(pb.getValue() + 2*s.getCell(j, i).getContents().length() + 36);
						pb.repaint();
						sb.append(s.getCell(j, i).getContents()+"\t");
					}
			}
			sb.append("\n");
		}
		name.setText(f.getName().substring(0, f.getName().lastIndexOf('.')));
		input.setText(sb.toString());
		wb.close();
		d.dispose();

	} catch (Exception e) {
		JOptionPane.showMessageDialog(null, "Error loading file:\n"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
		return;
	}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:49,代碼來源:OtherDBInputDialog.java

示例4: loadExcelURL

import javax.swing.JProgressBar; //導入方法依賴的package包/類
public void loadExcelURL(String c){
	try {
		URL url = URLFactory.url(c);
		int length = url.openConnection().getContentLength();
		JDialog d = new JDialog((Frame)null, "Loading File");
		JPanel p = new JPanel(new BorderLayout());
		p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
		d.setLocationRelativeTo(null);
		JProgressBar pb = new JProgressBar(0,length);
		p.add(new JLabel("Loading " + (length / 1000) + " kb file"), BorderLayout.NORTH);
		p.add(pb);
		d.getContentPane().add(p);
		d.pack();
		d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		d.setVisible(true); 
		d.setAlwaysOnTop(true);
		Workbook wb = Workbook.getWorkbook(url.openStream());
		if (wb.getNumberOfSheets()==0) return;
		Sheet s = wb.getSheet(0);
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.getRows(); i++) {
			for (int j = 0; j < s.getColumns(); j++)
			{
					if (s.getCell(j, i).getType() == CellType.NUMBER && !s.getCell(j, i).getContents().matches("\\d*")) {
						sb.append(((NumberCell)s.getCell(j, i)).getValue()+"\t");	
						pb.setValue(pb.getValue() + 16);
						pb.repaint();
					}
					else {
						pb.setValue(pb.getValue() + 2*s.getCell(j, i).getContents().length()+36);
						pb.repaint();
						sb.append(s.getCell(j, i).getContents()+"\t");
					}
					//if (j<s.getRows()-1) sb.append(s.getCell(j, i).getContents()+"\t");
				//else sb.append(s.getCell(j, i).getContents()+"\t");
			}
			sb.append("\n");
		}
		name.setText(url.getFile().substring(url.getFile().lastIndexOf('/')+1, url.getFile().lastIndexOf('.')));
		input.setText(sb.toString());
		wb.close();
		d.dispose();
	} catch (Exception e) {
		JOptionPane.showMessageDialog(null, "Error reading URL:\n"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
		return;
	}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:48,代碼來源:OtherDBInputDialog.java


注:本文中的javax.swing.JProgressBar.repaint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。