@ -28,6 +28,8 @@ import java.awt.Component;
import java.awt.Dimension ;
import java.awt.Dimension ;
import java.awt.GridLayout ;
import java.awt.GridLayout ;
import java.awt.Insets ;
import java.awt.Insets ;
import java.awt.event.AdjustmentEvent ;
import java.awt.event.AdjustmentListener ;
import java.util.List ;
import java.util.List ;
import static com.fine.swing.ui.layout.Layouts.cell ;
import static com.fine.swing.ui.layout.Layouts.cell ;
@ -50,6 +52,8 @@ public class UITableEditorPane<T> extends BasicPane {
protected UITableModelAdapter < T > tableModel ;
protected UITableModelAdapter < T > tableModel ;
private String leftLabelName ;
private String leftLabelName ;
private JPanel buttonPane ;
private JPanel buttonPane ;
protected JScrollPane scrollPane ;
protected JPanel verticalScrollBar ;
public UITableEditorPane ( UITableModelAdapter < T > model ) {
public UITableEditorPane ( UITableModelAdapter < T > model ) {
this . tableModel = model ;
this . tableModel = model ;
@ -99,18 +103,25 @@ public class UITableEditorPane<T> extends BasicPane {
* @param scrollPane
* @param scrollPane
* @return
* @return
* /
* /
protected Component buildScrollTablePane ( JScrollPane scrollPane ) {
protected JPanel buildScrollTablePane ( JScrollPane scrollPane ) {
return row (
verticalScrollBar = column (
cell ( scrollPane ) . weight ( 1 ) ,
cell ( new UILabel ( ) ) . with ( it - > {
column (
it . setBorder ( BorderFactory . createMatteBorder ( 1 , 0 , 0 , 1 , UIManager . getColor ( "defaultBorderColor" ) ) ) ;
cell ( new UILabel ( ) ) . with ( it - > {
it . setPreferredSize ( new Dimension ( scrollPane . getVerticalScrollBar ( ) . getWidth ( ) , ( int ) editTable . getTableHeader ( ) . getPreferredSize ( ) . getHeight ( ) ) ) ;
it . setBorder ( BorderFactory . createMatteBorder ( 1 , 0 , 0 , 1 , UIManager . getColor ( "defaultBorderColor" ) ) ) ;
} ) ,
it . setPreferredSize ( FineUIScale . scale ( new Dimension ( scrollPane . getVerticalScrollBar ( ) . getWidth ( ) , ( int ) editTable . getTableHeader ( ) . getPreferredSize ( ) . getHeight ( ) ) ) ) ;
cell ( scrollPane . getVerticalScrollBar ( ) ) . weight ( 1 ) . with ( it - > {
} ) ,
it . setBorder ( BorderFactory . createMatteBorder ( 1 , 0 , 1 , 1 , UIManager . getColor ( "defaultBorderColor" ) ) ) ;
cell ( scrollPane . getVerticalScrollBar ( ) ) . weight ( 1 ) . with ( it - > {
} )
it . setBorder ( BorderFactory . createMatteBorder ( 1 , 0 , 1 , 1 , UIManager . getColor ( "defaultBorderColor" ) ) ) ;
} ) )
) . getComponent ( ) ;
) . getComponent ( ) ;
scrollPane . getVerticalScrollBar ( ) . addAdjustmentListener ( new AdjustmentListener ( ) {
@Override
public void adjustmentValueChanged ( AdjustmentEvent e ) {
verticalScrollBar . setVisible ( editTable . getHeight ( ) > scrollPane . getViewport ( ) . getHeight ( ) ) ;
verticalScrollBar . repaint ( ) ;
}
} ) ;
return row ( cell ( scrollPane ) . weight ( 1 ) , cell ( verticalScrollBar ) ) . getComponent ( ) ;
}
}
public UITableModelAdapter < T > getTableModel ( ) {
public UITableModelAdapter < T > getTableModel ( ) {