Java Code Examples for javax.swing.JTabbedPane#BOTTOM

The following examples show how to use javax.swing.JTabbedPane#BOTTOM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NBTabbedPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: TabsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: Switches.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: InnerTabsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;

}
 
Example 5
Source File: InnerTabsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: InnerTabsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 7
Source File: TabDisplayerFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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 );
}
 
Example 8
Source File: TabContainer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 );
}
 
Example 9
Source File: TabDataRenderer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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 );
    }
}
 
Example 10
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
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));
}
 
Example 11
Source File: BasicOutlookBarUI.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
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);
  }
}
 
Example 12
Source File: TabsPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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);
        }
    }
}
 
Example 13
Source File: TabTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public TabTable( TabDataModel tabModel, int tabsLocation ) {
    this( TabTableModel.create(tabModel, tabsLocation),
            tabsLocation == JTabbedPane.TOP || tabsLocation == JTabbedPane.BOTTOM ? JTabbedPane.HORIZONTAL : JTabbedPane.VERTICAL );
    this.tabsLocation = tabsLocation;
}
 
Example 14
Source File: AbstractTabDisplayer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 15
Source File: TabbedPaneBottomTabState.java    From seaglass with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    return (c instanceof JTabbedPane && ((JTabbedPane) c).getTabPlacement() == JTabbedPane.BOTTOM);
}