레이아웃이 BorderLayout 인 컨테이너가 있습니다. 이 컨테이너는 반복적으로 그려 지므로 각 행을 수평으로 구분하고 싶기 때문에 SOUTH 위치에 수평선을 그립니다. 여기 컨테이너의 BorderLayout의 남쪽 위치에 수평선을 그리는 방법은 무엇입니까?
코드입니다 :tList = new List(tModel);
tList.setListCellRenderer(new CTable(listclient));
public class CTable extends Container implements ListCellRenderer {
private Label pic = new Label("");
private Container cnt;
private Label name = new Label("");
private Label credit = new Label("");
private ligneHorizontal ligne;
private Font fontLibelle = (MenuPrincipalForm.r).getFont("FontTextFieldBold");
private Label focus = new Label("");
public CTable(Vector valeur)
{
setLayout(new BorderLayout());
addComponent(BorderLayout.WEST, pic);
cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
name.getStyle().setBgTransparency(0);
name.getStyle().setFont(fontLibelle);
credit.getStyle().setBgTransparency(0);
cnt.addComponent(name);
cnt.addComponent(credit);
ligne = new ligneHorizontal(100);
cnt.addComponent(ligne);
addComponent(BorderLayout.CENTER, cnt);
focus.getStyle().setBgTransparency(100);
}
public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected)
{
if ("-".equalsIgnoreCase(String.valueOf(value)))
{
name.setText(" - ");
credit.setText("Encours : - Impayés : -");
pic.setIcon(null);
}
else
{
if (index%2 == 0)
this.setUIID("evenRowsCell");
else
this.setUIID("oddRowsCell");
name.setText("123456789012 - Rasolofomanana Marc");
credit.setText("Crédits : 15.000 (Ar) Impayés : 10.000 (Ar)");
pic.setIcon(null);
}
return this;
}
public Component getListFocusComponent(List list)
{
return focus;
}
}
public class ligneHorizontal extends Label {
public ligneHorizontal(int l)
{
String t = "";
do
{
t.concat(new String("-"));
}
while(t.length()<l);
this.setText(t);
this.setPreferredH(5);
this.getStyle().setBgColor(0);
}
}
또한 내가 시도하지만 셀을 클릭 할 때까지 색상이하지 않기 때문에 심지어 행과 목록의 홀수 행을 coloriate하는 방법을 알고 싶어요.
나는 아무것도 볼 수 없다! –
또한 bg 스타일을 지정하십시오. –
레이블에 공백 문자열 레이블을 지정하여 특수 문자로 지정하여 선호 크기 값을 0으로 지정하고 그리지 않으므로 작동하지 않습니다. 선호되는 너비도 증가시켜야합니다. 그래도 큰 해결책은 아니지만 작동시킬 수 있습니다. 우리는 일반적으로 테마에서 반복 가능한 이미지를 사용합니다 (예 : T-zone Friends 데모에서 Add 대화 상자의 UI를 확인하십시오.) –