?? userinfo.java
字號:
package fyrad;
import javax.swing.*;
import java.awt.*;
public class UserInfo extends JPanel
{
/**
* 玩家信息顯示
*/
private static final long serialVersionUID = 6210765339381106319L;
public String userName;
public Color userColor;
public JLabel nameCtrl;
public JLabel colorCtrl;
public Button colorButton;
public UserInfo(String name,Color color)
{
userName=name;
userColor=color;
InitUser();
}
public void SetName(String name)
{ userName=name; }
public void SetColor(Color color)
{ userColor=color; }
public void InitUser()
{
if(nameCtrl==null)
{
nameCtrl=new JLabel();
nameCtrl.setText("Player Name:"+userName);
}
if(colorCtrl==null)
{
colorCtrl=new JLabel();
colorCtrl.setText("Player Color:");
}
colorButton=new Button();
colorButton.setBackground(userColor);
this.setLayout(null);
this.add(nameCtrl);
this.add(colorCtrl);
this.add(colorButton);
nameCtrl.setBounds(0,0,196,20);
colorCtrl.setBounds(0,20,160,20);
colorButton.setBounds(160,15,30,30);
}
public void UpdateUserInfo()
{
nameCtrl=new JLabel();
nameCtrl.setText("Player Name:"+userName);
colorCtrl=new JLabel();
colorCtrl.setText("Player Color:");
colorButton=new Button();
colorButton.setBackground(userColor);
this.setLayout(null);
this.add(nameCtrl);
this.add(colorCtrl);
this.add(colorButton);
nameCtrl.setBounds(0,0,196,20);
colorCtrl.setBounds(0,20,160,20);
colorButton.setBounds(160,15,30,30);
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
int width=getWidth();
int height=getHeight();
g.setColor(Color.black);
g.drawRect(0, 0, width-1, height-1);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -