⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statusbar.java

📁 Java编写的小游戏扫雷代码,可以在多种环境下运行
💻 JAVA
字号:
/*
 * @(#)StatusBar.java	0.01 2002-10-10
 *
 * Copyright 2004 Dragon Software Limit. All rights reserved.
 *
 */

package org.nebula.cwt;

import java.awt.*;
import java.util.*;
import javax.swing.*;

/**
 * The StatusBar, a simple status bar used in window's bottom.
 *
 * @since 0.1
 */
public class StatusBar extends JPanel {
	public static final int MAX_COLUMN = 10;

	Vector  labels;

    public StatusBar(int cols) {
		super();

		if ((cols <= 0) || (cols > MAX_COLUMN)) return;

		labels = new Vector();

		GridBagLayout gbl = new GridBagLayout();
		GridBagConstraints gc = new GridBagConstraints();
		gc.fill = GridBagConstraints.BOTH;
		setLayout(gbl);

		for (int i = 0 ; i < cols ; i++){
			JPanel p = new JPanel();
			p.setBorder(BorderFactory.createLoweredBevelBorder());
			JLabel jl = new JLabel("loading...");
			labels.addElement(jl);
			p.add(jl);
			GUITools.addComponentTo(this,p, gbl, gc, i, 0, 1, 1, 1.0, 1.0);
		}
	}

	public void showStatus(int index, String info){
		if ((index >= labels.size()) || (index < 0))
			return;
		JLabel jl = (JLabel) labels.elementAt(index);
		jl.setText(info);
		repaint();
	}

	public Dimension getPreferredSize() {
		return new Dimension(20,30);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -