?? userinfopanel.java
字號:
package qq.client.panel;
/**
* 個人信息條
* @author student
*
*/
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.BorderFactory;
import qq.entity.*;
public class UserInfoPanel extends JPanel{
private static final long serialVersionUID = 14521154L;
private User user;
public UserInfoPanel(User user){
this.user=user;
Border line = BorderFactory.createLineBorder(new Color(74,133, 213));
this.setBackground(new Color(244, 249, 254));
this.setLayout(new FlowLayout(FlowLayout.LEADING,0,10));//設置對齊方式,從左到右
this.setBorder(line);
this.add(getLabel());
}
private JLabel getLabel(){
ImageIcon icon = user.getSmallImageIcon();
String memo="";
if(user.getMemo()!=null){
memo=user.getMemo();
}
String str=user.getName()+" ("+user.getId()+")"+" : "+memo;
JLabel label=new JLabel(str,icon,SwingConstants.LEFT);
label.setForeground(Color.RED);
return label;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -