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

📄 antcomponent.java

📁 P2P模拟器P2Psim的程序源码
💻 JAVA
字号:
/*
 * Created on 20-dec-2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package gui;

import graph.Properties;
import graph.Ant;

//import javax.swing.JComponent;
import java.util.ListIterator;

import javax.swing.JLabel;

import java.awt.Color;
import java.awt.Graphics;

//import graph.Properties;


public class AntComponent extends PropertyComponent
{

	private JLabel[] color = new JLabel[10];
	private JLabel[] number = new JLabel[10];
	private JLabel[] destination = new JLabel[10];	

	public AntComponent()
	{		
		for (int i=0; i<10; i++)
		{
			color[i] = new JLabel("");
			color[i].setOpaque(true);
			color[i].setBounds(0, (1+i*16), 14, 14);
			//color[i].setBackground(Color.white);
			add(color[i]);
			
			number[i] = new JLabel("");
			number[i].setBounds(20, i*16, 16, 16);
			//color[i].setBackground(Color.red);
			add(number[i]);
			
			destination[i] = new JLabel("");
			destination[i].setBounds(42, i*16, 80, 16);
			//destination[i].setBackground(Color.blue);
			add(destination[i]);
		}
		
		System.out.println(color[0].toString());
	}

	public void paint(Graphics g)
	{
		super.paint(g);
		System.out.println("Paint");
	}

	public void updateInformation(Properties p)
	{
		for (int i=0; i<10; i++)
		{
			color[i].setBackground(new Color(204,204,204));
			number[i].setText("");
			destination[i].setText("");
		}
		
		Ant tempAnt;
		ListIterator li = p.getInformation("Ants");
		
		int i = 0;
		while(li != null && li.hasNext() && i<10)
		{
			tempAnt = (Ant)li.next();
			
			color[i].setBackground(Color.orange);
			//number[i].setText(String.valueOf(tempGradient.getDistance()));
			destination[i].setText(tempAnt.getDestination().toString());
			
			i++;
		}
	}

}

⌨️ 快捷键说明

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