下面列出了javax.swing.JTabbedPane#HORIZONTAL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void autoscroll( Point cursorLocn ) {
Rectangle tabsArea = getTabsArea();
if( !tabsArea.contains( cursorLocn ) ) {
autoscroller.stop();
return;
}
if( orientation == JTabbedPane.HORIZONTAL ) {
if( cursorLocn.x < tabsArea.x+25 ) {
autoscroller.start( true );
} else if( cursorLocn.x > tabsArea.x+tabsArea.width-25 ) {
autoscroller.start( false );
} else {
autoscroller.stop();
}
} else {
if( cursorLocn.y < tabsArea.y+25 ) {
autoscroller.start( true );
} else if( cursorLocn.y > tabsArea.y+tabsArea.height-25 ) {
autoscroller.start( false );
} else {
autoscroller.stop();
}
}
}
@Override
public Insets getAutoscrollInsets() {
if( orientation == JTabbedPane.HORIZONTAL ) {
return new Insets( 0, 25, 0, 25 );
} else {
return new Insets( 25, 0, 25, 0 );
}
}
public TabTable( TabDataModel tabModel, int tabsLocation ) {
this( TabTableModel.create(tabModel, tabsLocation),
tabsLocation == JTabbedPane.TOP || tabsLocation == JTabbedPane.BOTTOM ? JTabbedPane.HORIZONTAL : JTabbedPane.VERTICAL );
this.tabsLocation = tabsLocation;
}
@Override
public boolean getScrollableTracksViewportHeight() {
return orientation == JTabbedPane.HORIZONTAL ? true : super.getScrollableTracksViewportHeight();
}
@Override
public boolean getScrollableTracksViewportWidth() {
return orientation == JTabbedPane.HORIZONTAL ? super.getScrollableTracksViewportHeight() : true;
}
private SingleRowTabTable( TabDataModel tabModel, ArrayList<Integer> tabIndexes ) {
super( TabTableModel.create( tabModel, tabIndexes ), JTabbedPane.HORIZONTAL );
this.tabIndexes = tabIndexes;
}
public AbstractTabDisplayer( final TabDataModel tabModel, int tabsLocation ) {
super( tabModel );
setLayout( new BorderLayout( 3, 3 ) );
this.orientation = tabsLocation == JTabbedPane.TOP || tabsLocation == JTabbedPane.BOTTOM ? JTabbedPane.HORIZONTAL : JTabbedPane.VERTICAL;
scrollPane = new JScrollPane();
controls = new ControlsToolbar();
lblFullPath.setBorder( BorderFactory.createEmptyBorder( 0, 3, 2, 3) );
Font defaultFont = lblFullPath.getFont();
lblFullPath.setFont( defaultFont.deriveFont( defaultFont.getSize2D()-2 ) );
JPanel controlsPanel = new JPanel( new BorderLayout() );
controlsPanel.setOpaque( false );
if( TabTableUI.IS_AQUA ) {
Color backColor = UIManager.getColor( "NbSplitPane.background" ); //NOI18N
if( null != backColor ) {
setBackground( backColor );
setOpaque( true );
}
Color white = Color.white;
white = white.darker();
lblFullPath.setForeground(white);
}
switch( tabsLocation ) {
case JTabbedPane.TOP:
case JTabbedPane.BOTTOM:
add( scrollPane, BorderLayout.CENTER );
controlsPanel.add( controls, BorderLayout.NORTH );
add( controlsPanel, BorderLayout.EAST );
if( Settings.getDefault().isShowFullPath() )
add( lblFullPath, BorderLayout.SOUTH );
break;
case JTabbedPane.LEFT:
case JTabbedPane.RIGHT:
add( scrollPane, BorderLayout.CENTER );
controlsPanel.add( controls, BorderLayout.EAST );
add( controlsPanel, BorderLayout.NORTH );
break;
default:
throw new IllegalArgumentException( "Invalid orientation: " + tabsLocation );
}
configureScrollPane( scrollPane );
scrollLeft = new ScrollAction( scrollPane, tabsLocation, true );
scrollRight = new ScrollAction( scrollPane, tabsLocation, false );
controls.add( ButtonFactory.createScrollLeftButton( scrollLeft ) );
controls.add( ButtonFactory.createScrollRightButton( scrollRight ) );
addMouseWheelListener( this );
projectsListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
repaint();
}
};
fullPathListener = new ChangeListener() {
@Override
public void stateChanged( ChangeEvent e ) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
updateFullPath();
}
});
}
};
tabModel.addChangeListener(fullPathListener);
}