Java examples for Swing:JButton
Returns a button to add to a panel in a tabbed pane.
/*/*w w w . j a va2 s .co 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. */ //package com.java2s; 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; } }