/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import javax.accessibility.*;
/**
* Class that manages a JLF awt.Window-descendant class's title bar.
* <p>
* This class assumes it will be created with a particular window
* decoration style, and that if the style changes, a new one will
* be created.
*
* @author Terry Kellerman
* @since 1.4
*/
/**
* PropertyChangeListener added to the JRootPane.
*/
/**
* JMenuBar, typically renders the system menu items.
*/
/**
* Action used to close the Window.
*/
/**
* Action used to iconify the Frame.
*/
/**
* Action to restore the Frame size.
*/
/**
* Action to restore the Frame size.
*/
/**
* Button used to maximize or restore the Frame.
*/
/**
* Button used to maximize or restore the Frame.
*/
/**
* Button used to maximize or restore the Frame.
*/
/**
* Icon used for toggleButton when window is normal size.
*/
/**
* Icon used for toggleButton when window is maximized.
*/
/**
* Image used for the system menu icon
*/
/**
* Listens for changes in the state of the Window listener to update
* the state of the widgets.
*/
/**
* Window we're currently in.
*/
/**
* JRootPane rendering for.
*/
/**
* Room remaining in title for bumps.
*/
private int buttonsWidth;
/**
* Buffered Frame.state property. As state isn't bound, this is kept
* to determine when to avoid updating widgets.
*/
private int state;
/**
* MetalRootPaneUI that created us.
*/
// Colors
// Bumps
rootPaneUI = ui;
state = -1;
}
/**
* Uninstalls the necessary state.
*/
private void uninstall() {
removeAll();
}
/**
* Installs the necessary listeners.
*/
private void installListeners() {
}
}
/**
* Uninstalls the necessary listeners.
*/
private void uninstallListeners() {
}
}
/**
* Returns the <code>WindowListener</code> to add to the
* <code>Window</code>.
*/
return new WindowHandler();
}
/**
* Returns the <code>PropertyChangeListener</code> to install on
* the <code>Window</code>.
*/
return new PropertyChangeHandler();
}
/**
* Returns the <code>JRootPane</code> this was created for.
*/
return rootPane;
}
/**
* Returns the decoration style of the <code>JRootPane</code>.
*/
private int getWindowDecorationStyle() {
return getRootPane().getWindowDecorationStyle();
}
public void addNotify() {
super.addNotify();
}
else {
setState(0);
}
}
}
public void removeNotify() {
super.removeNotify();
}
/**
* Adds any sub-Components contained in the <code>MetalTitlePane</code>.
*/
private void installSubcomponents() {
int decorationStyle = getWindowDecorationStyle();
menuBar = createMenuBar();
}
}
/**
* Determines the Colors to draw with.
*/
private void determineColors() {
switch (getWindowDecorationStyle()) {
break;
case JRootPane.ERROR_DIALOG:
"OptionPane.errorDialog.titlePane.background");
"OptionPane.errorDialog.titlePane.foreground");
"OptionPane.errorDialog.titlePane.shadow");
break;
case JRootPane.QUESTION_DIALOG:
case JRootPane.FILE_CHOOSER_DIALOG:
"OptionPane.questionDialog.titlePane.background");
"OptionPane.questionDialog.titlePane.foreground");
"OptionPane.questionDialog.titlePane.shadow");
break;
case JRootPane.WARNING_DIALOG:
"OptionPane.warningDialog.titlePane.background");
"OptionPane.warningDialog.titlePane.foreground");
"OptionPane.warningDialog.titlePane.shadow");
break;
case JRootPane.PLAIN_DIALOG:
case JRootPane.INFORMATION_DIALOG:
default:
break;
}
}
/**
* Installs the fonts and necessary properties on the MetalTitlePane.
*/
private void installDefaults() {
}
/**
* Uninstalls any previously installed UI values.
*/
private void uninstallDefaults() {
}
/**
* Returns the <code>JMenuBar</code> displaying the appropriate
* system menu items.
*/
menuBar = new SystemMenuBar();
menuBar.setFocusable(false);
menuBar.setBorderPainted(true);
return menuBar;
}
/**
* Closes the Window.
*/
private void close() {
}
}
/**
* Iconifies the Frame.
*/
private void iconify() {
}
}
/**
* Maximizes the Frame.
*/
private void maximize() {
}
}
/**
* Restores the Frame size.
*/
private void restore() {
return;
}
} else {
}
}
/**
* Create the <code>Action</code>s that get associated with the
* buttons and menu items.
*/
private void createActions() {
closeAction = new CloseAction();
iconifyAction = new IconifyAction();
restoreAction = new RestoreAction();
maximizeAction = new MaximizeAction();
}
}
/**
* Returns the <code>JMenu</code> displaying the appropriate menu items
* for manipulating the Frame.
*/
}
return menu;
}
/**
* Adds the necessary <code>JMenuItem</code>s to the passed in menu.
*/
if (mnemonic != -1) {
}
if (mnemonic != -1) {
}
Frame.MAXIMIZED_BOTH)) {
mnemonic =
if (mnemonic != -1) {
}
}
if (mnemonic != -1) {
}
}
/**
* Returns a <code>JButton</code> appropriate for placement on the
* TitlePane.
*/
button.setFocusPainted(false);
button.setFocusable(false);
return button;
}
/**
* Creates the Buttons that will be placed on the TitlePane.
*/
private void createButtons() {
"Close");
"Iconify");
"Maximize");
}
}
/**
* Returns the <code>LayoutManager</code> that should be installed on
* the <code>MetalTitlePane</code>.
*/
return new TitlePaneLayout();
}
/**
* Updates state dependant upon the Window's active state.
*/
}
// Repaint the whole thing as the Borders that are used have
// different colors for active vs inactive
getRootPane().repaint();
}
/**
* Sets the state of the Window.
*/
}
/**
* Sets the state of the window. If <code>updateRegardless</code> is
* true and the state has not changed, this will update anyway.
*/
return;
}
}
// This is a croak, if state becomes bound, this can
// be nuked.
}
if (frame.isResizable()) {
maximizeAction.setEnabled(false);
restoreAction.setEnabled(true);
}
else {
maximizeAction.setEnabled(true);
restoreAction.setEnabled(false);
}
revalidate();
repaint();
}
}
else {
maximizeAction.setEnabled(false);
restoreAction.setEnabled(false);
revalidate();
repaint();
}
}
}
else {
// Not contained in a Frame
maximizeAction.setEnabled(false);
restoreAction.setEnabled(false);
iconifyAction.setEnabled(false);
revalidate();
repaint();
}
closeAction.setEnabled(true);
}
}
/**
* Updates the toggle button to contain the Icon <code>icon</code>, and
* Action <code>action</code>.
*/
}
/**
* Returns the Frame rendering in. This will return null if the
* <code>JRootPane</code> is not contained in a <code>Frame</code>.
*/
}
return null;
}
/**
* Returns the <code>Window</code> the <code>JRootPane</code> is
* contained in. This will return null if there is no parent ancestor
* of the <code>JRootPane</code>.
*/
return window;
}
/**
* Returns the String to display as the title.
*/
if (w instanceof Frame) {
}
else if (w instanceof Dialog) {
}
return null;
}
/**
* Renders the TitlePane.
*/
// As state isn't bound, we need a convenience place to check
// if it has changed. Changing the state typically changes the
}
if (isSelected) {
bumps = activeBumps;
} else {
}
g.setColor(background);
g.setColor( darkShadow );
}
g.setColor(foreground);
}
int titleW;
if( leftToRight ) {
if (rect.x == 0) {
}
} else {
theTitle);
}
theTitle);
yOffset );
}
int bumpXOffset;
int bumpLength;
if( leftToRight ) {
} else {
}
int bumpYOffset = 3;
}
/**
* Actions used to <code>close</code> the <code>Window</code>.
*/
public CloseAction() {
getLocale()));
}
close();
}
}
/**
* Actions used to <code>iconfiy</code> the <code>Frame</code>.
*/
public IconifyAction() {
getLocale()));
}
iconify();
}
}
/**
* Actions used to <code>restore</code> the <code>Frame</code>.
*/
public RestoreAction() {
("MetalTitlePane.restoreTitle", getLocale()));
}
restore();
}
}
/**
* Actions used to <code>restore</code> the <code>Frame</code>.
*/
public MaximizeAction() {
getLocale()));
}
maximize();
}
}
/**
* Class responsible for drawing the system menu. Looks up the
* image to draw from the Frame associated with the
* <code>JRootPane</code>.
*/
if (isOpaque()) {
g.setColor(getBackground());
}
if (systemIcon != null) {
} else {
}
}
}
return getPreferredSize();
}
}
}
int height = computeHeight();
}
return preferredLayoutSize(c);
}
private int computeHeight() {
fontHeight += 7;
int iconHeight = 0;
}
return finalHeight;
}
int w = getWidth();
int x;
int y = 3;
int spacing;
int buttonHeight;
int buttonWidth;
}
else {
}
// assumes all buttons have the same dimensions
// these dimensions include the borders
x = leftToRight ? w : 0;
spacing = 5;
}
x = leftToRight ? w : 0;
spacing = 4;
if (closeButton != null) {
}
if( !leftToRight ) x += buttonWidth;
Frame.MAXIMIZED_BOTH)) {
spacing = 10;
if (!leftToRight) {
x += buttonWidth;
}
}
}
spacing = 2;
if (!leftToRight) {
x += buttonWidth;
}
}
}
buttonsWidth = leftToRight ? w - x : x;
}
}
/**
* PropertyChangeListener installed on the Window. Updates the necessary
* state as the state of the Window changes.
*/
// Frame.state isn't currently bound.
}
getRootPane().repaint();
}
}
repaint();
}
else if ("componentOrientation" == name) {
revalidate();
repaint();
}
else if ("iconImage" == name) {
revalidate();
repaint();
}
}
}
/**
* Update the image used for the system icon
*/
private void updateSystemIcon() {
systemIcon = null;
return;
}
systemIcon = null;
}
}
else {
}
}
/**
* WindowListener installed on the Window, updates the state as necessary.
*/
setActive(true);
}
setActive(false);
}
}
}