javax.swing.plaf.basic.BasicTabbedPaneUI Java Examples
The following examples show how to use
javax.swing.plaf.basic.BasicTabbedPaneUI.
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: TabbedPaneImpl.java From consulo with Apache License 2.0 | 6 votes |
public void setLeadingTabIndex(final int leadingIndex) { try { final Field tabScrollerField = BasicTabbedPaneUI.class.getDeclaredField(TAB_SCROLLER_NAME); tabScrollerField.setAccessible(true); final Object tabScrollerValue = tabScrollerField.get(myUI); Method setLeadingIndexMethod = null; final Method[] methods = tabScrollerValue.getClass().getDeclaredMethods(); for (final Method method : methods) { if (SET_LEADING_TAB_INDEX_METHOD.equals(method.getName())) { setLeadingIndexMethod = method; break; } } if (setLeadingIndexMethod == null) { throw new IllegalStateException("method setLeadingTabIndex not found"); } setLeadingIndexMethod.setAccessible(true); setLeadingIndexMethod.invoke(tabScrollerValue, Integer.valueOf(getTabPlacement()), Integer.valueOf(leadingIndex)); } catch (Exception exc) { final String writer = StringUtil.getThrowableText(exc); throw new IllegalStateException("myUI=" + myUI + "; cause=" + writer); } }
Example #2
Source File: TabbedPaneImpl.java From consulo with Apache License 2.0 | 6 votes |
/** * @return value of <code>leadingTabIndex</code> field of BasicTabbedPaneUI.ScrollableTabSupport class. */ public int getLeadingTabIndex() { try { final Field tabScrollerField = BasicTabbedPaneUI.class.getDeclaredField(TAB_SCROLLER_NAME); tabScrollerField.setAccessible(true); final Object tabScrollerValue = tabScrollerField.get(myUI); final Field leadingTabIndexField = tabScrollerValue.getClass().getDeclaredField(LEADING_TAB_INDEX_NAME); leadingTabIndexField.setAccessible(true); return leadingTabIndexField.getInt(tabScrollerValue); } catch (Exception exc) { final String writer = StringUtil.getThrowableText(exc); throw new IllegalStateException("myUI=" + myUI + "; cause=" + writer); } }
Example #3
Source File: SubstanceTabbedPaneUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Ensures the current layout. */ protected void ensureCurrentLayout() { if (!this.tabPane.isValid()) { this.tabPane.validate(); } /* * If tabPane doesn't have a peer yet, the validate() call will silently fail. We handle * that by forcing a layout if tabPane is still invalid. See bug 4237677. */ if (!this.tabPane.isValid()) { LayoutManager lm = this.tabPane.getLayout(); if (lm instanceof BasicTabbedPaneUI.TabbedPaneLayout) { BasicTabbedPaneUI.TabbedPaneLayout layout = (BasicTabbedPaneUI.TabbedPaneLayout) lm; layout.calculateLayoutInfo(); } } }
Example #4
Source File: FlatTabbedPaneUI.java From FlatLaf with Apache License 2.0 | 6 votes |
@Override protected PropertyChangeListener createPropertyChangeListener() { return new BasicTabbedPaneUI.PropertyChangeHandler() { @Override public void propertyChange( PropertyChangeEvent e ) { super.propertyChange( e ); switch( e.getPropertyName() ) { case TABBED_PANE_SHOW_TAB_SEPARATORS: case TABBED_PANE_HAS_FULL_BORDER: case TABBED_PANE_TAB_HEIGHT: tabPane.revalidate(); tabPane.repaint(); break; } } }; }
Example #5
Source File: bug7010561.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #6
Source File: TabbedPaneImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setUI(final TabbedPaneUI ui){ super.setUI(ui); if(ui instanceof BasicTabbedPaneUI){ myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui); }else{ myScrollableTabSupport=null; } }
Example #7
Source File: ToolAdapterTabbedEditorDialog.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override protected JTabbedPane createMainPanel() { this.tabbedPane = new JTabbedPane(JTabbedPane.LEFT); this.tabbedPane.setBorder(BorderFactory.createEmptyBorder()); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); double widthRatio = 0.5; formWidth = Math.max((int) (screenSize.width * widthRatio), MIN_TABBED_WIDTH); double heightRatio = 0.5; int formHeight = Math.max((int) (screenSize.height * heightRatio), MIN_TABBED_HEIGHT); tabbedPane.setPreferredSize(new Dimension(formWidth, formHeight)); getJDialog().setMinimumSize(new Dimension(formWidth + 16, formHeight + 72)); addTab(tabbedPane, Bundle.CTL_Panel_OperatorDescriptor_Text(), createDescriptorTab()); currentIndex++; addTab(tabbedPane, Bundle.CTL_Panel_ConfigParams_Text(), createToolInfoPanel()); currentIndex++; addTab(tabbedPane, Bundle.CTL_Panel_PreProcessing_Border_TitleText(), createPreProcessingTab()); currentIndex++; addTab(tabbedPane, Bundle.CTL_Panel_OpParams_Border_TitleText(), createParametersTab(formWidth)); currentIndex++; addTab(tabbedPane, Bundle.CTL_Panel_SysVar_Border_TitleText(), createVariablesPanel()); currentIndex++; addTab(tabbedPane, Bundle.CTL_Panel_Bundle_TitleText(), createBundlePanel()); currentIndex++; tabbedPane.setUI(new BasicTabbedPaneUI()); formWidth = tabbedPane.getTabComponentAt(0).getWidth(); return tabbedPane; }
Example #8
Source File: BundleForm.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void buildUI() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); gbc.weighty = 0.01; addTab("Windows Bundle", createTab(OSFamily.windows)); addTab("Linux Bundle", createTab(OSFamily.linux)); addTab("MacOSX Bundle", createTab(OSFamily.macosx)); GridBagUtils.addToPanel(this, this.bundleTabPane, gbc, "gridx=0, gridy=0, gridwidth=11, weightx=1"); GridBagUtils.addToPanel(this, new JLabel("Reflect in Variable:"), gbc, "gridx=0, gridy=1, gridwidth=1, weightx=0"); variablesCombo = getEditorComponent(OSFamily.all, "updateVariable", this.variables.stream().map(SystemVariable::getKey).toArray()); GridBagUtils.addToPanel(this, variablesCombo, gbc, "gridx=1, gridy=1, gridwidth=10, weightx=0"); GridBagUtils.addToPanel(this, new JLabel(" "), gbc, "gridx=0, gridy=2, gridwidth=11, weighty=1"); int selected = 0; switch (Bundle.getCurrentOS()) { case windows: selected = 0; break; case linux: selected = 1; break; case macosx: selected = 2; break; } this.bundleTabPane.setSelectedIndex(selected); this.bundleTabPane.setUI(new BasicTabbedPaneUI()); }
Example #9
Source File: bug7010561.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #10
Source File: bug7010561.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #11
Source File: bug7010561.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #12
Source File: bug7010561.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #13
Source File: bug7010561.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #14
Source File: bug7010561.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #15
Source File: bug7010561.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #16
Source File: bug7010561.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #17
Source File: NBTabbedPaneController.java From netbeans with Apache License 2.0 | 5 votes |
/** * A hack to invoke rollover effect on tab header under mouse cursor when * the mouse is within the custom tab header component. * @param tabIndex */ private void makeRollover( int tabIndex ) { if( !(container.getUI() instanceof BasicTabbedPaneUI) ) { return; } BasicTabbedPaneUI ui = ( BasicTabbedPaneUI ) container.getUI(); try { Method m = container.getUI().getClass().getDeclaredMethod( "setRolloverTab", Integer.TYPE ); //NOI18N m.setAccessible( true ); m.invoke( ui, tabIndex ); } catch( Exception e ) { //ignore } }
Example #18
Source File: bug7010561.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #19
Source File: bug7010561.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #20
Source File: bug7010561.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #21
Source File: bug7010561.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SynthLookAndFeel()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tab 1", new JLabel("Tab 1")); // Ensure internal TabbedPane fields are initialized tabbedPane.doLayout(); BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI(); try { Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class, int.class, boolean.class); method.setAccessible(true); for (int i = 0; i < 4; i++) { int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0, IS_SELECTED[i])).intValue(); if (res != RETURN_VALUE[i]) { throw new RuntimeException("Test bug7010561 failed on index " + i); } } } catch (Exception e) { throw new RuntimeException(e); } System.out.println("Test bug7010561 passed"); } }); }
Example #22
Source File: JTabbedPaneTabJavaElement.java From marathonv5 with Apache License 2.0 | 4 votes |
private boolean makeTabVisible(JTabbedPane tp, int selectedTab) { validateTab(); if (!(tp.getUI() instanceof BasicTabbedPaneUI)) { try { EventQueueWait.call(tp, "setSelectedIndex", selectedTab); } catch (NoSuchMethodException e) { throw new InvalidElementStateException( "Unable to call setSelectedIndex on JTabbedPane. selectedTab = " + selectedTab, e); } return true; } boolean isVisible = false; int n = tp.getTabCount(); int loopCount = n; Action backward = tp.getActionMap().get("scrollTabsBackwardAction"); Action forward = tp.getActionMap().get("scrollTabsForwardAction"); while (!isVisible && loopCount-- > 0) { int firstVisibleTab = -1, lastVisibleTab = -1; for (int i = 0; i < n; i++) { Rectangle tabBounds = tp.getBoundsAt(i); int tabForCoordinate = tp.getUI().tabForCoordinate(tp, tabBounds.x + tabBounds.width / 2, tabBounds.y + tabBounds.height / 2); if (tabForCoordinate != -1) { if (firstVisibleTab == -1) { firstVisibleTab = tabForCoordinate; } lastVisibleTab = tabForCoordinate; } } isVisible = firstVisibleTab <= selectedTab && selectedTab <= lastVisibleTab; if (isVisible) { continue; } if (selectedTab < firstVisibleTab) { backward.actionPerformed(new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "")); } else { forward.actionPerformed(new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "")); } } return isVisible; }
Example #23
Source File: TabbedPaneImpl.java From consulo with Apache License 2.0 | 4 votes |
public ScrollableTabSupport(final BasicTabbedPaneUI ui){ myUI=ui; }
Example #24
Source File: FlatTabbedPaneUI.java From FlatLaf with Apache License 2.0 | 4 votes |
/** * Actually does nearly the same as super.paintContentBorder() but * - not using UIManager.getColor("TabbedPane.contentAreaColor") to be GUI builder friendly * - not invoking paintContentBorder*Edge() methods * - repaint selection */ @Override protected void paintContentBorder( Graphics g, int tabPlacement, int selectedIndex ) { if( tabPane.getTabCount() <= 0 ) return; Insets insets = tabPane.getInsets(); Insets tabAreaInsets = getTabAreaInsets( tabPlacement ); int x = insets.left; int y = insets.top; int w = tabPane.getWidth() - insets.right - insets.left; int h = tabPane.getHeight() - insets.top - insets.bottom; // remove tabs from bounds switch( tabPlacement ) { case LEFT: x += calculateTabAreaWidth( tabPlacement, runCount, maxTabWidth ); if( tabsOverlapBorder ) x -= tabAreaInsets.right; w -= (x - insets.left); break; case RIGHT: w -= calculateTabAreaWidth( tabPlacement, runCount, maxTabWidth ); if( tabsOverlapBorder ) w += tabAreaInsets.left; break; case BOTTOM: h -= calculateTabAreaHeight( tabPlacement, runCount, maxTabHeight ); if( tabsOverlapBorder ) h += tabAreaInsets.top; break; case TOP: default: y += calculateTabAreaHeight( tabPlacement, runCount, maxTabHeight ); if( tabsOverlapBorder ) y -= tabAreaInsets.bottom; h -= (y - insets.top); } // compute insets for separator or full border boolean hasFullBorder = clientPropertyBoolean( tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder ); int sh = scale( contentSeparatorHeight * 100 ); // multiply by 100 because rotateInsets() does not use floats Insets ci = new Insets( 0, 0, 0, 0 ); rotateInsets( hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 ), ci, tabPlacement ); // paint content area g.setColor( contentAreaColor ); Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD ); path.append( new Rectangle2D.Float( x, y, w, h ), false ); path.append( new Rectangle2D.Float( x + (ci.left / 100f), y + (ci.top / 100f), w - (ci.left / 100f) - (ci.right / 100f), h - (ci.top / 100f) - (ci.bottom / 100f) ), false ); ((Graphics2D)g).fill( path ); // repaint selection in scroll-tab-layout because it may be painted before // the content border was painted (from BasicTabbedPaneUI$ScrollableTabPanel) if( isScrollTabLayout() && selectedIndex >= 0 ) { Component scrollableTabViewport = findComponentByClassName( tabPane, BasicTabbedPaneUI.class.getName() + "$ScrollableTabViewport" ); if( scrollableTabViewport != null ) { Rectangle tabRect = getTabBounds( tabPane, selectedIndex ); Shape oldClip = g.getClip(); g.setClip( scrollableTabViewport.getBounds() ); paintTabSelection( g, tabPlacement, tabRect.x, tabRect.y, tabRect.width, tabRect.height ); g.setClip( oldClip ); } } }