@ -85,7 +85,7 @@ public class CustomSortPane extends JPanel {
top . addActionListener ( e - > {
SwingUtilities . invokeLater ( ( ) - > {
sortItemPane . setComponentZOrder ( selectedLabel , 0 ) ;
setToolbarEnable ( false , false , true , true ) ;
setToolbarEnable ( sortItemPane . getComponentZOrder ( selectedLabel ) , sortItemPane . getComponentCount ( ) ) ;
CustomSortPane . this . revalidate ( ) ;
CustomSortPane . this . repaint ( ) ;
refreshCurrentOrder ( ) ;
@ -95,7 +95,7 @@ public class CustomSortPane extends JPanel {
bottom . addActionListener ( e - > {
SwingUtilities . invokeLater ( ( ) - > {
sortItemPane . setComponentZOrder ( selectedLabel , sortItemPane . getComponentCount ( ) - 1 ) ;
setToolbarEnable ( true , true , false , false ) ;
setToolbarEnable ( sortItemPane . getComponentZOrder ( selectedLabel ) , sortItemPane . getComponentCount ( ) ) ;
CustomSortPane . this . revalidate ( ) ;
CustomSortPane . this . repaint ( ) ;
refreshCurrentOrder ( ) ;
@ -105,7 +105,7 @@ public class CustomSortPane extends JPanel {
up . addActionListener ( e - > {
SwingUtilities . invokeLater ( ( ) - > {
sortItemPane . setComponentZOrder ( selectedLabel , sortItemPane . getComponentZOrder ( selectedLabel ) - 1 ) ;
setToolbarEnable ( true , true , true , true ) ;
setToolbarEnable ( sortItemPane . getComponentZOrder ( selectedLabel ) , sortItemPane . getComponentCount ( ) ) ;
CustomSortPane . this . revalidate ( ) ;
CustomSortPane . this . repaint ( ) ;
refreshCurrentOrder ( ) ;
@ -115,7 +115,7 @@ public class CustomSortPane extends JPanel {
down . addActionListener ( e - > {
SwingUtilities . invokeLater ( ( ) - > {
sortItemPane . setComponentZOrder ( selectedLabel , sortItemPane . getComponentZOrder ( selectedLabel ) + 1 ) ;
setToolbarEnable ( true , true , true , true ) ;
setToolbarEnable ( sortItemPane . getComponentZOrder ( selectedLabel ) , sortItemPane . getComponentCount ( ) ) ;
CustomSortPane . this . revalidate ( ) ;
CustomSortPane . this . repaint ( ) ;
refreshCurrentOrder ( ) ;
@ -175,6 +175,26 @@ public class CustomSortPane extends JPanel {
this . bottom . setEnabled ( bottom ) ;
}
/ * *
* 根据选项当前位置以及菜单大小设置 置顶 , 上移 , 下移 , 置底 按钮的状态
* /
private void setToolbarEnable ( int order , int maxOrder ) {
this . top . setEnabled ( true ) ;
this . up . setEnabled ( true ) ;
this . down . setEnabled ( true ) ;
this . bottom . setEnabled ( true ) ;
// 选项处于顶端,则置灰上移和置顶按钮
if ( order = = 0 ) {
this . top . setEnabled ( false ) ;
this . up . setEnabled ( false ) ;
}
// 选项处于底端,则置灰下移和置底按钮
if ( order = = maxOrder - 1 ) {
this . down . setEnabled ( false ) ;
this . bottom . setEnabled ( false ) ;
}
}
private void refreshCurrentOrder ( ) {
String [ ] currentTabOrder = parentPane . getCurrentOrder ( ) ;
HashSet < String > selectedTab = new HashSet < > ( ) ;