Java JButton Settings newTabbedPaneButton(String text)

Here you can find the source of newTabbedPaneButton(String text)

Description

Returns a button to add to a panel in a tabbed pane.

License

BSD License

Return

A button to add to a JTabbedPane.

Declaration

public static JButton newTabbedPaneButton(String text) 

Method Source Code

//package com.java2s;
/*//from w w w . java 2 s  . c  o  m
 * 09/08/2005
 *
 * UIUtil.java - Utility methods for org.fife.ui classes.
 * Copyright (C) 2005 Robert Futrell
 * http://fifesoft.com/rtext
 * Licensed under a modified BSD license.
 * See the included license file for details.
 */

import javax.swing.JButton;

public class Main {
    private static int nonOpaqueTabbedPaneComponents = -1;

    /**
     * Returns a button to add to a panel in a tabbed pane.  This method
     * checks system properties to determine the operating system this JVM is
     * running in; if it is determined that this OS paints its tabbed panes
     * in a special way (such as the gradient tabbed panes in Windows XP),
     * then the button returned is not opaque.  Otherwise, a regular (opaque)
     * button is returned.
     *
     * @return A button to add to a <code>JTabbedPane</code>.
     * @see #newTabbedPanePanel()
     */
    public static JButton newTabbedPaneButton(String text) {
        JButton button = new JButton(text);
        if (getUseNonOpaqueTabbedPaneComponents())
            button.setOpaque(false);
        return button;
    }

    /**
     * Returns whether or not this operating system should use non-opaque
     * components in tabbed panes to show off, for example, a gradient effect.
     *
     * @return Whether or not non-opaque components should be used in tabbed
     *         panes.
     */
    static synchronized boolean getUseNonOpaqueTabbedPaneComponents() {

        if (nonOpaqueTabbedPaneComponents == -1) {

            // Check for Windows XP.
            String osname = System.getProperty("os.name");
            if (osname.toLowerCase().indexOf("windows") > -1) {
                String osver = System.getProperty("os.version");
                boolean isXPorVista = osver.startsWith("5.1") || osver.startsWith("6.0");
                nonOpaqueTabbedPaneComponents = isXPorVista ? 1 : 0;
            } else {
                nonOpaqueTabbedPaneComponents = 0;
            }

        }

        return nonOpaqueTabbedPaneComponents == 1 ? true : false;

    }
}

Related

  1. isScrollBarButton(AbstractButton button)
  2. isSelected(AbstractButton... buttons)
  3. isSelected(final AbstractButton abstractButton)
  4. isSelected(final AbstractButton abstractButton)
  5. lookupButton(Container c, String text)
  6. numberButtonGroup(ButtonGroup buttonGroup)
  7. opacityCheck(AbstractButton b)
  8. paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex)
  9. parseLevel(ButtonGroup buttonGroup)