当前位置: 首页>>代码示例>>Java>>正文


Java JProgressBar.setBackground方法代码示例

本文整理汇总了Java中javax.swing.JProgressBar.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java JProgressBar.setBackground方法的具体用法?Java JProgressBar.setBackground怎么用?Java JProgressBar.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JProgressBar的用法示例。


在下文中一共展示了JProgressBar.setBackground方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: JProgressDemo

import javax.swing.JProgressBar; //导入方法依赖的package包/类
public JProgressDemo() {
	frame = new JFrame("install");
	frame.setLayout(new BorderLayout());
	label = new JLabel("progress",SwingConstants.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, 10));
	progressbar.setBorderPainted(false);
	progressbar.setBackground(Color.pink);
	JPanel progressPane = new JPanel();
	progressPane.add(progressbar);
	progressPane.setPreferredSize(new Dimension(300, 10));
	JPanel panel = new JPanel();
	b = new JButton("install");
	stop = new JButton("pause");
	b.setForeground(Color.blue);
	b.addActionListener(this);
	stop.addActionListener(this);
	panel.add(b);
	panel.add(stop);
	// timer=new Timer(100,this);
	timer = new Timer(1000/10, this);
	frame.add(panel, BorderLayout.NORTH);
	frame.add(progressPane, BorderLayout.CENTER);
	frame.add(label, BorderLayout.SOUTH);
	// frame.pack();
	frame.setBounds(100, 100, 400, 130);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setVisible(true);
}
 
开发者ID:followwwind,项目名称:javase,代码行数:36,代码来源:JProgressDemo.java

示例2: createWholeProgress

import javax.swing.JProgressBar; //导入方法依赖的package包/类
private JProgressBar createWholeProgress(int total)
{
	whole = new JProgressBar(0, total);
	whole.setValue(0);
	whole.setStringPainted(true);
	whole.setForeground(new Color(153, 153, 204));
	whole.setBackground(Color.white);

	return whole;
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:ProgressWindow.java

示例3: createCurrentProgress

import javax.swing.JProgressBar; //导入方法依赖的package包/类
private JProgressBar createCurrentProgress()
{
	current = new JProgressBar(0, 0);
	current.setValue(0);
	current.setStringPainted(true);
	current.setForeground(new Color(153, 153, 204));
	current.setBackground(Color.white);

	return current;
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:ProgressWindow.java

示例4: initComponents

import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
 * Inicia los componentes del panel del Score
 */
public void initComponents(){
    int extra = 30;
    //FUENTE
    StarJedi = this.cargarFuente("../Starjedi.ttf");
    
    /**
     * TODO TIEMPO
     */
    iconTiempo = new JLabel("tiempo");               
    iconTiempo.setBounds(40, 10+extra, 200, 50);
    iconTiempo.setForeground(Color.yellow);
    iconTiempo.setFont(StarJedi);
    
    intTiempo = 0;
    tiempo = new JLabel(String.valueOf(intTiempo));
    tiempo.setBounds(82, 80+extra, 100, 30);
    tiempo.setForeground(Color.yellow);
    tiempo.setFont(StarJedi.deriveFont(1, 22f));
    
    /**
     * TODO SCORE
     */
    iconScore = new JLabel("score");               
    iconScore.setBounds(45, 130+extra, 200, 50);
    iconScore.setForeground(Color.yellow);
    iconScore.setFont(StarJedi);
    
    intScore = 0;
    score = new JLabel(String.valueOf(intScore));
    score.setForeground(Color.yellow);
    score.setFont(StarJedi.deriveFont(1, 22f));
    score.setBounds(90, 200+extra, 100, 30);
    
    /**
     * TODO COMBUSTIBLE
     */
    iconFuel = new JLabel();               
    iconFuel.setBounds(10, 250+extra, 200, 50);
    iconFuel.setForeground(Color.yellow);
    iconFuel.setFont(StarJedi.deriveFont(1, 22f));
    iconFuel.setText("Combustible");
    
    fuel = new JProgressBar(0);
    fuel.setBounds(25, 325+extra, 150, 30);  
    fuel.setValue(100);
    fuel.setBackground(Color.BLACK);
    
    /**
     * TODO VIDAS
     */
    iconLives = new JLabel();               
    iconLives.setBounds(43, 380+extra, 200, 50);
    iconLives.setForeground(Color.yellow);
    iconLives.setFont(StarJedi);
    iconLives.setText("vidas");
    
    intLives = 3;
    lives = new JLabel(String.valueOf(intLives));
    lives.setForeground(Color.yellow);
    lives.setFont(StarJedi.deriveFont(1, 22f));
    lives.setBounds(90, 450+extra, 100, 30);
    
    super.add(iconTiempo, 0);
    super.add(tiempo, 0);
    super.add(iconScore, 0);
    super.add(score, 0);
    super.add(iconFuel, 0);
    super.add(fuel, 0);
    super.add(iconLives, 0);
    super.add(lives, 0);
}
 
开发者ID:Uminks,项目名称:Star-Ride--RiverRaid,代码行数:75,代码来源:PanelScore.java

示例5: run

import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
 * thread run method
 */
public void run() {
	
	System.out.println("[ReceiveFileThread] :: started on port " + port + "file size : " + fileSize);
       int progress = 0;
	try {
		
		ServerSocket ssock = new ServerSocket(port);			
		Socket socket = ssock.accept();
		int size = 10000;
		byte[] contents = new byte[size];

		//Initialize the FileOutputStream to the output file's full path.
		FileOutputStream fos = new FileOutputStream(filePath);
		BufferedOutputStream bos = new BufferedOutputStream(fos);
		InputStream is = socket.getInputStream();

		//No of bytes read in one read() call
		int bytesRead = 0; 
       
		//receiving file Message dialog window
		JFrame recFileMessFrame =  new JFrame("Recieving File");
		recFileMessFrame.setBounds(500, 300, 350, 200);
	  			
	  	JPanel panel = new JPanel();
	  	panel.setLayout(new GridLayout(9, 1));
	  	
	 	//progress bar for recieved data
	  	JProgressBar progressbar = new JProgressBar(0, 100); 	
	  	progressbar.setSize(new Dimension(100, 15));
	    progressbar.setBackground(Color.white);
	    progressbar.setForeground(Color.gray);		    
	   
	    //adding blank frame
	    for(int i = 0; i <= 2; i++){
		    panel.add(new JPanel());
		}
	    
	    JPanel progressPanel = new JPanel(new BorderLayout(5, 5));
		JLabel progressLabel = new JLabel();
		
		//adding progress label to progress panel
		progressPanel.add(progressLabel);			
		panel.add(progressPanel);
		
	    //adding progress panel to main panel
		panel.add(progressbar);
	
		recFileMessFrame.add(panel);
		recFileMessFrame.setVisible(true);
		long recFileSize = 0;
		
	    while((bytesRead=is.read(contents))!=-1){
	    			   	
	    	recFileSize += bytesRead; 
	    	//change the progressbar value
			progressbar.setValue((progress = (int)((recFileSize*100)/fileSize)));
			progressLabel.setText("File Recieved......." + progress + "%");		
			bos.write(contents, 0, bytesRead);
		}
		bos.flush();
		recFileMessFrame.setVisible(false);
		JOptionPane.showMessageDialog(null, "File recieved ! " + Paths.get(filePath).getFileName() );
		socket.close();
		ssock.close();
	} catch(Exception e) {
		System.out.println("[ReceiveFileThread] exception :: " + e);
		e.printStackTrace();
	}

	System.out.println("[ReceiveFileThread] :: File saved successfully!");
}
 
开发者ID:angeldove,项目名称:LanChatLite,代码行数:75,代码来源:ReceiveFileThread.java


注:本文中的javax.swing.JProgressBar.setBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。