当前位置: 首页>>代码示例>>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;未经允许,请勿转载。