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

项目:intellij-ce-playground    文件: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);
  }
}
项目:intellij-ce-playground    文件: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);
  }
}
项目:tools-idea    文件: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);
  }
}
项目:tools-idea    文件: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);
  }
}
项目:com.opendoorlogistics    文件:TablesPanel.java   
TablesPanel(ODLDatastoreUndoable<? extends ODLTableAlterable> globalDs) {
    this.globalDs = globalDs;
    setLayout(new BorderLayout());
    tabbedPane = new JTabbedPane();
    tabbedPane.setUI(new BasicTabbedPaneUI() {
        @Override
        protected int calculateTabAreaHeight(int tab_placement, int run_count, int max_tab_height) {
            // hide tab header if only one class selected
            if (tabbedPane.getTabCount() > 1)
                return super.calculateTabAreaHeight(tab_placement, run_count, max_tab_height);
            else
                return 0;
        }
    });
    add(tabbedPane, BorderLayout.CENTER);

    filteredDs = new RowFilterDecorator<>(globalDs);

}
项目: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);
  }
}
项目: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);
  }
}
项目:JRLib    文件: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();
        }
    }
}
项目:incubator-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
    }
}
项目:rapidminer    文件:TabbedPaneUI.java   
@Override
protected LayoutManager createLayoutManager() {
    if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) {
        // can't override because private class..
        return super.createLayoutManager();
    } else {
        // override for docking framework spacing fix!
        return new BasicTabbedPaneUI.TabbedPaneLayout() {

            @Override
            protected void calculateTabRects(int tabPlacement, int tabCount) {
                final int spacer = -5;
                final int indent = 0;

                super.calculateTabRects(tabPlacement, tabCount);

                for (int i = 1; i < rects.length; i++) {
                    // hack to get the tabs closer together. Don't shift leftmost tab(s)
                    if (rects[i].x > 0) {
                        rects[i].x += i * spacer + indent;
                    }
                }
            }
        };
    }

}
项目: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");
        }
    });
}
项目:openjdk-jdk10    文件: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");
        }
    });
}
项目:openjdk9    文件: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");
        }
    });
}
项目: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");
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件: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");
        }
    });
}
项目:intellij-ce-playground    文件:TabbedPaneImpl.java   
@Override
public void setUI(final TabbedPaneUI ui){
  super.setUI(ui);
  if(ui instanceof BasicTabbedPaneUI){
    myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui);
  }else{
    myScrollableTabSupport=null;
  }
}
项目:rapidminer-studio    文件:TabbedPaneUI.java   
@Override
protected LayoutManager createLayoutManager() {
    if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) {
        // can't override because private class..
        return super.createLayoutManager();
    } else {
        // override for docking framework spacing fix!
        return new BasicTabbedPaneUI.TabbedPaneLayout() {

            @Override
            protected void calculateTabRects(int tabPlacement, int tabCount) {
                final int spacer = -5;
                final int indent = 0;

                super.calculateTabRects(tabPlacement, tabCount);

                for (int i = 1; i < rects.length; i++) {
                    // hack to get the tabs closer together. Don't shift leftmost tab(s)
                    if (rects[i].x > 0) {
                        rects[i].x += i * spacer + indent;
                    }
                }
            }
        };
    }

}
项目:infobip-open-jdk-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");
        }
    });
}
项目: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");
        }
    });
}
项目:OLD-OpenJDK8    文件: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");
        }
    });
}
项目: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());
}
项目:snap-desktop    文件:ToolAdapterTabbedEditorDialog.java   
@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;
}
项目:tools-idea    文件:TabbedPaneImpl.java   
@Override
public void setUI(final TabbedPaneUI ui){
  super.setUI(ui);
  if(ui instanceof BasicTabbedPaneUI){
    myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui);
  }else{
    myScrollableTabSupport=null;
  }
}
项目:openjdk-jdk7u-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");
        }
    });
}
项目:openjdk-icedtea7    文件: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");
        }
    });
}
项目: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;
  }
}
项目: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;
}
项目:Moenagade    文件:MainFrame.java   
public void loadLibrary(String destination)
{
    // load the library
    Library library = Library.getInstance();
    library.load(destination);
    tabs.removeAll();

    // hide the tabs
    tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); //WRAP_TAB_LAYOUT || SCROLL_TAB_LAYOUT);
    tabs.setUI(new BasicTabbedPaneUI() {  
        @Override  
        protected int calculateTabAreaHeight(int tab_placement, int run_count, int max_tab_height) {  
            /*if (tabs.getTabCount() > 1)
                return super.calculateTabAreaHeight(tab_placement, run_count, max_tab_height);  
            else*/ 
                return 0;  
        }  
    });

    // jlist with colored items
    catList.setCellRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            Color col = (new BloxsDefinitions()).getColor(value.toString());
            if (col==null) col=Color.white;

            setBackground(col);
            if (isSelected) {
                 setBackground(getBackground().darker());
            }

            JPanel p = new JPanel();
            p.setLayout(new BorderLayout());
            p.setBorder(new LineBorder(col, 5));
            p.add(c,BorderLayout.CENTER);
            return p;
        }
    });
    //catList.setFixedCellHeight(50);
    //catList.setFixedCellWidth(100);



    Vector<String> names = new Vector<>();
    for (int i = 0; i < library.getTabs().size(); i++) {
        LibraryPanel ep = library.getTabs().get(i);
        // register the library for the mouse events
        // it will pass them on to the actual opened editor
        ep.addMouseListener(library);
        ep.addMouseMotionListener(library);
        ep.revalidate();
        JScrollPane scroll = new JScrollPane(ep);
        scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
        names.add(ep.getLabel());
        tabs.add(ep.getLabel(), scroll);
    }
    catList.setListData(names);
}
项目:intellij-ce-playground    文件:TabbedPaneImpl.java   
public ScrollableTabSupport(final BasicTabbedPaneUI ui){
  myUI=ui;
}
项目:HELMAntibodyEditor    文件:AntibodyEditorGUI.java   
/**
 * Constructor that creates the antibody editor GUI.
 * 
 * @param parentFrame
 */
protected AntibodyEditorGUI(JFrame parentFrame) {
  this.parentFrame = parentFrame;

  // create editor
  initLnF();

  parentFrame.setJMenuBar(createMenuBar());

  JPanel upperPanel = new JPanel();
  upperPanel.add(new JLabel("upper panel (curr. unused)"));

  JPanel antibodyPanel = new JPanel();
  antibodyPanel.setLayout(new BorderLayout());
  antibodyPanel.setPreferredSize(new Dimension(100, 10));
  JTabbedPane tabbedPane = new JTabbedPane();
  tabbedPane.setPreferredSize(new Dimension(100, 50));

  JPanel antibodyView = new JPanel();
  antibodyView.setLayout(new BorderLayout());
  antibodyView.setBackground(Color.WHITE);

  tabbedPane.add("Antibody View", antibodyView);
  tabbedPane.setUI(new BasicTabbedPaneUI() {
    @Override
    protected int calculateTabAreaHeight(int tab_placement, int run_count, int max_tab_height) {
      return 0;
    }
  });
  antibodyPanel.add(tabbedPane, BorderLayout.CENTER);

  // JSplitPane viewSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel,
  // antibodyPanel);
  UIService.getInstance().setAntibodyPanel(parentFrame, antibodyView);

  // viewSplitPane.setDividerLocation(50);
  // viewSplitPane.setOneTouchExpandable(false);

  // create buttons
  JPanel buttonPanel = createButtonPanel();
  UIService.getInstance().setToolBar(createToolBar());

  this.contentPanel = new JPanel();
  this.contentPanel.setLayout(new BorderLayout());
  // getContentPane().add(BorderLayout.CENTER, editor.getContentComponent());
  // this.contentPanel.add(viewSplitPane, BorderLayout.CENTER);
  this.contentPanel.add(UIService.getInstance().getToolBar(), BorderLayout.NORTH);
  this.contentPanel.add(antibodyPanel, BorderLayout.CENTER);
  this.contentPanel.add(buttonPanel, BorderLayout.SOUTH);

  PluginLoader.getInstance().loadMenuPlugins();
  PluginLoader.getInstance().loadToolbarPlugins();
}
项目:MARS_Assembler    文件:MainPane.java   
/**
  *  Constructor for the MainPane class. 
**/

   public MainPane(VenusUI appFrame, Editor editor, RegistersWindow regs,
                   Coprocessor1Window cop1Regs,Coprocessor0Window cop0Regs){
     super();
     this.mainUI = appFrame;
     this.setTabPlacement(JTabbedPane.TOP); //LEFT);
     if (this.getUI() instanceof BasicTabbedPaneUI) {
        BasicTabbedPaneUI ui = (BasicTabbedPaneUI) this.getUI();
     }
     editTabbedPane = new EditTabbedPane(appFrame, editor, this);
     executeTab = new ExecutePane(appFrame, regs, cop1Regs, cop0Regs);
     String editTabTitle = "Edit"; //"<html><center>&nbsp;<br>E<br>d<br>i<br>t<br>&nbsp;</center></html>";
     String executeTabTitle = "Execute"; //"<html><center>&nbsp;<br>E<br>x<br>e<br>c<br>u<br>t<br>e<br>&nbsp;</center></html>";
     Icon editTabIcon = null;//new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath+"Edit_tab.jpg")));
     Icon executeTabIcon = null;//new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath+"Execute_tab.jpg")));

     this.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
     this.addTab(editTabTitle, editTabIcon, editTabbedPane);

     // this.addTab("<html><center>&nbsp;<br>P<br>r<br>o<br>j<br>&nbsp;<br>1<br&nbsp;</center></html>", null, new JTabbedPane());   
     // this.addTab("<html><center>&nbsp;<br>P<br>r<br>o<br>j<br>&nbsp;<br>2<br&nbsp;</center></html>", null, new JTabbedPane());
     // this.addTab("<html><center>&nbsp;<br>P<br>r<br>o<br>j<br>&nbsp;<br>3<br&nbsp;</center></html>", null, new JTabbedPane());
     // this.addTab("<html><center>&nbsp;<br>P<br>r<br>o<br>j<br>&nbsp;<br>4<br&nbsp;</center></html>", null, new JTabbedPane());

     this.addTab(executeTabTitle, executeTabIcon, executeTab);

     this.setToolTipTextAt(0,"Text editor for composing MIPS programs.");
     this.setToolTipTextAt(1,"View and control assembly language program execution.  Enabled upon successful assemble.");

    /* Listener has one specific purpose: when Execute tab is selected for the 
     * first time, set the bounds of its internal frames by invoking the
     * setWindowsBounds() method.  Once this occurs, listener removes itself!
     * We do NOT want to reset bounds each time Execute tab is selected.
     * See ExecutePane.setWindowsBounds documentation for more details.
     */
     this.addChangeListener(
            new ChangeListener() {
               public void stateChanged(ChangeEvent ce) {
                 JTabbedPane tabbedPane = (JTabbedPane) ce.getSource();
                 int index = tabbedPane.getSelectedIndex();
                 Component c = tabbedPane.getComponentAt(index);
                 ExecutePane executePane = Globals.getGui().getMainPane().getExecutePane();
                 if (c == executePane) {
                    executePane.setWindowBounds();
                    Globals.getGui().getMainPane().removeChangeListener(this);
                 } 
              }
           });
  }
项目:cn1    文件:JTabbedPaneTest.java   
public void testSetGetUI() {
    BasicTabbedPaneUI ui = new BasicTabbedPaneUI();
    tabbed.setUI(ui);
    assertSame(ui, tabbed.getUI());
}
项目:tools-idea    文件:TabbedPaneImpl.java   
public ScrollableTabSupport(final BasicTabbedPaneUI ui){
  myUI=ui;
}
项目:freeVM    文件:JTabbedPaneTest.java   
public void testSetGetUI() {
    BasicTabbedPaneUI ui = new BasicTabbedPaneUI();
    tabbed.setUI(ui);
    assertSame(ui, tabbed.getUI());
}
项目:freeVM    文件:JTabbedPaneTest.java   
public void testSetGetUI() {
    BasicTabbedPaneUI ui = new BasicTabbedPaneUI();
    tabbed.setUI(ui);
    assertSame(ui, tabbed.getUI());
}
项目:consulo    文件:TabbedPaneImpl.java   
public ScrollableTabSupport(final BasicTabbedPaneUI ui){
  myUI=ui;
}