|
|
|
@ -37,6 +37,8 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
|
|
|
|
|
private boolean isToolBarComponent = false; |
|
|
|
|
private boolean isClick; |
|
|
|
|
|
|
|
|
|
private boolean autoFireStateChanged = true; |
|
|
|
|
|
|
|
|
|
public UIButtonGroup(String[] textArray) { |
|
|
|
|
this(textArray, null); |
|
|
|
|
} |
|
|
|
@ -72,7 +74,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
|
|
|
|
|
if (globalNameListener != null) { |
|
|
|
|
globalNameListener.setGlobalName(buttonGroupName); |
|
|
|
|
} |
|
|
|
|
setSelectedWithFireChanged(index); |
|
|
|
|
setSelectedIndex(index, autoFireStateChanged); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
@ -108,7 +110,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
|
|
|
|
|
if (globalNameListener != null) { |
|
|
|
|
globalNameListener.setGlobalName(buttonGroupName); |
|
|
|
|
} |
|
|
|
|
setSelectedWithFireChanged(index); |
|
|
|
|
setSelectedIndex(index, autoFireStateChanged); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
@ -175,7 +177,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
|
|
|
|
|
if (globalNameListener != null) { |
|
|
|
|
globalNameListener.setGlobalName(buttonGroupName); |
|
|
|
|
} |
|
|
|
|
setSelectedWithFireChanged(index); |
|
|
|
|
setSelectedIndex(index, autoFireStateChanged); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
@ -253,6 +255,10 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
|
|
|
|
|
g2d.setClip(oldClip); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setAutoFireStateChanged(boolean autoFireStateChanged) { |
|
|
|
|
this.autoFireStateChanged = autoFireStateChanged; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* setSelectedItem |
|
|
|
|
* |
|
|
|
@ -287,13 +293,14 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
|
|
|
|
|
return selectedIndex; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void setSelectedWithFireChanged(int newSelectedIndex) { |
|
|
|
|
protected void setSelectedIndex(int newSelectedIndex, boolean fireChanged) { |
|
|
|
|
if (selectedIndex != newSelectedIndex) { |
|
|
|
|
selectedIndex = newSelectedIndex; |
|
|
|
|
for (int i = 0; i < labelButtonList.size(); i++) { |
|
|
|
|
if (i == selectedIndex) { |
|
|
|
|
labelButtonList.get(i).setSelectedWithFireListener(true); |
|
|
|
|
} else { |
|
|
|
|
labelButtonList.get(i).setSelected(false); |
|
|
|
|
labelButtonList.get(i).setSelected(i == selectedIndex, false); |
|
|
|
|
} |
|
|
|
|
if (fireChanged) { |
|
|
|
|
fireStateChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -304,10 +311,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
|
|
|
|
|
* @param newSelectedIndex |
|
|
|
|
*/ |
|
|
|
|
public void setSelectedIndex(int newSelectedIndex) { |
|
|
|
|
selectedIndex = newSelectedIndex; |
|
|
|
|
for (int i = 0; i < labelButtonList.size(); i++) { |
|
|
|
|
labelButtonList.get(i).setSelected(i == selectedIndex); |
|
|
|
|
} |
|
|
|
|
setSelectedIndex(newSelectedIndex, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void fireStateChanged() { |
|
|
|
|