📄 checkboxgroup.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: CheckboxGroup.java
package com.motorola.lwt;
// Referenced classes of package com.motorola.lwt:
// Checkbox, ComponentListener, Component
public class CheckboxGroup
{
public static final int CHECKBOXGROUP_SELECTION_CHANGED = 1;
private Checkbox itsCheckboxes[];
private int checkboxCount;
ComponentListener listener;
int style;
public CheckboxGroup(int i)
throws IllegalArgumentException
{
itsCheckboxes = new Checkbox[5];
checkboxCount = 0;
listener = null;
style = 0;
if(i < 1 || i > 3)
{
throw new IllegalArgumentException();
} else
{
style = i;
return;
}
}
public int getSelectedIndex()
{
if(style != 1)
{
for(int i = checkboxCount - 1; i >= 0; i--)
if(itsCheckboxes[i].value)
return i;
}
return -1;
}
public void setComponentListener(ComponentListener componentlistener)
{
listener = componentlistener;
}
void dispatchComponentEvent(int i)
{
if(listener != null)
listener.processComponentEvent(this, i);
}
public synchronized int add(Checkbox checkbox)
{
insert(checkbox, checkboxCount);
return checkboxCount - 1;
}
public synchronized void insert(Checkbox checkbox, int i)
{
boolean flag = checkbox.value;
if(checkbox.itsGroup != null)
checkbox.itsGroup.remove(checkbox);
i = i >= 0 ? i <= checkboxCount ? i : checkboxCount : 0;
if(checkboxCount == itsCheckboxes.length)
{
Checkbox acheckbox[] = itsCheckboxes;
itsCheckboxes = new Checkbox[checkboxCount + 5];
System.arraycopy(acheckbox, 0, itsCheckboxes, 0, checkboxCount);
}
if(i < checkboxCount)
System.arraycopy(itsCheckboxes, i, itsCheckboxes, i + 1, checkboxCount - i);
itsCheckboxes[i] = checkbox;
checkboxCount++;
checkbox.itsGroup = this;
checkbox.style = style;
checkbox.preferredWidthChanged();
checkbox.repaint();
if(style != 1)
if(checkboxCount == 1)
setSelectedIndex(0, true);
else
checkbox.setValueImpl(false);
}
public synchronized void remove(Checkbox checkbox)
{
int i = getIndex(checkbox);
if(i >= 0)
remove(i);
}
int getIndex(Checkbox checkbox)
{
for(int i = checkboxCount - 1; i >= 0; i--)
if(itsCheckboxes[i] == checkbox)
return i;
return -1;
}
public Checkbox getCheckbox(int i)
throws IndexOutOfBoundsException
{
if(i >= 0 && i < checkboxCount)
return itsCheckboxes[i];
else
throw new IndexOutOfBoundsException();
}
public int getCheckboxCount()
{
return checkboxCount;
}
public synchronized void remove(int i)
throws IndexOutOfBoundsException
{
if(i >= 0 && i < checkboxCount)
{
if(style != 1 && itsCheckboxes[i].value)
setSelectedIndex(0, true);
itsCheckboxes[i].itsGroup = null;
int j = checkboxCount - i - 1;
if(j > 0)
System.arraycopy(itsCheckboxes, i + 1, itsCheckboxes, i, j);
checkboxCount--;
itsCheckboxes[checkboxCount] = null;
} else
{
throw new IndexOutOfBoundsException();
}
}
public synchronized boolean isSelected(int i)
throws IndexOutOfBoundsException
{
if(i >= 0 && i < checkboxCount)
return itsCheckboxes[i].value;
else
throw new IndexOutOfBoundsException();
}
public synchronized void setSelectedFlags(boolean aflag[])
{
if(checkboxCount > 0)
if(aflag.length >= checkboxCount)
{
if(style == 1)
{
boolean flag = false;
for(int j = checkboxCount - 1; j >= 0; j--)
flag |= itsCheckboxes[j].setValueImpl(aflag[j]);
if(flag)
dispatchComponentEvent(1);
} else
{
for(int i = 0; i < checkboxCount; i++)
if(aflag[i])
{
setSelectedIndex(i, true);
return;
}
setSelectedIndex(0, true);
}
} else
{
throw new IllegalArgumentException();
}
}
public synchronized void setSelectedIndex(int i, boolean flag)
{
if(i >= 0 && i < checkboxCount)
{
if(style == 1)
{
if(itsCheckboxes[i].setValueImpl(flag))
dispatchComponentEvent(1);
} else
if(flag)
{
int j = getSelectedIndex();
if(j != i)
{
if(j != -1)
itsCheckboxes[j].setValueImpl(false);
itsCheckboxes[i].setValueImpl(true);
dispatchComponentEvent(1);
}
}
} else
{
throw new IndexOutOfBoundsException();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -