javax.swing.plaf.basic.BasicTabbedPaneUI源码实例Demo

类javax.swing.plaf.basic.BasicTabbedPaneUI源码实例Demo

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

源代码1 项目: FlatLaf   文件: FlatTabbedPaneUI.java
@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;
			}
		}
	};
}
 
源代码2 项目: radiance   文件: SubstanceTabbedPaneUI.java
/**
 * 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();
        }
    }
}
 
源代码3 项目: consulo   文件: TabbedPaneImpl.java
/**
 * @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);
  }
}
 
源代码4 项目: consulo   文件: TabbedPaneImpl.java
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);
  }
}
 
源代码5 项目: dragonwell8_jdk   文件: bug7010561.java
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");
        }
    });
}
 
源代码6 项目: TencentKona-8   文件: bug7010561.java
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");
        }
    });
}
 
源代码7 项目: jdk8u60   文件: bug7010561.java
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");
        }
    });
}
 
源代码8 项目: openjdk-jdk8u   文件: bug7010561.java
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");
        }
    });
}
 
源代码9 项目: netbeans   文件: NBTabbedPaneController.java
/**
 * 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
    }
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: bug7010561.java
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");
        }
    });
}
 
源代码11 项目: openjdk-jdk9   文件: bug7010561.java
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");
        }
    });
}
 
源代码12 项目: jdk8u-jdk   文件: bug7010561.java
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");
        }
    });
}
 
源代码13 项目: hottub   文件: bug7010561.java
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");
        }
    });
}
 
源代码14 项目: openjdk-8-source   文件: bug7010561.java
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");
        }
    });
}
 
源代码15 项目: openjdk-8   文件: bug7010561.java
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");
        }
    });
}
 
源代码16 项目: jdk8u_jdk   文件: bug7010561.java
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");
        }
    });
}
 
源代码17 项目: jdk8u-jdk   文件: bug7010561.java
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");
        }
    });
}
 
源代码18 项目: jdk8u-dev-jdk   文件: bug7010561.java
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");
        }
    });
}
 
源代码19 项目: snap-desktop   文件: BundleForm.java
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());
}
 
@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;
}
 
源代码21 项目: consulo   文件: TabbedPaneImpl.java
@Override
public void setUI(final TabbedPaneUI ui){
  super.setUI(ui);
  if(ui instanceof BasicTabbedPaneUI){
    myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui);
  }else{
    myScrollableTabSupport=null;
  }
}
 
源代码22 项目: FlatLaf   文件: FlatTabbedPaneUI.java
/**
 * 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 );
		}
	}
}
 
源代码23 项目: marathonv5   文件: JTabbedPaneTabJavaElement.java
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;
}
 
源代码24 项目: consulo   文件: TabbedPaneImpl.java
public ScrollableTabSupport(final BasicTabbedPaneUI ui){
  myUI=ui;
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 类方法
 同包方法