📄 frendlistpanel.java
字号:
package group.client;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class FrendListPanel extends JPanel
{
private JList frendList;
private DefaultListModel model;
public FrendListPanel(String title, int rowSize, int hSize)
{
model = new DefaultListModel();
frendList = new JList();
frendList.setVisibleRowCount(rowSize);
frendList.setFixedCellHeight(20);
frendList.setFixedCellWidth(hSize);
frendList.setModel(model);
add(new JScrollPane(frendList));
Border titleBorder = BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(EtchedBorder.RAISED,
Color.black, Color.white), title); //创建一个用于面板的有标题的3D直线边界
setBorder(titleBorder);
}
public void updateFrend(String ID)
{
if(ID.endsWith("move"))
{
model.removeElement(ID.substring(0, ID.lastIndexOf("move")));
}
else
{
model.addElement(ID);
}
}
public String getID()
{
String tmp = (String)frendList.getSelectedValue();
if(tmp == null)
{
return "";
}
return tmp.substring(tmp.indexOf("[") + 1, tmp.lastIndexOf("]"));
}
/*public static void main(String[] args)
{
FrendListPanel f = new FrendListPanel("wwww", 21, 150);
JFrame frame = new JFrame("Test");
frame.getContentPane().add(f);
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -