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

The following examples show how to use javax.swing.JProgressBar#setForeground() . 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: SendFileFrame.java    From myqq with MIT License 6 votes vote down vote up
/**
 * Create the frame.
 */
public SendFileFrame()
{
	//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 510, 196);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);

	lbl = new JLabel("进度条");
	lbl.setBounds(42, 35, 74, 33);
	contentPane.add(lbl);

	progressBar = new JProgressBar();
	progressBar.setForeground(Color.BLUE);
	progressBar.setBounds(96, 35, 332, 33);
	contentPane.add(progressBar);

	lblProgress = new JLabel("");
	lblProgress.setBounds(64, 82, 386, 58);
	contentPane.add(lblProgress);
}
 
Example 2
Source File: TaskImagePanel.java    From egdownloader with GNU General Public License v2.0 6 votes vote down vote up
public void renderSelectBarColor(JPanel p, JProgressBar bar, boolean selected, Task task){
	if(selected){
		bar.setForeground(progressBarSelectedColor);
		p.setBorder(BorderFactory.createLineBorder(progressBarSelectedColor, 2));
	}else{
		if(task.isSearched()){
			bar.setForeground(progressBarSearchedColor);
			p.setBorder(BorderFactory.createLineBorder(progressBarSearchedColor, 2));
		}else if(task.getStatus() == TaskStatus.COMPLETED){
			bar.setForeground(progressBarCompletedColor);
			p.setBorder(BorderFactory.createLineBorder(progressBarCompletedColor, 2));
		}else{
			bar.setForeground(progressBarColor);
			p.setBorder(BorderFactory.createLineBorder(progressBarColor, 2));
		}
	}
}
 
Example 3
Source File: JPanel_TaskManager.java    From MobyDroid with Apache License 2.0 5 votes vote down vote up
public TaskProgressCellRenderer() {
    jProgressBar = new JProgressBar(0, 100);
    jProgressBar.setBackground(MaterialColor.WHITE);
    jProgressBar.setForeground(MaterialColor.BLUE_700);
    jProgressBar.setStringPainted(true);
    jProgressBar.setOpaque(false);
}
 
Example 4
Source File: UpdateScreen.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
public void Downloading(int n) {
	MAX = n;

	JPanel labelPanel = new JPanel(new FlowLayout());
	JLabel label = new JLabel("Downloading...");
	label.setFont(new Font("Sans Serif", Font.PLAIN, 15));
	labelPanel.add(label);
	labelPanel.setBorder(new EmptyBorder(4, 0, 4, 0));
	labelPanel.setBackground(Color.WHITE);

	JPanel progressPanel = new JPanel(new BorderLayout());
	progress = new JProgressBar(0, MAX);
	progress.setStringPainted(true);
	progress.setForeground(Value.TRUE_COLOR);
	progressPanel.add(progress);
	progressPanel.setBorder(new EmptyBorder(0, 10, 4, 10));
	progressPanel.setBackground(Color.WHITE);

	JPanel buttonPanel = new JPanel(new FlowLayout());
	buttonPanel.add(cancel);
	buttonPanel.setBackground(Color.WHITE);

	JPanel updatePanel = new JPanel(new BorderLayout());
	updatePanel.add(labelPanel, BorderLayout.NORTH);
	updatePanel.add(progressPanel, BorderLayout.CENTER);
	updatePanel.add(buttonPanel, BorderLayout.SOUTH);

	this.getContentPane().add(updatePanel, BorderLayout.CENTER);
}
 
Example 5
Source File: Launcher.java    From rscplus with GNU General Public License v3.0 5 votes vote down vote up
/** Renders the launcher progress bar window, then calls {@link #run()}. */
public void init() {
  Logger.start();
  Logger.Info("Starting rscplus");

  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  getContentPane().setBackground(Color.BLACK);

  // Set window icon
  URL iconURL = Settings.getResource("/assets/icon.png");
  if (iconURL != null) {
    icon = new ImageIcon(iconURL);
    setIconImage(icon.getImage());
  }
  iconURL = Settings.getResource("/assets/icon_warn.png");
  if (iconURL != null) {
    icon_warn = new ImageIcon(iconURL);
  }

  // Set size
  getContentPane().setPreferredSize(new Dimension(280, 32));
  setTitle("rscplus Launcher");
  setResizable(false);
  pack();
  setLocationRelativeTo(null);

  // Add progress bar
  m_progressBar = new JProgressBar();
  m_progressBar.setStringPainted(true);
  m_progressBar.setBorderPainted(true);
  m_progressBar.setForeground(Color.GRAY.brighter());
  m_progressBar.setBackground(Color.BLACK);
  m_progressBar.setString("Initializing");
  getContentPane().add(m_progressBar);

  setVisible(true);
  new Thread(this).start();
}
 
Example 6
Source File: TimerFrame.java    From training with MIT License 5 votes vote down vote up
public TimerFrame() {
	setUndecorated(true);
	getContentPane().setBackground(Color.lightGray);
	setShape(new RoundRectangle2D.Double(0, -20, GlobalSettings.WIDTH/2, 44, 20, 20));
	setSize(GlobalSettings.WIDTH/2, 24);
	setLocation(getX(), 0);
	horizontalPositioner.tick();
	setAlwaysOnTop(true);
	setFocusable(false);
	setType(Type.UTILITY);
	setFocusableWindowState(false);

	getContentPane().setLayout(new BorderLayout());
	
	progressBar = new JProgressBar();
	progressBar.setForeground(Color.lightGray);
	progressBar.setBackground(Color.GREEN);
	progressBar.setString("1 min");
	progressBar.setStringPainted(true);
	progressBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	progressBar.setBorderPainted(false);
	progressBar.setValue(50);
	progressBar.setFont(new Font("Consolas", Font.BOLD, 19));
	progressBar.addMouseListener(new ProgressMouseListener());
	progressBar.setCursor(new Cursor(Cursor.HAND_CURSOR));
	getContentPane().add(progressBar);
}
 
Example 7
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 8
Source File: ShowProgressBar.java    From CEC-Automatic-Annotation with Apache License 2.0 5 votes vote down vote up
public ShowProgressBar() {

		// 创建标签,并在标签上放置一张图片
		// label = new JLabel(new ImageIcon("images/background.jpg"));
		label = new JLabel("数据正在处理中,请稍后... ...", SwingConstants.CENTER);
		label.setFont(new Font("华文楷体", Font.ITALIC, 30));
		label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT - 25);
		label.setBackground(new Color(204, 0, 1));// 背景色设置之后无效,不知道为何
		label.setForeground(new Color(69, 133, 243));
		// 创建进度条
		progressbar = new JProgressBar();
		// 显示当前进度值信息
		progressbar.setStringPainted(true);
		// 设置进度条边框不显示
		progressbar.setBorderPainted(false);
		// 设置进度条的前景色,即进度条的颜色
		progressbar.setForeground(new Color(153, 230, 40));
		// 设置进度条的背景色,即进度条的背景色
		progressbar.setBackground(new Color(27, 27, 24));
		progressbar.setBounds(0, LOAD_HEIGHT - 15, LOAD_WIDTH, 15);
		// 添加组件
		this.add(label);
		this.add(progressbar);
		// 设置布局为空
		this.setLayout(null);
		// 设置窗口初始位置
		this.setLocation((WIDTH - LOAD_WIDTH) / 2, (HEIGHT - LOAD_HEIGHT) / 2);
		// 设置窗口大小
		this.setSize(LOAD_WIDTH, LOAD_HEIGHT);
		// 设置窗口显示
		this.setVisible(true);

	}
 
Example 9
Source File: SettlerProgressbar.java    From settlers-remake with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);

	c.setOpaque(false);
	c.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));

	JProgressBar pg = (JProgressBar) c;
	pg.setForeground(FOREGROUND_COLOR);
}
 
Example 10
Source File: Launcher.java    From open-ig with GNU Lesser General Public License v3.0 4 votes vote down vote up
/** Create the progress panel. */
void createProgressPanel() {
	GroupLayout gl = new GroupLayout(progressPanel);
	progressPanel.setLayout(gl);
	
	currentActionLabel = new JLabel();
	currentFileLabel = new JLabel();
	currentFileProgressLabel = new JLabel();
	totalFileProgressLabel = new JLabel();

	currentAction = new JLabel();
	currentFile = new JLabel();
	currentFileProgress = new JLabel();
	totalFileProgress = new JLabel();

	fileProgress = new JProgressBar();
	fileProgress.setFont(fontMedium);
	fileProgress.setStringPainted(true);
	totalProgress = new JProgressBar();
	totalProgress.setFont(fontMedium);
	totalProgress.setStringPainted(true);
	
	currentActionLabel.setFont(fontLarge);
	currentActionLabel.setForeground(Color.LIGHT_GRAY);
	currentFileLabel.setFont(fontMedium);
	currentFileLabel.setForeground(Color.LIGHT_GRAY);
	currentFileProgressLabel.setFont(fontMedium);
	currentFileProgressLabel.setForeground(Color.LIGHT_GRAY);
	totalFileProgressLabel.setFont(fontMedium);
	totalFileProgressLabel.setForeground(Color.LIGHT_GRAY);
	
	currentAction.setFont(fontLarge);
	currentFile.setFont(fontMedium);
	currentFileProgress.setFont(fontMedium);
	totalFileProgress.setFont(fontMedium);
	currentAction.setForeground(Color.ORANGE);
	currentFile.setForeground(Color.WHITE);
	currentFileProgress.setForeground(Color.WHITE);
	totalFileProgress.setForeground(Color.WHITE);
	fileProgress.setForeground(backgroundColoring);
	totalProgress.setForeground(backgroundColoring);
	
	
	gl.setHorizontalGroup(
		gl.createParallelGroup()
		.addGroup(
			gl.createSequentialGroup()
			.addGroup(
				gl.createParallelGroup()
				.addComponent(currentActionLabel)
				.addComponent(currentFileLabel)
				.addComponent(currentFileProgressLabel)
				.addComponent(totalFileProgressLabel)
			)
			.addGap(20)
			.addGroup(
				gl.createParallelGroup()
				.addGroup(
					gl.createSequentialGroup()
					.addComponent(currentAction, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
					.addComponent(cancel)
				)
				.addComponent(currentFile)
				.addComponent(currentFileProgress)
				.addComponent(totalFileProgress)
			)
		)
		.addComponent(fileProgress)
		.addComponent(totalProgress)
	);
	gl.setVerticalGroup(
		gl.createSequentialGroup()
		.addGroup(
			gl.createParallelGroup(Alignment.BASELINE)
			.addComponent(currentActionLabel)
			.addComponent(currentAction)
			.addComponent(cancel)
		)
		.addGroup(
			gl.createParallelGroup(Alignment.BASELINE)
			.addComponent(currentFileLabel)
			.addComponent(currentFile)
		)
		.addGroup(
			gl.createParallelGroup(Alignment.BASELINE)
			.addComponent(currentFileProgressLabel)
			.addComponent(currentFileProgress)
		)
		.addGap(5)
		.addComponent(fileProgress)
		.addGap(5)
		.addGroup(
			gl.createParallelGroup(Alignment.BASELINE)
			.addComponent(totalFileProgressLabel)
			.addComponent(totalFileProgress)
		)
		.addGap(5)
		.addComponent(totalProgress)
	);
}
 
Example 11
Source File: JProgressBarFactory.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
public static JProgressBar createHorizontalJProgressBar(int min, int max, ImageInfoReader imageInfoReader) {
	JProgressBar progressBar = new TiledHorizontalImageProgressBar(min, max, ImageIds.PROGRESSBAR_BACKGROUND, imageInfoReader);
	progressBar.setBackground(ColorPalette.DARK_BACKGROUND_COLOR);
	progressBar.setForeground(ColorPalette.FOREGROUND_COLOR);
	return progressBar;
}
 
Example 12
Source File: LevelInfoPanel.java    From osrsclient with GNU General Public License v2.0 4 votes vote down vote up
private void setup() {

        this.setLayout(new MigLayout("ins 05, gapx 5, align left, "));
        setBackground(new Color(51, 51, 51));
        setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

        skillLabel = new JLabel("SKILL:");
        rankLabel = new JLabel("RANK:");
        xpLabel = new JLabel("XP:");
        xpToLevelLabel = new JLabel("XP TO LEVEL:");
        xpToLevelBar = new JProgressBar(0);
        xpToLevelBar.setStringPainted(true);

        skill = new JLabel("");
        rank = new JLabel("");
        xp = new JLabel("");
        xpToLevel = new JLabel("");

        skillLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, skillLabel.getFont().getSize()));
        rankLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, rankLabel.getFont().getSize()));
        xpLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpLabel.getFont().getSize()));
        xpToLevelLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpToLevelLabel.getFont().getSize()));

        skill.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, skillLabel.getFont().getSize()));
        rank.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, rankLabel.getFont().getSize()));
        xp.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpLabel.getFont().getSize()));
        xpToLevel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpToLevelLabel.getFont().getSize()));

        skillLabel.setForeground(Color.white);
        rankLabel.setForeground(Color.white);
        xpLabel.setForeground(Color.white);
        xpToLevelLabel.setForeground(Color.white);

        skill.setForeground(Color.white);
        rank.setForeground(Color.white);
        xp.setForeground(Color.white);
        xpToLevel.setForeground(Color.white);
        
       xpToLevelBar.setForeground(Color.green);
       xpToLevelBar.setBackground(Color.red);
       xpToLevelBar.setBorder(BorderFactory.createLineBorder(Color.black));
       xpToLevelBar.setUI(new BasicProgressBarUI());
       
        add(skillLabel, "cell 0 0,spanx ");
        add(rankLabel, "cell 0 1,spanx ");
        add(xpLabel, "cell 0 2, gap 0,spanx");
        add(xpToLevelLabel, "cell 0 3, gap 0,spanx ");

        add(skill, "cell 1 0,spanx, gap 45");
        add(rank, "cell 1 1, spanx, gap 45");
        add(xp, "cell 1 2,spanx, gap 25");
        add(xpToLevel, "cell 1 3, spanx, gap 100");
        add(xpToLevelBar, "cell 0 4,spanx, width 100%  ");
    }