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

📄 statusbar.java

📁 用Java实现的网络画图程序
💻 JAVA
字号:
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;

public class StatusBar extends JPanel implements Constants{
	private StatusPane colorPane=new StatusPane("蓝色");
	private StatusPane typePane=new StatusPane("直线");
	private StatusPane xPane=new StatusPane("X");
	private StatusPane yPane=new StatusPane("Y");
	
	public StatusBar(){
		setLayout(new FlowLayout(FlowLayout.LEFT,2,1));
		setBackground(Color.lightGray);
		setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
		setColorPane(DEFAULT_ELEMENT_COLOR);
		setTypePane(DEFAULT_ELEMENT_TYPE);
		add(colorPane);
		add(typePane);
		add(xPane);
		add(yPane);
	}

	public void setColorPane(Color color){
		String text;
		if(color.equals(Color.red))
			text="红色";
		else if(color.equals(Color.yellow))
			text="黄色";
		else if(color.equals(Color.green))
			text="绿色";
		else if(color.equals(Color.blue))
			text="蓝色";
		else
			text="定制颜色";
		colorPane.setForeground(color);
		colorPane.setText(text);
	
	}

	public void setTypePane(int type){
		String text;
		switch(type){
			case LINE:
				text="直线";
				break;
			case RECTANGLE:
				text="矩形";
				break;
			case CIRCLE:
				text="圆";
				break;
			case ELLIPSE:
				text="椭圆";
				break;
			case CURVE:
				text="曲线";
				break;
			case TEXT:
				text="标注";
				break;
			default:
				text="错误";
		
		}
		typePane.setText(text);
	
	}


	public void setXY(Point point){
		xPane.setText("X: "+Integer.toString(point.x));
		yPane.setText("Y: "+Integer.toString(point.y));

	}

	

	class StatusPane extends JLabel {
		
		private Font paneFont=new Font("宋体",Font.PLAIN,12);
		
		public StatusPane(String text){
			setBackground(Color.lightGray);	
			setForeground(Color.black);	
			setFont(paneFont);
			setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
			setPreferredSize(new Dimension(100,20));
			setText(text);
		}
	}

}
			
			
	

⌨️ 快捷键说明

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