Java Code Examples for javax.swing.plaf.basic.BasicTabbedPaneUI

The following are top voted examples for showing how to use javax.swing.plaf.basic.BasicTabbedPaneUI. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij-ce-playground   File: TabbedPaneImpl.java   View source code 6 votes vote down vote up
/**
 * @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 2
Project: intellij-ce-playground   File: TabbedPaneImpl.java   View source code 6 votes vote down vote up
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 3
Project: tools-idea   File: TabbedPaneImpl.java   View source code 6 votes vote down vote up
/**
 * @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 4
Project: tools-idea   File: TabbedPaneImpl.java   View source code 6 votes vote down vote up
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 5
Project: com.opendoorlogistics   File: TablesPanel.java   View source code 6 votes vote down vote up
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);

}
 
Example 6
Project: consulo   File: TabbedPaneImpl.java   View source code 6 votes vote down vote up
/**
 * @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 7
Project: consulo   File: TabbedPaneImpl.java   View source code 6 votes vote down vote up
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 8
Project: JRLib   File: SubstanceTabbedPaneUI.java   View source code 6 votes vote down vote up
/**
 * 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 9
Project: incubator-netbeans   File: NBTabbedPaneController.java   View source code 5 votes vote down vote up
/**
 * 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 10
Project: rapidminer   File: TabbedPaneUI.java   View source code 5 votes vote down vote up
@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;
					}
				}
			}
		};
	}

}
 
Example 11
Project: jdk8u-jdk   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: openjdk-jdk10   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: openjdk9   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: jdk8u_jdk   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: lookaside_java-1.8.0-openjdk   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: intellij-ce-playground   File: TabbedPaneImpl.java   View source code 5 votes vote down vote up
@Override
public void setUI(final TabbedPaneUI ui){
  super.setUI(ui);
  if(ui instanceof BasicTabbedPaneUI){
    myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui);
  }else{
    myScrollableTabSupport=null;
  }
}
 
Example 17
Project: rapidminer-studio   File: TabbedPaneUI.java   View source code 5 votes vote down vote up
@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;
					}
				}
			}
		};
	}

}
 
Example 18
Project: infobip-open-jdk-8   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: jdk8u-dev-jdk   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: OLD-OpenJDK8   File: bug7010561.java   View source code 5 votes vote down vote up
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
Project: snap-desktop   File: BundleForm.java   View source code 5 votes vote down vote up
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 22
Project: snap-desktop   File: ToolAdapterTabbedEditorDialog.java   View source code 5 votes vote down vote up
@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 23
Project: tools-idea   File: TabbedPaneImpl.java   View source code 5 votes vote down vote up
@Override
public void setUI(final TabbedPaneUI ui){
  super.setUI(ui);
  if(ui instanceof BasicTabbedPaneUI){
    myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui);
  }else{
    myScrollableTabSupport=null;
  }
}
 
Example 24
Project: openjdk-jdk7u-jdk   File: bug7010561.java   View source code 5 votes vote down vote up
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 25
Project: openjdk-icedtea7   File: bug7010561.java   View source code 5 votes vote down vote up
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 26
Project: consulo   File: TabbedPaneImpl.java   View source code 5 votes vote down vote up
@Override
public void setUI(final TabbedPaneUI ui){
  super.setUI(ui);
  if(ui instanceof BasicTabbedPaneUI){
    myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui);
  }else{
    myScrollableTabSupport=null;
  }
}
 
Example 27
Project: marathonv5   File: JTabbedPaneTabJavaElement.java   View source code 4 votes vote down vote up
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 28
Project: Moenagade   File: MainFrame.java   View source code 4 votes vote down vote up
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);
}
 
Example 29
Project: intellij-ce-playground   File: TabbedPaneImpl.java   View source code 4 votes vote down vote up
public ScrollableTabSupport(final BasicTabbedPaneUI ui){
  myUI=ui;
}
 
Example 30
Project: HELMAntibodyEditor   File: AntibodyEditorGUI.java   View source code 4 votes vote down vote up
/**
 * 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();
}
 
Example 31
Project: MARS_Assembler   File: MainPane.java   View source code 4 votes vote down vote up
/**
  *  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);
                 } 
              }
           });
  }
 
Example 32
Project: cn1   File: JTabbedPaneTest.java   View source code 4 votes vote down vote up
public void testSetGetUI() {
    BasicTabbedPaneUI ui = new BasicTabbedPaneUI();
    tabbed.setUI(ui);
    assertSame(ui, tabbed.getUI());
}
 
Example 33
Project: tools-idea   File: TabbedPaneImpl.java   View source code 4 votes vote down vote up
public ScrollableTabSupport(final BasicTabbedPaneUI ui){
  myUI=ui;
}
 
Example 34
Project: freeVM   File: JTabbedPaneTest.java   View source code 4 votes vote down vote up
public void testSetGetUI() {
    BasicTabbedPaneUI ui = new BasicTabbedPaneUI();
    tabbed.setUI(ui);
    assertSame(ui, tabbed.getUI());
}
 
Example 35
Project: freeVM   File: JTabbedPaneTest.java   View source code 4 votes vote down vote up
public void testSetGetUI() {
    BasicTabbedPaneUI ui = new BasicTabbedPaneUI();
    tabbed.setUI(ui);
    assertSame(ui, tabbed.getUI());
}
 
Example 36
Project: consulo   File: TabbedPaneImpl.java   View source code 4 votes vote down vote up
public ScrollableTabSupport(final BasicTabbedPaneUI ui){
  myUI=ui;
}