javax.swing.JTabbedPane#BOTTOM源码实例Demo

下面列出了javax.swing.JTabbedPane#BOTTOM 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: NBTabbedPane.java
/**
 * The index at which a tab should be inserted if a drop operation occurs at
 * this point.
 *
 * @param location A point anywhere on the TabbedContainer
 * @return A tab index, or -1
 */
public int dropIndexOfPoint( Point location ) {
    int index = indexAtLocation( location.x, location.y );
    if( index < 0 ) {
        index = getTabCount();
    } else if( index == getTabCount()-1 ) {
        Rectangle rect = getBoundsAt( index );
        if( getTabPlacement() == JTabbedPane.TOP || getTabPlacement() == JTabbedPane.BOTTOM ) {
            if( location.x > rect.x + rect.width/2 )
                index++;
        } else {
            if( location.y > rect.y + rect.height/2 )
                index++;
        }
    }

    return index;
}
 
源代码2 项目: netbeans   文件: TabsPanel.java
protected boolean store() {
    prefs.putBoolean(WinSysPrefs.EDITOR_CLOSE_ACTIVATES_RECENT, isCloseActivatesMostRecentDocument.isSelected());
    prefs.putBoolean(WinSysPrefs.OPEN_DOCUMENTS_NEXT_TO_ACTIVE_TAB, isNewDocumentOpensNextToActiveTab.isSelected());
    prefs.put(WinSysPrefs.EDITOR_SORT_TABS, getSelectedSortType().name());

    boolean needsWinsysRefresh = false;
    needsWinsysRefresh = checkMultiRow.isSelected() != defMultiRow;
    prefs.putBoolean(WinSysPrefs.DOCUMENT_TABS_MULTIROW, checkMultiRow.isSelected());

    int tabPlacement = JTabbedPane.TOP;
    if( radioBottom.isSelected() )
        tabPlacement = JTabbedPane.BOTTOM;
    else if( radioLeft.isSelected() )
        tabPlacement = JTabbedPane.LEFT;
    else if( radioRight.isSelected() )
        tabPlacement = JTabbedPane.RIGHT;
    prefs.putInt( WinSysPrefs.DOCUMENT_TABS_PLACEMENT, tabPlacement );
    needsWinsysRefresh |= tabPlacement != defTabPlacement;

    return needsWinsysRefresh;
}
 
源代码3 项目: netbeans   文件: Switches.java
/**
 * Defines the tab placement. The possible bundle values are <code>top</code>, <code>bottom</code>, <code>left</code>, <code>right</code>.
 * @return Tab placement when JTabbedPane implementation of Tab Control is
 * being used. The return value is one of <code>JTabbedPane.TOP</code> (default), <code>JTabbedPane.BOTTOM</code>,
 * <code>JTabbedPane.LEFT</code>, <code>JTabbedPane.RIGHT</code>.
 * 
 * @see JTabbedPane#getTabPlacement() 
 * 
 * @since 2.44
 */
public static int getSimpleTabsPlacement() {
    int result = JTabbedPane.TOP;
    try {
        String resValue = NbBundle.getMessage(Switches.class, "WinSys.TabControl.SimpleTabs.Placement" ); //NOI18N
        if( "bottom".equals( resValue ) )
            result = JTabbedPane.BOTTOM;
        else if( "right".equals( resValue ) )
            result = JTabbedPane.RIGHT;
        else if( "left".equals( resValue ) )
            result = JTabbedPane.LEFT;
    } catch( MissingResourceException mrE ) {
        //ignore
    }
    return result;
}
 
源代码4 项目: netbeans   文件: InnerTabsPanel.java
boolean store() {
    boolean changed = false;
    int placement = JTabbedPane.TOP;
    if( radioPlacementBottom.isSelected() ) {
        placement = JTabbedPane.BOTTOM;
    } else if( radioPlacementLeft.isSelected() ) {
        placement = JTabbedPane.LEFT;
    } else if( radioPlacementRight.isSelected() ) {
        placement = JTabbedPane.RIGHT;
    }
    changed |= settings.setTabsLocation( placement );
    changed |= settings.setShowFullPath( checkShowFullPath.isSelected() );
    changed |= settings.setSameProjectSameColor( checkProjectColors.isSelected() );

    int rowCount = 1;
    if( checkMultiRow.isSelected() && radioRowCount.isSelected() )
        rowCount = ((Number)spinRowCount.getValue()).intValue();
    changed |= settings.setRowCount( rowCount );
    changed |= settings.setTabRowPerProject( radioRowPerProject.isSelected() && checkMultiRow.isSelected() );

    changed |= settings.setShowFolderName( checkShowFolderName.isSelected() );
    changed |= settings.setSortDocumentListByProject( checkSortDocumentList.isSelected() );

    return changed;

}
 
源代码5 项目: netbeans   文件: InnerTabsPanel.java
private void fireChanged() {
    boolean isChanged = false;
    if (checkShowFolderName.isSelected() != settings.isShowFolderName()
            || checkShowFullPath.isSelected() != settings.isShowFullPath()
            || checkProjectColors.isSelected() != settings.isSameProjectSameColor()
            || checkSortDocumentList.isSelected() != settings.isSortDocumentListByProject()) {
        isChanged = true;
    }
    
    int rowCount = settings.getRowCount();
    if (checkMultiRow.isSelected() && radioRowCount.isSelected()) {
        rowCount = ((Number) spinRowCount.getValue()).intValue();
    }
    if (checkMultiRow.isSelected() != (rowCount > 1 || settings.isTabRowPerProject())) {
        isChanged = true;
    }
    if (rowCount != settings.getRowCount()) {
        isChanged = true;
    }
    if (radioRowPerProject.isSelected() != settings.isTabRowPerProject()) {
        isChanged = true;
    }
    
    if(radioPlacementBottom.isSelected() && settings.getTabsLocation() != JTabbedPane.BOTTOM
            || radioPlacementLeft.isSelected() && settings.getTabsLocation() != JTabbedPane.LEFT
            || radioPlacementRight.isSelected() && settings.getTabsLocation() != JTabbedPane.RIGHT
            || radioPlacementTop.isSelected() && settings.getTabsLocation() != JTabbedPane.TOP) {
        isChanged = true;
    }
    controller.changed(null, isChanged);
}
 
源代码6 项目: netbeans   文件: InnerTabsPanel.java
void load() {
    ProjectSupport projectSupport = ProjectSupport.getDefault();
    switch( settings.getTabsLocation() ) {
        case JTabbedPane.LEFT:
            radioPlacementLeft.setSelected( true );
            break;
        case JTabbedPane.RIGHT:
            radioPlacementRight.setSelected( true );
            break;
        case JTabbedPane.BOTTOM:
            radioPlacementBottom.setSelected( true );
            break;
        default:
            radioPlacementTop.setSelected( true );
    }
    checkShowFolderName.setSelected( settings.isShowFolderName() );
    checkShowFullPath.setSelected( settings.isShowFullPath() );
    checkProjectColors.setSelected( settings.isSameProjectSameColor() );
    checkSortDocumentList.setSelected( settings.isSortDocumentListByProject() );
    int rowCount = settings.getRowCount();
    checkMultiRow.setSelected( rowCount > 1 || settings.isTabRowPerProject() );
    if( rowCount > 1 )
        spinRowCount.getModel().setValue( Integer.valueOf( rowCount ) );
    radioRowPerProject.setSelected( settings.isTabRowPerProject() );
    radioRowCount.setSelected( rowCount > 1 );

    radioRowPerProject.setVisible( projectSupport.isEnabled() );
    checkProjectColors.setVisible( projectSupport.isEnabled() );
    checkSortDocumentList.setVisible( projectSupport.isEnabled() );

    enableControls();
}
 
源代码7 项目: netbeans   文件: TabDisplayerFactory.java
@Override
public TabDisplayer createTabDisplayer( TabDataModel tabModel, int orientation ) {
    Settings settings = Settings.getDefault();
    boolean multiRow = settings.getRowCount() > 1 || settings.isTabRowPerProject();
    if( multiRow && (orientation == JTabbedPane.TOP || orientation == JTabbedPane.BOTTOM) ) {
        if( settings.isTabRowPerProject() ) {
            return new RowPerProjectTabDisplayer( tabModel, orientation );
        }
        return new MultiRowTabDisplayer( tabModel, orientation );
    }
    return new SimpleTabDisplayer( tabModel, orientation );
}
 
源代码8 项目: netbeans   文件: TabContainer.java
TabContainer( TabbedImpl tabbedImpl, TabDisplayer tabDisplayer, int orientation ) {
    super( new BorderLayout(0, 0) );
    this.tabbedImpl = tabbedImpl;
    this.displayer = tabDisplayer;
    tcPanel = new JPanel( layout );
    add( tcPanel, BorderLayout.CENTER );
    tabbedImpl.getSelectionModel().addChangeListener( this );
    String lafId = UIManager.getLookAndFeel().getID();
    if( "Nimbus".equals( lafId ) ) {
        setBorder( new MatteBorder(1, 1, 1, 1, UIManager.getColor("nimbusBorder"))); //NOI18N
    } else if( "Aqua".equals( lafId ) ) {
        setBorder( BorderFactory.createEmptyBorder() );
    } else {
        setBorder( UIManager.getBorder( "Nb.ScrollPane.border" ) ); //NOI18N
    }
    switch( orientation ) {
        case JTabbedPane.TOP:
            add( displayer, BorderLayout.NORTH );
            break;
        case JTabbedPane.LEFT:
            add( displayer, BorderLayout.WEST );
            break;
        case JTabbedPane.RIGHT:
            add( displayer, BorderLayout.EAST );
            break;
        case JTabbedPane.BOTTOM:
            add( displayer, BorderLayout.SOUTH );
            break;
        default:
            throw new IllegalArgumentException( "Invalid orientation: " + orientation ); //NOI18N
    }
    stateChanged( null );
}
 
源代码9 项目: netbeans   文件: TabDataRenderer.java
@Override
public void paint( Graphics g ) {
    super.paint( g );
    Rectangle rect = getBounds();
    rect.x = 0;
    rect.y = 0;

    // paint underline selection
    if (isSelected && underlineHeight > 0 && underlineColor != null) {
        g.setColor(isActive || inactiveUnderlineColor == null
                ? underlineColor : inactiveUnderlineColor);
        switch (tabsLocation) {
            default:
            case JTabbedPane.TOP:
                g.fillRect(0, rect.height - underlineHeight, rect.width, underlineHeight);
                break;
            case JTabbedPane.BOTTOM:
                g.fillRect(0, 0, rect.width, underlineHeight);
                break;
            case JTabbedPane.LEFT:
                g.fillRect(rect.width - underlineHeight, 0, underlineHeight, rect.height);
                break;
            case JTabbedPane.RIGHT:
                g.fillRect(0, 0, underlineHeight, rect.height);
                break;
        }
    }

    // paint tab decorators
    for( TabDecorator td : decorators ) {
        td.paintAfter( tabData, g, rect, isSelected );
    }
}
 
源代码10 项目: pumpernickel   文件: BoxTabbedPaneUI.java
private Dimension getLayoutSize(Container parent, boolean preferred) {
	int tabPlacement = ((JTabbedPane) parent).getTabPlacement();
	boolean verticalPlacement = tabPlacement == JTabbedPane.TOP
			|| tabPlacement == JTabbedPane.BOTTOM;
	Dimension additional = new Dimension(0, 0);
	Dimension max = new Dimension(0, 0);
	for (int a = 0; a < parent.getComponentCount(); a++) {
		Component c = parent.getComponent(a);
		Dimension d = preferred ? c.getPreferredSize() : c
				.getMinimumSize();
		if (c instanceof UIResourcePanel) {
			if (verticalPlacement) {
				additional.height += d.height;
				additional.width = Math.max(additional.width, d.width);
			} else {
				additional.width += d.width;
				additional.height = Math.max(additional.height,
						d.height);
			}
		} else {
			max.width = Math.max(max.width, d.width);
			max.height = Math.max(max.height, d.height);
		}
	}
	if (verticalPlacement) {
		return new Dimension(Math.max(additional.width, max.width),
				additional.height + max.height);
	}
	return new Dimension(additional.width + max.width, Math.max(
			additional.height, max.height));
}
 
源代码11 项目: CodenameOne   文件: BasicOutlookBarUI.java
protected void updateTabLayoutOrientation() {
  TabLayout layout = (TabLayout)tabPane.getLayout();
  int placement = tabPane.getTabPlacement();
  if (placement == JTabbedPane.TOP || placement == JTabbedPane.BOTTOM) {
    layout.setOrientation(PercentLayout.HORIZONTAL);
  } else {
    layout.setOrientation(PercentLayout.VERTICAL);
  }
}
 
源代码12 项目: netbeans   文件: TabsPanel.java
protected void load() {
    isCloseActivatesMostRecentDocument.setSelected(prefs.getBoolean(WinSysPrefs.EDITOR_CLOSE_ACTIVATES_RECENT, true));
    isNewDocumentOpensNextToActiveTab.setSelected(prefs.getBoolean(WinSysPrefs.OPEN_DOCUMENTS_NEXT_TO_ACTIVE_TAB, false));
    EditorSortType sortType = EditorSortType.valueOf(prefs.get(WinSysPrefs.EDITOR_SORT_TABS, EditorSortType.None.name()));
    switch (sortType) {
        case FullFilePath:
            radioSortFullFilePath.setSelected(true);
            break;
        case FileName:
            radioSortFileName.setSelected(true);
            break;
        case FileNameWithParent:
            radioSortFileNameWithParent.setSelected(true);
            break;
        default:
            radioSortNothing.setSelected(true);
            break;
    }

    defMultiRow = prefs.getBoolean( WinSysPrefs.DOCUMENT_TABS_MULTIROW, false );
    checkMultiRow.setSelected( defMultiRow );
    defTabPlacement = prefs.getInt( WinSysPrefs.DOCUMENT_TABS_PLACEMENT, JTabbedPane.TOP );
    switch( defTabPlacement ) {
        case JTabbedPane.BOTTOM:
            radioBottom.setSelected( true );
            break;
        case JTabbedPane.LEFT:
            radioLeft.setSelected( true );
            break;
        case JTabbedPane.RIGHT:
            radioRight.setSelected( true );
            break;
        default:
            radioTop.setSelected( true );
    }

    if( isAquaLaF ) {
        checkMultiRow.setSelected(false);
        checkMultiRow.setEnabled(false);
        radioLeft.setEnabled(false);
        radioRight.setEnabled(false);
        if( radioLeft.isSelected() || radioRight.isSelected() ) {
            radioTop.setSelected(true);
        }
    }
}
 
源代码13 项目: netbeans   文件: TabTable.java
public TabTable( TabDataModel tabModel, int tabsLocation ) {
    this( TabTableModel.create(tabModel, tabsLocation),
            tabsLocation == JTabbedPane.TOP || tabsLocation == JTabbedPane.BOTTOM ? JTabbedPane.HORIZONTAL : JTabbedPane.VERTICAL );
    this.tabsLocation = tabsLocation;
}
 
源代码14 项目: netbeans   文件: AbstractTabDisplayer.java
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);
}
 
源代码15 项目: seaglass   文件: TabbedPaneBottomTabState.java
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    return (c instanceof JTabbedPane && ((JTabbedPane) c).getTabPlacement() == JTabbedPane.BOTTOM);
}