feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,734 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.swing.SwingUtilities2;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
/**
* Factory object that can vend Icons appropriate for the basic L & F.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Amy Fowler
*/
public class MotifBorders {
public static class BevelBorder extends AbstractBorder implements UIResource {
private Color darkShadow = UIManager.getColor("controlShadow");
private Color lightShadow = UIManager.getColor("controlLtHighlight");
private boolean isRaised;
public BevelBorder(boolean isRaised, Color darkShadow, Color lightShadow) {
this.isRaised = isRaised;
this.darkShadow = darkShadow;
this.lightShadow = lightShadow;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.setColor((isRaised) ? lightShadow : darkShadow);
g.drawLine(x, y, x+w-1, y); // top
g.drawLine(x, y+h-1, x, y+1); // left
g.setColor((isRaised) ? darkShadow : lightShadow);
g.drawLine(x+1, y+h-1, x+w-1, y+h-1); // bottom
g.drawLine(x+w-1, y+h-1, x+w-1, y+1); // right
}
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(1, 1, 1, 1);
return insets;
}
public boolean isOpaque(Component c) {
return true;
}
}
public static class FocusBorder extends AbstractBorder implements UIResource {
private Color focus;
private Color control;
public FocusBorder(Color control, Color focus) {
this.control = control;
this.focus = focus;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if (c.hasFocus()) {
g.setColor(focus);
g.drawRect(x, y, w-1, h-1);
} else {
g.setColor(control);
g.drawRect(x, y, w-1, h-1);
}
}
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(1, 1, 1, 1);
return insets;
}
}
public static class ButtonBorder extends AbstractBorder implements UIResource {
protected Color focus = UIManager.getColor("activeCaptionBorder");
protected Color shadow = UIManager.getColor("Button.shadow");
protected Color highlight = UIManager.getColor("Button.light");
protected Color darkShadow;
public ButtonBorder(Color shadow, Color highlight, Color darkShadow, Color focus) {
this.shadow = shadow;
this.highlight = highlight;
this.darkShadow = darkShadow;
this.focus = focus;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
boolean isPressed = false;
boolean hasFocus = false;
boolean canBeDefault = false;
boolean isDefault = false;
if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c;
ButtonModel model = b.getModel();
isPressed = (model.isArmed() && model.isPressed());
hasFocus = (model.isArmed() && isPressed) ||
(b.isFocusPainted() && b.hasFocus());
if (b instanceof JButton) {
canBeDefault = ((JButton)b).isDefaultCapable();
isDefault = ((JButton)b).isDefaultButton();
}
}
int bx1 = x+1;
int by1 = y+1;
int bx2 = x+w-2;
int by2 = y+h-2;
if (canBeDefault) {
if (isDefault) {
g.setColor(shadow);
g.drawLine(x+3, y+3, x+3, y+h-4);
g.drawLine(x+3, y+3, x+w-4, y+3);
g.setColor(highlight);
g.drawLine(x+4, y+h-4, x+w-4, y+h-4);
g.drawLine(x+w-4, y+3, x+w-4, y+h-4);
}
bx1 +=6;
by1 += 6;
bx2 -= 6;
by2 -= 6;
}
if (hasFocus) {
g.setColor(focus);
if (isDefault) {
g.drawRect(x, y, w-1, h-1);
} else {
g.drawRect(bx1-1, by1-1, bx2-bx1+2, by2-by1+2);
}
}
g.setColor(isPressed? shadow : highlight);
g.drawLine(bx1, by1, bx2, by1);
g.drawLine(bx1, by1, bx1, by2);
g.setColor(isPressed? highlight : shadow);
g.drawLine(bx2, by1+1, bx2, by2);
g.drawLine(bx1+1, by2, bx2, by2);
}
public Insets getBorderInsets(Component c, Insets insets) {
int thickness = (c instanceof JButton && ((JButton)c).isDefaultCapable())? 8 : 2;
insets.set(thickness, thickness, thickness, thickness);
return insets;
}
}
public static class ToggleButtonBorder extends ButtonBorder {
public ToggleButtonBorder(Color shadow, Color highlight, Color darkShadow, Color focus) {
super(shadow, highlight, darkShadow, focus);
}
public void paintBorder(Component c, Graphics g, int x, int y,
int width, int height) {
if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c;
ButtonModel model = b.getModel();
if (model.isArmed() && model.isPressed() || model.isSelected()) {
drawBezel(g, x, y, width, height,
(model.isPressed() || model.isSelected()),
b.isFocusPainted() && b.hasFocus(), shadow, highlight, darkShadow, focus);
} else {
drawBezel(g, x, y, width, height,
false, b.isFocusPainted() && b.hasFocus(),
shadow, highlight, darkShadow, focus);
}
} else {
drawBezel(g, x, y, width, height, false, false,
shadow, highlight, darkShadow, focus);
}
}
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(2, 2, 3, 3);
return insets;
}
}
public static class MenuBarBorder extends ButtonBorder {
public MenuBarBorder(Color shadow, Color highlight, Color darkShadow, Color focus) {
super(shadow, highlight, darkShadow, focus);
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if (!(c instanceof JMenuBar)) {
return;
}
JMenuBar menuBar = (JMenuBar)c;
if (menuBar.isBorderPainted() == true) {
// this draws the MenuBar border
Dimension size = menuBar.getSize();
drawBezel(g,x,y,size.width,size.height,false,false,
shadow, highlight, darkShadow, focus);
}
}
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(6, 6, 6, 6);
return insets;
}
}
public static class FrameBorder extends AbstractBorder implements UIResource {
JComponent jcomp;
Color frameHighlight;
Color frameColor;
Color frameShadow;
// The width of the border
public final static int BORDER_SIZE = 5;
/** Constructs an FrameBorder for the JComponent <b>comp</b>.
*/
public FrameBorder(JComponent comp) {
jcomp = comp;
}
/** Sets the FrameBorder's JComponent.
*/
public void setComponent(JComponent comp) {
jcomp = comp;
}
/** Returns the FrameBorder's JComponent.
* @see #setComponent
*/
public JComponent component() {
return jcomp;
}
protected Color getFrameHighlight() {
return frameHighlight;
}
protected Color getFrameColor() {
return frameColor;
}
protected Color getFrameShadow() {
return frameShadow;
}
public Insets getBorderInsets(Component c, Insets newInsets) {
newInsets.set(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
return newInsets;
}
/** Draws the FrameBorder's top border.
*/
protected boolean drawTopBorder(Component c, Graphics g,
int x, int y, int width, int height) {
Rectangle titleBarRect = new Rectangle(x, y, width, BORDER_SIZE);
if (!g.getClipBounds().intersects(titleBarRect)) {
return false;
}
int maxX = width - 1;
int maxY = BORDER_SIZE - 1;
// Draw frame
g.setColor(frameColor);
g.drawLine(x, y + 2, maxX - 2, y + 2);
g.drawLine(x, y + 3, maxX - 2, y + 3);
g.drawLine(x, y + 4, maxX - 2, y + 4);
// Draw highlights
g.setColor(frameHighlight);
g.drawLine(x, y, maxX, y);
g.drawLine(x, y + 1, maxX, y + 1);
g.drawLine(x, y + 2, x, y + 4);
g.drawLine(x + 1, y + 2, x + 1, y + 4);
// Draw shadows
g.setColor(frameShadow);
g.drawLine(x + 4, y + 4, maxX - 4, y + 4);
g.drawLine(maxX, y + 1, maxX, maxY);
g.drawLine(maxX - 1, y + 2, maxX - 1, maxY);
return true;
}
/** Draws the FrameBorder's left border.
*/
protected boolean drawLeftBorder(Component c, Graphics g, int x, int y,
int width, int height) {
Rectangle borderRect =
new Rectangle(0, 0, getBorderInsets(c).left, height);
if (!g.getClipBounds().intersects(borderRect)) {
return false;
}
int startY = BORDER_SIZE;
g.setColor(frameHighlight);
g.drawLine(x, startY, x, height - 1);
g.drawLine(x + 1, startY, x + 1, height - 2);
g.setColor(frameColor);
g.fillRect(x + 2, startY, x + 2, height - 3);
g.setColor(frameShadow);
g.drawLine(x + 4, startY, x + 4, height - 5);
return true;
}
/** Draws the FrameBorder's right border.
*/
protected boolean drawRightBorder(Component c, Graphics g, int x, int y,
int width, int height) {
Rectangle borderRect = new Rectangle(
width - getBorderInsets(c).right, 0,
getBorderInsets(c).right, height);
if (!g.getClipBounds().intersects(borderRect)) {
return false;
}
int startX = width - getBorderInsets(c).right;
int startY = BORDER_SIZE;
g.setColor(frameColor);
g.fillRect(startX + 1, startY, 2, height - 1);
g.setColor(frameShadow);
g.fillRect(startX + 3, startY, 2, height - 1);
g.setColor(frameHighlight);
g.drawLine(startX, startY, startX, height - 1);
return true;
}
/** Draws the FrameBorder's bottom border.
*/
protected boolean drawBottomBorder(Component c, Graphics g, int x, int y,
int width, int height) {
Rectangle borderRect;
int marginHeight, startY;
borderRect = new Rectangle(0, height - getBorderInsets(c).bottom,
width, getBorderInsets(c).bottom);
if (!g.getClipBounds().intersects(borderRect)) {
return false;
}
startY = height - getBorderInsets(c).bottom;
g.setColor(frameShadow);
g.drawLine(x + 1, height - 1, width - 1, height - 1);
g.drawLine(x + 2, height - 2, width - 2, height - 2);
g.setColor(frameColor);
g.fillRect(x + 2, startY + 1, width - 4, 2);
g.setColor(frameHighlight);
g.drawLine(x + 5, startY, width - 5, startY);
return true;
}
// Returns true if the associated component has focus.
protected boolean isActiveFrame() {
return jcomp.hasFocus();
}
/** Draws the FrameBorder in the given Rect. Calls
* <b>drawTitleBar</b>, <b>drawLeftBorder</b>, <b>drawRightBorder</b> and
* <b>drawBottomBorder</b>.
*/
public void paintBorder(Component c, Graphics g,
int x, int y, int width, int height) {
if (isActiveFrame()) {
frameColor = UIManager.getColor("activeCaptionBorder");
} else {
frameColor = UIManager.getColor("inactiveCaptionBorder");
}
frameHighlight = frameColor.brighter();
frameShadow = frameColor.darker().darker();
drawTopBorder(c, g, x, y, width, height);
drawLeftBorder(c, g, x, y, width, height);
drawRightBorder(c, g, x, y, width, height);
drawBottomBorder(c, g, x, y, width, height);
}
}
public static class InternalFrameBorder extends FrameBorder {
JInternalFrame frame;
// The size of the bounding box for Motif frame corners.
public final static int CORNER_SIZE = 24;
/** Constructs an InternalFrameBorder for the InternalFrame
* <b>aFrame</b>.
*/
public InternalFrameBorder(JInternalFrame aFrame) {
super(aFrame);
frame = aFrame;
}
/** Sets the InternalFrameBorder's InternalFrame.
*/
public void setFrame(JInternalFrame aFrame) {
frame = aFrame;
}
/** Returns the InternalFrameBorder's InternalFrame.
* @see #setFrame
*/
public JInternalFrame frame() {
return frame;
}
/** Returns the width of the InternalFrameBorder's resize controls,
* appearing along the InternalFrameBorder's bottom border. Clicking
* and dragging within these controls lets the user change both the
* InternalFrame's width and height, while dragging between the controls
* constrains resizing to just the vertical dimension. Override this
* method if you implement your own bottom border painting and use a
* resize control with a different size.
*/
public int resizePartWidth() {
if (!frame.isResizable()) {
return 0;
}
return FrameBorder.BORDER_SIZE;
}
/** Draws the InternalFrameBorder's top border.
*/
protected boolean drawTopBorder(Component c, Graphics g,
int x, int y, int width, int height) {
if (super.drawTopBorder(c, g, x, y, width, height) &&
frame.isResizable()) {
g.setColor(getFrameShadow());
g.drawLine(CORNER_SIZE - 1, y + 1, CORNER_SIZE - 1, y + 4);
g.drawLine(width - CORNER_SIZE - 1, y + 1,
width - CORNER_SIZE - 1, y + 4);
g.setColor(getFrameHighlight());
g.drawLine(CORNER_SIZE, y, CORNER_SIZE, y + 4);
g.drawLine(width - CORNER_SIZE, y, width - CORNER_SIZE, y + 4);
return true;
}
return false;
}
/** Draws the InternalFrameBorder's left border.
*/
protected boolean drawLeftBorder(Component c, Graphics g, int x, int y,
int width, int height) {
if (super.drawLeftBorder(c, g, x, y, width, height) &&
frame.isResizable()) {
g.setColor(getFrameHighlight());
int topY = y + CORNER_SIZE;
g.drawLine(x, topY, x + 4, topY);
int bottomY = height - CORNER_SIZE;
g.drawLine(x + 1, bottomY, x + 5, bottomY);
g.setColor(getFrameShadow());
g.drawLine(x + 1, topY - 1, x + 5, topY - 1);
g.drawLine(x + 1, bottomY - 1, x + 5, bottomY - 1);
return true;
}
return false;
}
/** Draws the InternalFrameBorder's right border.
*/
protected boolean drawRightBorder(Component c, Graphics g, int x, int y,
int width, int height) {
if (super.drawRightBorder(c, g, x, y, width, height) &&
frame.isResizable()) {
int startX = width - getBorderInsets(c).right;
g.setColor(getFrameHighlight());
int topY = y + CORNER_SIZE;
g.drawLine(startX, topY, width - 2, topY);
int bottomY = height - CORNER_SIZE;
g.drawLine(startX + 1, bottomY, startX + 3, bottomY);
g.setColor(getFrameShadow());
g.drawLine(startX + 1, topY - 1, width - 2, topY - 1);
g.drawLine(startX + 1, bottomY - 1, startX + 3, bottomY - 1);
return true;
}
return false;
}
/** Draws the InternalFrameBorder's bottom border.
*/
protected boolean drawBottomBorder(Component c, Graphics g, int x, int y,
int width, int height) {
if (super.drawBottomBorder(c, g, x, y, width, height) &&
frame.isResizable()) {
int startY = height - getBorderInsets(c).bottom;
g.setColor(getFrameShadow());
g.drawLine(CORNER_SIZE - 1, startY + 1,
CORNER_SIZE - 1, height - 1);
g.drawLine(width - CORNER_SIZE, startY + 1,
width - CORNER_SIZE, height - 1);
g.setColor(getFrameHighlight());
g.drawLine(CORNER_SIZE, startY, CORNER_SIZE, height - 2);
g.drawLine(width - CORNER_SIZE + 1, startY,
width - CORNER_SIZE + 1, height - 2);
return true;
}
return false;
}
// Returns true if the associated internal frame has focus.
protected boolean isActiveFrame() {
return frame.isSelected();
}
}
public static void drawBezel(Graphics g, int x, int y, int w, int h,
boolean isPressed, boolean hasFocus,
Color shadow, Color highlight,
Color darkShadow, Color focus) {
Color oldColor = g.getColor();
g.translate(x, y);
if (isPressed) {
if (hasFocus){
g.setColor(focus);
g.drawRect(0, 0, w-1, h-1);
}
g.setColor(shadow); // inner border
g.drawRect(1, 1, w-3, h-3);
g.setColor(highlight); // inner 3D border
g.drawLine(2, h-3, w-3, h-3);
g.drawLine(w-3, 2, w-3, h-4);
} else {
if (hasFocus) {
g.setColor(focus);
g.drawRect(0, 0, w-1, h-1);
g.setColor(highlight); // inner 3D border
g.drawLine(1, 1, 1, h-3);
g.drawLine(2, 1, w-4, 1);
g.setColor(shadow);
g.drawLine(2, h-3, w-3, h-3);
g.drawLine(w-3, 1, w-3, h-4);
g.setColor(darkShadow); // black drop shadow __|
g.drawLine(1, h-2, w-2, h-2);
g.drawLine(w-2, h-2, w-2, 1);
} else {
g.setColor(highlight); // inner 3D border
g.drawLine(1,1,1,h-3);
g.drawLine(2,1,w-4,1);
g.setColor(shadow);
g.drawLine(2,h-3,w-3,h-3);
g.drawLine(w-3,1,w-3,h-4);
g.setColor(darkShadow); // black drop shadow __|
g.drawLine(1,h-2,w-2,h-2);
g.drawLine(w-2,h-2,w-2,0);
}
g.translate(-x, -y);
}
g.setColor(oldColor);
}
public static class MotifPopupMenuBorder extends AbstractBorder implements UIResource {
protected Font font;
protected Color background;
protected Color foreground;
protected Color shadowColor;
protected Color highlightColor;
// Space between the border and text
static protected final int TEXT_SPACING = 2;
// Space for the separator under the title
static protected final int GROOVE_HEIGHT = 2;
/**
* Creates a MotifPopupMenuBorder instance
*
*/
public MotifPopupMenuBorder(
Font titleFont,
Color bgColor,
Color fgColor,
Color shadow,
Color highlight) {
this.font = titleFont;
this.background = bgColor;
this.foreground = fgColor;
this.shadowColor = shadow;
this.highlightColor = highlight;
}
/**
* Paints the border for the specified component with the
* specified position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if (!(c instanceof JPopupMenu)) {
return;
}
Font origFont = g.getFont();
Color origColor = g.getColor();
JPopupMenu popup = (JPopupMenu)c;
String title = popup.getLabel();
if (title == null) {
return;
}
g.setFont(font);
FontMetrics fm = SwingUtilities2.getFontMetrics(popup, g, font);
int fontHeight = fm.getHeight();
int descent = fm.getDescent();
int ascent = fm.getAscent();
Point textLoc = new Point();
int stringWidth = SwingUtilities2.stringWidth(popup, fm,
title);
textLoc.y = y + ascent + TEXT_SPACING;
textLoc.x = x + ((width - stringWidth) / 2);
g.setColor(background);
g.fillRect(textLoc.x - TEXT_SPACING, textLoc.y - (fontHeight-descent),
stringWidth + (2 * TEXT_SPACING), fontHeight - descent);
g.setColor(foreground);
SwingUtilities2.drawString(popup, g, title, textLoc.x, textLoc.y);
MotifGraphicsUtils.drawGroove(g, x, textLoc.y + TEXT_SPACING,
width, GROOVE_HEIGHT,
shadowColor, highlightColor);
g.setFont(origFont);
g.setColor(origColor);
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
if (!(c instanceof JPopupMenu)) {
return insets;
}
FontMetrics fm;
int descent = 0;
int ascent = 16;
String title = ((JPopupMenu)c).getLabel();
if (title == null) {
insets.left = insets.top = insets.right = insets.bottom = 0;
return insets;
}
fm = c.getFontMetrics(font);
if(fm != null) {
descent = fm.getDescent();
ascent = fm.getAscent();
}
insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT;
return insets;
}
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.basic.*;
import javax.swing.event.*;
/**
* Button Listener
* <p>
*
* @author Rich Schiavi
*/
public class MotifButtonListener extends BasicButtonListener {
public MotifButtonListener(AbstractButton b ) {
super(b);
}
protected void checkOpacity(AbstractButton b) {
b.setOpaque( false );
}
}

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.*;
/**
* MotifButton implementation
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Rich Schiavi
*/
public class MotifButtonUI extends BasicButtonUI {
protected Color selectColor;
private boolean defaults_initialized = false;
private static final Object MOTIF_BUTTON_UI_KEY = new Object();
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifButtonUI motifButtonUI =
(MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY);
if (motifButtonUI == null) {
motifButtonUI = new MotifButtonUI();
appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI);
}
return motifButtonUI;
}
// ********************************
// Create Listeners
// ********************************
protected BasicButtonListener createButtonListener(AbstractButton b){
return new MotifButtonListener(b);
}
// ********************************
// Install Defaults
// ********************************
public void installDefaults(AbstractButton b) {
super.installDefaults(b);
if(!defaults_initialized) {
selectColor = UIManager.getColor(getPropertyPrefix() + "select");
defaults_initialized = true;
}
LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
}
protected void uninstallDefaults(AbstractButton b) {
super.uninstallDefaults(b);
defaults_initialized = false;
}
// ********************************
// Default Accessors
// ********************************
protected Color getSelectColor() {
return selectColor;
}
// ********************************
// Paint Methods
// ********************************
public void paint(Graphics g, JComponent c) {
fillContentArea( g, (AbstractButton)c , c.getBackground() );
super.paint(g,c);
}
// Overridden to ensure we don't paint icon over button borders.
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) {
Shape oldClip = g.getClip();
Rectangle newClip =
AbstractBorder.getInteriorRectangle(c, c.getBorder(), 0, 0,
c.getWidth(), c.getHeight());
Rectangle r = oldClip.getBounds();
newClip =
SwingUtilities.computeIntersection(r.x, r.y, r.width, r.height,
newClip);
g.setClip(newClip);
super.paintIcon(g, c, iconRect);
g.setClip(oldClip);
}
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
// focus painting is handled by the border
}
protected void paintButtonPressed(Graphics g, AbstractButton b) {
fillContentArea( g, b , selectColor );
}
protected void fillContentArea( Graphics g, AbstractButton b, Color fillColor) {
if (b.isContentAreaFilled()) {
Insets margin = b.getMargin();
Insets insets = b.getInsets();
Dimension size = b.getSize();
g.setColor(fillColor);
g.fillRect(insets.left - margin.left,
insets.top - margin.top,
size.width - (insets.left-margin.left) - (insets.right - margin.right),
size.height - (insets.top-margin.top) - (insets.bottom - margin.bottom));
}
}
}

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicButtonListener;
import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
import java.awt.*;
import java.awt.event.*;
/**
* MotifCheckboxMenuItem implementation
* <p>
*
* @author Georges Saab
* @author Rich Schiavi
*/
public class MotifCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI
{
protected ChangeListener changeListener;
public static ComponentUI createUI(JComponent b) {
return new MotifCheckBoxMenuItemUI();
}
protected void installListeners() {
super.installListeners();
changeListener = createChangeListener(menuItem);
menuItem.addChangeListener(changeListener);
}
protected void uninstallListeners() {
super.uninstallListeners();
menuItem.removeChangeListener(changeListener);
}
protected ChangeListener createChangeListener(JComponent c) {
return new ChangeHandler();
}
protected class ChangeHandler implements ChangeListener {
public void stateChanged(ChangeEvent e) {
JMenuItem c = (JMenuItem)e.getSource();
LookAndFeel.installProperty(c, "borderPainted", c.isArmed());
}
}
protected MouseInputListener createMouseInputListener(JComponent c) {
return new MouseInputHandler();
}
protected class MouseInputHandler implements MouseInputListener {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(getPath());
}
public void mouseReleased(MouseEvent e) {
MenuSelectionManager manager =
MenuSelectionManager.defaultManager();
JMenuItem menuItem = (JMenuItem)e.getComponent();
Point p = e.getPoint();
if(p.x >= 0 && p.x < menuItem.getWidth() &&
p.y >= 0 && p.y < menuItem.getHeight()) {
manager.clearSelectedPath();
menuItem.doClick(0);
} else {
manager.processMouseEvent(e);
}
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseDragged(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseMoved(MouseEvent e) { }
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.*;
import java.awt.*;
/**
* MotifCheckBox implementation
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Rich Schiavi
*/
public class MotifCheckBoxUI extends MotifRadioButtonUI {
private static final Object MOTIF_CHECK_BOX_UI_KEY = new Object();
private final static String propertyPrefix = "CheckBox" + ".";
private boolean defaults_initialized = false;
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifCheckBoxUI motifCheckBoxUI =
(MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY);
if (motifCheckBoxUI == null) {
motifCheckBoxUI = new MotifCheckBoxUI();
appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI);
}
return motifCheckBoxUI;
}
public String getPropertyPrefix() {
return propertyPrefix;
}
// ********************************
// Defaults
// ********************************
public void installDefaults(AbstractButton b) {
super.installDefaults(b);
if(!defaults_initialized) {
icon = UIManager.getIcon(getPropertyPrefix() + "icon");
defaults_initialized = true;
}
}
protected void uninstallDefaults(AbstractButton b) {
super.uninstallDefaults(b);
defaults_initialized = false;
}
}

View File

@@ -0,0 +1,361 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import java.io.Serializable;
import java.awt.event.*;
import java.beans.*;
/**
* ComboBox motif look and feel
* <p> * <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Arnaud Weber
*/
public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable {
Icon arrowIcon;
static final int HORIZ_MARGIN = 3;
public static ComponentUI createUI(JComponent c) {
return new MotifComboBoxUI();
}
public void installUI(JComponent c) {
super.installUI(c);
arrowIcon = new MotifComboBoxArrowIcon(UIManager.getColor("controlHighlight"),
UIManager.getColor("controlShadow"),
UIManager.getColor("control"));
Runnable initCode = new Runnable() {
public void run(){
if ( motifGetEditor() != null ) {
motifGetEditor().setBackground( UIManager.getColor( "text" ) );
}
}
};
SwingUtilities.invokeLater( initCode );
}
public Dimension getMinimumSize( JComponent c ) {
if ( !isMinimumSizeDirty ) {
return new Dimension( cachedMinimumSize );
}
Dimension size;
Insets insets = getInsets();
size = getDisplaySize();
size.height += insets.top + insets.bottom;
int buttonSize = iconAreaWidth();
size.width += insets.left + insets.right + buttonSize;
cachedMinimumSize.setSize( size.width, size.height );
isMinimumSizeDirty = false;
return size;
}
protected ComboPopup createPopup() {
return new MotifComboPopup( comboBox );
}
/**
* Overriden to empty the MouseMotionListener.
*/
protected class MotifComboPopup extends BasicComboPopup {
public MotifComboPopup( JComboBox comboBox ) {
super( comboBox );
}
/**
* Motif combo popup should not track the mouse in the list.
*/
public MouseMotionListener createListMouseMotionListener() {
return new MouseMotionAdapter() {};
}
public KeyListener createKeyListener() {
return super.createKeyListener();
}
protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
protected InvocationKeyHandler() {
MotifComboPopup.this.super();
}
}
}
protected void installComponents() {
if ( comboBox.isEditable() ) {
addEditor();
}
comboBox.add( currentValuePane );
}
protected void uninstallComponents() {
removeEditor();
comboBox.removeAll();
}
public void paint(Graphics g, JComponent c) {
boolean hasFocus = comboBox.hasFocus();
Rectangle r;
if (comboBox.isEnabled()) {
g.setColor(comboBox.getBackground());
} else {
g.setColor(UIManager.getColor("ComboBox.disabledBackground"));
}
g.fillRect(0,0,c.getWidth(),c.getHeight());
if ( !comboBox.isEditable() ) {
r = rectangleForCurrentValue();
paintCurrentValue(g,r,hasFocus);
}
r = rectangleForArrowIcon();
arrowIcon.paintIcon(c,g,r.x,r.y);
if ( !comboBox.isEditable() ) {
Border border = comboBox.getBorder();
Insets in;
if ( border != null ) {
in = border.getBorderInsets(comboBox);
}
else {
in = new Insets( 0, 0, 0, 0 );
}
// Draw the separation
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
r.x -= (HORIZ_MARGIN + 2);
}
else {
r.x += r.width + HORIZ_MARGIN + 1;
}
r.y = in.top;
r.width = 1;
r.height = comboBox.getBounds().height - in.bottom - in.top;
g.setColor(UIManager.getColor("controlShadow"));
g.fillRect(r.x,r.y,r.width,r.height);
r.x++;
g.setColor(UIManager.getColor("controlHighlight"));
g.fillRect(r.x,r.y,r.width,r.height);
}
}
public void paintCurrentValue(Graphics g,Rectangle bounds,boolean hasFocus) {
ListCellRenderer renderer = comboBox.getRenderer();
Component c;
Dimension d;
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
c.setFont(comboBox.getFont());
if ( comboBox.isEnabled() ) {
c.setForeground(comboBox.getForeground());
c.setBackground(comboBox.getBackground());
}
else {
c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
}
d = c.getPreferredSize();
currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
bounds.width,d.height);
}
protected Rectangle rectangleForArrowIcon() {
Rectangle b = comboBox.getBounds();
Border border = comboBox.getBorder();
Insets in;
if ( border != null ) {
in = border.getBorderInsets(comboBox);
}
else {
in = new Insets( 0, 0, 0, 0 );
}
b.x = in.left;
b.y = in.top;
b.width -= (in.left + in.right);
b.height -= (in.top + in.bottom);
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
b.x = b.x + b.width - HORIZ_MARGIN - arrowIcon.getIconWidth();
}
else {
b.x += HORIZ_MARGIN;
}
b.y = b.y + (b.height - arrowIcon.getIconHeight()) / 2;
b.width = arrowIcon.getIconWidth();
b.height = arrowIcon.getIconHeight();
return b;
}
protected Rectangle rectangleForCurrentValue() {
int width = comboBox.getWidth();
int height = comboBox.getHeight();
Insets insets = getInsets();
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
return new Rectangle(insets.left, insets.top,
(width - (insets.left + insets.right)) -
iconAreaWidth(),
height - (insets.top + insets.bottom));
}
else {
return new Rectangle(insets.left + iconAreaWidth(), insets.top,
(width - (insets.left + insets.right)) -
iconAreaWidth(),
height - (insets.top + insets.bottom));
}
}
public int iconAreaWidth() {
if ( comboBox.isEditable() )
return arrowIcon.getIconWidth() + (2 * HORIZ_MARGIN);
else
return arrowIcon.getIconWidth() + (3 * HORIZ_MARGIN) + 2;
}
public void configureEditor() {
super.configureEditor();
editor.setBackground( UIManager.getColor( "text" ) );
}
protected LayoutManager createLayoutManager() {
return new ComboBoxLayoutManager();
}
private Component motifGetEditor() {
return editor;
}
/**
* This inner class is marked &quot;public&quot; due to a compiler bug.
* This class should be treated as a &quot;protected&quot; inner class.
* Instantiate it only within subclasses of <FooUI>.
*/
public class ComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager {
public ComboBoxLayoutManager() {
MotifComboBoxUI.this.super();
}
public void layoutContainer(Container parent) {
if ( motifGetEditor() != null ) {
Rectangle cvb = rectangleForCurrentValue();
cvb.x += 1;
cvb.y += 1;
cvb.width -= 1;
cvb.height -= 2;
motifGetEditor().setBounds(cvb);
}
}
}
static class MotifComboBoxArrowIcon implements Icon, Serializable {
private Color lightShadow;
private Color darkShadow;
private Color fill;
public MotifComboBoxArrowIcon(Color lightShadow, Color darkShadow, Color fill) {
this.lightShadow = lightShadow;
this.darkShadow = darkShadow;
this.fill = fill;
}
public void paintIcon(Component c, Graphics g, int xo, int yo) {
int w = getIconWidth();
int h = getIconHeight();
g.setColor(lightShadow);
g.drawLine(xo, yo, xo+w-1, yo);
g.drawLine(xo, yo+1, xo+w-3, yo+1);
g.setColor(darkShadow);
g.drawLine(xo+w-2, yo+1, xo+w-1, yo+1);
for ( int x = xo+1, y = yo+2, dx = w-6; y+1 < yo+h; y += 2 ) {
g.setColor(lightShadow);
g.drawLine(x, y, x+1, y);
g.drawLine(x, y+1, x+1, y+1);
if ( dx > 0 ) {
g.setColor(fill);
g.drawLine(x+2, y, x+1+dx, y);
g.drawLine(x+2, y+1, x+1+dx, y+1);
}
g.setColor(darkShadow);
g.drawLine(x+dx+2, y, x+dx+3, y);
g.drawLine(x+dx+2, y+1, x+dx+3, y+1);
x += 1;
dx -= 2;
}
g.setColor(darkShadow);
g.drawLine(xo+(w/2), yo+h-1, xo+(w/2), yo+h-1);
}
public int getIconWidth() {
return 11;
}
public int getIconHeight() {
return 11;
}
}
/**
*{@inheritDoc}
*
* @since 1.6
*/
protected PropertyChangeListener createPropertyChangeListener() {
return new MotifPropertyChangeListener();
}
/**
* This class should be made &quot;protected&quot; in future releases.
*/
private class MotifPropertyChangeListener
extends BasicComboBoxUI.PropertyChangeHandler {
public void propertyChange(PropertyChangeEvent e) {
super.propertyChange(e);
String propertyName = e.getPropertyName();
if (propertyName == "enabled") {
if (comboBox.isEnabled()) {
Component editor = motifGetEditor();
if (editor != null) {
editor.setBackground(UIManager.getColor("text"));
}
}
}
}
}
}

View File

@@ -0,0 +1,375 @@
/*
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.swing.SwingUtilities2;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import java.beans.*;
import java.util.EventListener;
import java.io.Serializable;
import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.MouseEventAccessor;
/**
* Motif rendition of the component.
*
* @author Thomas Ball
* @author Rich Schiavi
*/
public class MotifDesktopIconUI extends BasicDesktopIconUI
{
protected DesktopIconActionListener desktopIconActionListener;
protected DesktopIconMouseListener desktopIconMouseListener;
protected Icon defaultIcon;
protected IconButton iconButton;
protected IconLabel iconLabel;
// This is only used for its system menu, but we need a reference to it so
// we can remove its listeners.
private MotifInternalFrameTitlePane sysMenuTitlePane;
JPopupMenu systemMenu;
EventListener mml;
final static int LABEL_HEIGHT = 18;
final static int LABEL_DIVIDER = 4; // padding between icon and label
final static Font defaultTitleFont =
new Font(Font.SANS_SERIF, Font.PLAIN, 12);
public static ComponentUI createUI(JComponent c) {
return new MotifDesktopIconUI();
}
public MotifDesktopIconUI() {
}
protected void installDefaults(){
super.installDefaults();
setDefaultIcon(UIManager.getIcon("DesktopIcon.icon"));
iconButton = createIconButton(defaultIcon);
// An underhanded way of creating a system popup menu.
sysMenuTitlePane = new MotifInternalFrameTitlePane(frame);
systemMenu = sysMenuTitlePane.getSystemMenu();
MotifBorders.FrameBorder border = new MotifBorders.FrameBorder(desktopIcon);
desktopIcon.setLayout(new BorderLayout());
iconButton.setBorder(border);
desktopIcon.add(iconButton, BorderLayout.CENTER);
iconLabel = createIconLabel(frame);
iconLabel.setBorder(border);
desktopIcon.add(iconLabel, BorderLayout.SOUTH);
desktopIcon.setSize(desktopIcon.getPreferredSize());
desktopIcon.validate();
JLayeredPane.putLayer(desktopIcon, JLayeredPane.getLayer(frame));
}
protected void installComponents(){
}
protected void uninstallComponents(){
}
protected void installListeners(){
super.installListeners();
desktopIconActionListener = createDesktopIconActionListener();
desktopIconMouseListener = createDesktopIconMouseListener();
iconButton.addActionListener(desktopIconActionListener);
iconButton.addMouseListener(desktopIconMouseListener);
iconLabel.addMouseListener(desktopIconMouseListener);
}
JInternalFrame.JDesktopIcon getDesktopIcon(){
return desktopIcon;
}
void setDesktopIcon(JInternalFrame.JDesktopIcon d){
desktopIcon = d;
}
JInternalFrame getFrame(){
return frame;
}
void setFrame(JInternalFrame f){
frame = f ;
}
protected void showSystemMenu(){
systemMenu.show(iconButton, 0, getDesktopIcon().getHeight());
}
protected void hideSystemMenu(){
systemMenu.setVisible(false);
}
protected IconLabel createIconLabel(JInternalFrame frame){
return new IconLabel(frame);
}
protected IconButton createIconButton(Icon i){
return new IconButton(i);
}
protected DesktopIconActionListener createDesktopIconActionListener(){
return new DesktopIconActionListener();
}
protected DesktopIconMouseListener createDesktopIconMouseListener(){
return new DesktopIconMouseListener();
}
protected void uninstallDefaults(){
super.uninstallDefaults();
desktopIcon.setLayout(null);
desktopIcon.remove(iconButton);
desktopIcon.remove(iconLabel);
}
protected void uninstallListeners(){
super.uninstallListeners();
iconButton.removeActionListener(desktopIconActionListener);
iconButton.removeMouseListener(desktopIconMouseListener);
sysMenuTitlePane.uninstallListeners();
}
public Dimension getMinimumSize(JComponent c) {
JInternalFrame iframe = desktopIcon.getInternalFrame();
int w = defaultIcon.getIconWidth();
int h = defaultIcon.getIconHeight() + LABEL_HEIGHT + LABEL_DIVIDER;
Border border = iframe.getBorder();
if(border != null) {
w += border.getBorderInsets(iframe).left +
border.getBorderInsets(iframe).right;
h += border.getBorderInsets(iframe).bottom +
border.getBorderInsets(iframe).top;
}
return new Dimension(w, h);
}
public Dimension getPreferredSize(JComponent c) {
return getMinimumSize(c);
}
public Dimension getMaximumSize(JComponent c){
return getMinimumSize(c);
}
/**
* Returns the default desktop icon.
*/
public Icon getDefaultIcon() {
return defaultIcon;
}
/**
* Sets the icon used as the default desktop icon.
*/
public void setDefaultIcon(Icon newIcon) {
defaultIcon = newIcon;
}
protected class IconLabel extends JPanel {
JInternalFrame frame;
IconLabel(JInternalFrame f) {
super();
this.frame = f;
setFont(defaultTitleFont);
// Forward mouse events to titlebar for moves.
addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseMoved(MouseEvent e) {
forwardEventToParent(e);
}
});
addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
forwardEventToParent(e);
}
public void mousePressed(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseReleased(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseEntered(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseExited(MouseEvent e) {
forwardEventToParent(e);
}
});
}
void forwardEventToParent(MouseEvent e) {
MouseEvent newEvent = new MouseEvent(
getParent(), e.getID(), e.getWhen(), e.getModifiers(),
e.getX(), e.getY(), e.getXOnScreen(),
e.getYOnScreen(), e.getClickCount(),
e.isPopupTrigger(), MouseEvent.NOBUTTON);
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
meAccessor.setCausedByTouchEvent(newEvent,
meAccessor.isCausedByTouchEvent(e));
getParent().dispatchEvent(newEvent);
}
public boolean isFocusTraversable() {
return false;
}
public Dimension getMinimumSize() {
return new Dimension(defaultIcon.getIconWidth() + 1,
LABEL_HEIGHT + LABEL_DIVIDER);
}
public Dimension getPreferredSize() {
String title = frame.getTitle();
FontMetrics fm = frame.getFontMetrics(defaultTitleFont);
int w = 4;
if (title != null) {
w += SwingUtilities2.stringWidth(frame, fm, title);
}
return new Dimension(w, LABEL_HEIGHT + LABEL_DIVIDER);
}
public void paint(Graphics g) {
super.paint(g);
// touch-up frame
int maxX = getWidth() - 1;
Color shadow =
UIManager.getColor("inactiveCaptionBorder").darker().darker();
g.setColor(shadow);
g.setClip(0, 0, getWidth(), getHeight());
g.drawLine(maxX - 1, 1, maxX - 1, 1);
g.drawLine(maxX, 0, maxX, 0);
// fill background
g.setColor(UIManager.getColor("inactiveCaption"));
g.fillRect(2, 1, maxX - 3, LABEL_HEIGHT + 1);
// draw text -- clipping to truncate text like CDE/Motif
g.setClip(2, 1, maxX - 4, LABEL_HEIGHT);
int y = LABEL_HEIGHT - SwingUtilities2.getFontMetrics(frame, g).
getDescent();
g.setColor(UIManager.getColor("inactiveCaptionText"));
String title = frame.getTitle();
if (title != null) {
SwingUtilities2.drawString(frame, g, title, 4, y);
}
}
}
protected class IconButton extends JButton {
Icon icon;
IconButton(Icon icon) {
super(icon);
this.icon = icon;
// Forward mouse events to titlebar for moves.
addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseMoved(MouseEvent e) {
forwardEventToParent(e);
}
});
addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
forwardEventToParent(e);
}
public void mousePressed(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseReleased(MouseEvent e) {
if (!systemMenu.isShowing()) {
forwardEventToParent(e);
}
}
public void mouseEntered(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseExited(MouseEvent e) {
forwardEventToParent(e);
}
});
}
void forwardEventToParent(MouseEvent e) {
MouseEvent newEvent = new MouseEvent(
getParent(), e.getID(), e.getWhen(), e.getModifiers(),
e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(),
e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON );
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
meAccessor.setCausedByTouchEvent(newEvent,
meAccessor.isCausedByTouchEvent(e));
getParent().dispatchEvent(newEvent);
}
public boolean isFocusTraversable() {
return false;
}
}
protected class DesktopIconActionListener implements ActionListener {
public void actionPerformed(ActionEvent e){
systemMenu.show(iconButton, 0, getDesktopIcon().getHeight());
}
}
protected class DesktopIconMouseListener extends MouseAdapter {
// if we drag or move we should deengage the popup
public void mousePressed(MouseEvent e){
if (e.getClickCount() > 1) {
try {
getFrame().setIcon(false);
} catch (PropertyVetoException e2){ }
systemMenu.setVisible(false);
/* the mouse release will not get reported correctly,
because the icon will no longer be in the hierarchy;
maybe that should be fixed, but until it is, we need
to do the required cleanup here. */
getFrame().getDesktopPane().getDesktopManager().endDraggingFrame((JComponent)e.getSource());
}
}
}
}

View File

@@ -0,0 +1,267 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Component;
import java.awt.Point;
import javax.swing.plaf.*;
import java.io.Serializable;
/**
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author David Kloba
*/
public class MotifDesktopPaneUI extends javax.swing.plaf.basic.BasicDesktopPaneUI
{
/// DesktopPaneUI methods
public static ComponentUI createUI(JComponent d) {
return new MotifDesktopPaneUI();
}
public MotifDesktopPaneUI() {
}
protected void installDesktopManager() {
desktopManager = desktop.getDesktopManager();
if(desktopManager == null) {
desktopManager = new MotifDesktopManager();
desktop.setDesktopManager(desktopManager);
((MotifDesktopManager)desktopManager).adjustIcons(desktop);
}
}
public Insets getInsets(JComponent c) {return new Insets(0,0,0,0);}
////////////////////////////////////////////////////////////////////////////////////
/// DragPane class
////////////////////////////////////////////////////////////////////////////////////
private class DragPane extends JComponent {
public void paint(Graphics g) {
g.setColor(Color.darkGray);
g.drawRect(0, 0, getWidth()-1, getHeight()-1);
}
};
////////////////////////////////////////////////////////////////////////////////////
/// MotifDesktopManager class
////////////////////////////////////////////////////////////////////////////////////
private class MotifDesktopManager extends DefaultDesktopManager implements Serializable, UIResource {
JComponent dragPane;
boolean usingDragPane = false;
private transient JLayeredPane layeredPaneForDragPane;
int iconWidth, iconHeight;
// PENDING(klobad) this should be optimized
public void setBoundsForFrame(JComponent f, int newX, int newY,
int newWidth, int newHeight) {
if(!usingDragPane) {
boolean didResize;
didResize = (f.getWidth() != newWidth || f.getHeight() != newHeight);
Rectangle r = f.getBounds();
f.setBounds(newX, newY, newWidth, newHeight);
SwingUtilities.computeUnion(newX, newY, newWidth, newHeight, r);
f.getParent().repaint(r.x, r.y, r.width, r.height);
if(didResize) {
f.validate();
}
} else {
Rectangle r = dragPane.getBounds();
dragPane.setBounds(newX, newY, newWidth, newHeight);
SwingUtilities.computeUnion(newX, newY, newWidth, newHeight, r);
dragPane.getParent().repaint(r.x, r.y, r.width, r.height);
}
}
public void beginDraggingFrame(JComponent f) {
usingDragPane = false;
if(f.getParent() instanceof JLayeredPane) {
if(dragPane == null)
dragPane = new DragPane();
layeredPaneForDragPane = (JLayeredPane)f.getParent();
layeredPaneForDragPane.setLayer(dragPane, Integer.MAX_VALUE);
dragPane.setBounds(f.getX(), f.getY(), f.getWidth(), f.getHeight());
layeredPaneForDragPane.add(dragPane);
usingDragPane = true;
}
}
public void dragFrame(JComponent f, int newX, int newY) {
setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight());
}
public void endDraggingFrame(JComponent f) {
if(usingDragPane) {
layeredPaneForDragPane.remove(dragPane);
usingDragPane = false;
if (f instanceof JInternalFrame) {
setBoundsForFrame(f, dragPane.getX(), dragPane.getY(),
dragPane.getWidth(), dragPane.getHeight());
} else if (f instanceof JInternalFrame.JDesktopIcon) {
adjustBoundsForIcon((JInternalFrame.JDesktopIcon)f,
dragPane.getX(), dragPane.getY());
}
}
}
public void beginResizingFrame(JComponent f, int direction) {
usingDragPane = false;
if(f.getParent() instanceof JLayeredPane) {
if(dragPane == null)
dragPane = new DragPane();
JLayeredPane p = (JLayeredPane)f.getParent();
p.setLayer(dragPane, Integer.MAX_VALUE);
dragPane.setBounds(f.getX(), f.getY(),
f.getWidth(), f.getHeight());
p.add(dragPane);
usingDragPane = true;
}
}
public void resizeFrame(JComponent f, int newX, int newY,
int newWidth, int newHeight) {
setBoundsForFrame(f, newX, newY, newWidth, newHeight);
}
public void endResizingFrame(JComponent f) {
if(usingDragPane) {
JLayeredPane p = (JLayeredPane)f.getParent();
p.remove(dragPane);
usingDragPane = false;
setBoundsForFrame(f, dragPane.getX(), dragPane.getY(),
dragPane.getWidth(), dragPane.getHeight());
}
}
public void iconifyFrame(JInternalFrame f) {
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
Point p = icon.getLocation();
adjustBoundsForIcon(icon, p.x, p.y);
super.iconifyFrame(f);
}
/**
* Change positions of icons in the desktop pane so that
* they do not overlap
*/
protected void adjustIcons(JDesktopPane desktop) {
// We need to know Motif icon size
JInternalFrame.JDesktopIcon icon = new JInternalFrame.JDesktopIcon(
new JInternalFrame());
Dimension iconSize = icon.getPreferredSize();
iconWidth = iconSize.width;
iconHeight = iconSize.height;
JInternalFrame[] frames = desktop.getAllFrames();
for (int i=0; i<frames.length; i++) {
icon = frames[i].getDesktopIcon();
Point ip = icon.getLocation();
adjustBoundsForIcon(icon, ip.x, ip.y);
}
}
/**
* Change positions of icon so that it doesn't overlap
* other icons.
*/
protected void adjustBoundsForIcon(JInternalFrame.JDesktopIcon icon,
int x, int y) {
JDesktopPane c = icon.getDesktopPane();
int maxy = c.getHeight();
int w = iconWidth;
int h = iconHeight;
c.repaint(x, y, w, h);
x = x < 0 ? 0 : x;
y = y < 0 ? 0 : y;
/* Fix for disappearing icons. If the y value is maxy then this
* algorithm would place the icon in a non-displayed cell. Never
* to be ssen again.*/
y = y >= maxy ? (maxy - 1) : y;
/* Compute the offset for the cell we are trying to go in. */
int lx = (x / w) * w;
int ygap = maxy % h;
int ly = ((y-ygap) / h) * h + ygap;
/* How far are we into the cell we dropped the icon in. */
int dx = x - lx;
int dy = y - ly;
/* Set coordinates for the icon. */
x = dx < w/2 ? lx: lx + w;
y = dy < h/2 ? ly: ((ly + h) < maxy ? ly + h: ly);
while (getIconAt(c, icon, x, y) != null) {
x += w;
}
/* Cancel the move if the x value was moved off screen. */
if (x > c.getWidth()) {
return;
}
if (icon.getParent() != null) {
setBoundsForFrame(icon, x, y, w, h);
} else {
icon.setLocation(x, y);
}
}
protected JInternalFrame.JDesktopIcon getIconAt(JDesktopPane desktop,
JInternalFrame.JDesktopIcon icon, int x, int y) {
JInternalFrame.JDesktopIcon currentIcon = null;
Component[] components = desktop.getComponents();
for (int i=0; i<components.length; i++) {
Component comp = components[i];
if (comp instanceof JInternalFrame.JDesktopIcon &&
comp != icon) {
Point p = comp.getLocation();
if (p.x == x && p.y == y) {
return (JInternalFrame.JDesktopIcon)comp;
}
}
}
return null;
}
}; /// END of MotifDesktopManager
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicEditorPaneUI;
/**
* Provides the look and feel for an pluggable content-type text editor.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Timothy Prinzing
*/
public class MotifEditorPaneUI extends BasicEditorPaneUI {
/**
* Creates a UI for the JTextPane.
*
* @param c the JTextPane component
* @return the UI
*/
public static ComponentUI createUI(JComponent c) {
return new MotifEditorPaneUI();
}
/**
* Creates the object to use for a caret. By default an
* instance of MotifTextUI.MotifCaret is created. This method
* can be redefined to provide something else that implements
* the Caret interface.
*
* @return the caret object
*/
protected Caret createCaret() {
return MotifTextUI.createCaret();
}
}

View File

@@ -0,0 +1,854 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.filechooser.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
import sun.awt.shell.ShellFolder;
import sun.swing.SwingUtilities2;
/**
* Motif FileChooserUI.
*
* @author Jeff Dinkins
*/
public class MotifFileChooserUI extends BasicFileChooserUI {
private FilterComboBoxModel filterComboBoxModel;
protected JList<File> directoryList = null;
protected JList<File> fileList = null;
protected JTextField pathField = null;
protected JComboBox<FileFilter> filterComboBox = null;
protected JTextField filenameTextField = null;
private static final Dimension hstrut10 = new Dimension(10, 1);
private static final Dimension vstrut10 = new Dimension(1, 10);
private static final Insets insets = new Insets(10, 10, 10, 10);
private static Dimension prefListSize = new Dimension(75, 150);
private static Dimension WITH_ACCELERATOR_PREF_SIZE = new Dimension(650, 450);
private static Dimension PREF_SIZE = new Dimension(350, 450);
private static final int MIN_WIDTH = 200;
private static final int MIN_HEIGHT = 300;
private static Dimension PREF_ACC_SIZE = new Dimension(10, 10);
private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1);
private static Dimension MAX_SIZE = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
private static final Insets buttonMargin = new Insets(3, 3, 3, 3);
private JPanel bottomPanel;
protected JButton approveButton;
private String enterFolderNameLabelText = null;
private int enterFolderNameLabelMnemonic = 0;
private String enterFileNameLabelText = null;
private int enterFileNameLabelMnemonic = 0;
private String filesLabelText = null;
private int filesLabelMnemonic = 0;
private String foldersLabelText = null;
private int foldersLabelMnemonic = 0;
private String pathLabelText = null;
private int pathLabelMnemonic = 0;
private String filterLabelText = null;
private int filterLabelMnemonic = 0;
private JLabel fileNameLabel;
private void populateFileNameLabel() {
if (getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) {
fileNameLabel.setText(enterFolderNameLabelText);
fileNameLabel.setDisplayedMnemonic(enterFolderNameLabelMnemonic);
} else {
fileNameLabel.setText(enterFileNameLabelText);
fileNameLabel.setDisplayedMnemonic(enterFileNameLabelMnemonic);
}
}
private String fileNameString(File file) {
if (file == null) {
return null;
} else {
JFileChooser fc = getFileChooser();
if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
return file.getPath();
} else {
return file.getName();
}
}
}
private String fileNameString(File[] files) {
StringBuffer buf = new StringBuffer();
for (int i = 0; files != null && i < files.length; i++) {
if (i > 0) {
buf.append(" ");
}
if (files.length > 1) {
buf.append("\"");
}
buf.append(fileNameString(files[i]));
if (files.length > 1) {
buf.append("\"");
}
}
return buf.toString();
}
public MotifFileChooserUI(JFileChooser filechooser) {
super(filechooser);
}
public String getFileName() {
if(filenameTextField != null) {
return filenameTextField.getText();
} else {
return null;
}
}
public void setFileName(String filename) {
if(filenameTextField != null) {
filenameTextField.setText(filename);
}
}
public String getDirectoryName() {
return pathField.getText();
}
public void setDirectoryName(String dirname) {
pathField.setText(dirname);
}
public void ensureFileIsVisible(JFileChooser fc, File f) {
// PENDING(jeff)
}
public void rescanCurrentDirectory(JFileChooser fc) {
getModel().validateFileCache();
}
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) {
return new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
if(prop.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
File f = (File) e.getNewValue();
if(f != null) {
setFileName(getFileChooser().getName(f));
}
} else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
File[] files = (File[]) e.getNewValue();
JFileChooser fc = getFileChooser();
if (files != null && files.length > 0 && (files.length > 1 || fc.isDirectorySelectionEnabled()
|| !files[0].isDirectory())) {
setFileName(fileNameString(files));
}
} else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
fileList.clearSelection();
} else if(prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
directoryList.clearSelection();
ListSelectionModel sm = directoryList.getSelectionModel();
if (sm instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
sm.setAnchorSelectionIndex(0);
}
fileList.clearSelection();
sm = fileList.getSelectionModel();
if (sm instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
sm.setAnchorSelectionIndex(0);
}
File currentDirectory = getFileChooser().getCurrentDirectory();
if(currentDirectory != null) {
try {
setDirectoryName(ShellFolder.getNormalizedFile((File)e.getNewValue()).getPath());
} catch (IOException ioe) {
setDirectoryName(((File)e.getNewValue()).getAbsolutePath());
}
if ((getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) && !getFileChooser().isMultiSelectionEnabled()) {
setFileName(getDirectoryName());
}
}
} else if(prop.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
if (fileNameLabel != null) {
populateFileNameLabel();
}
directoryList.clearSelection();
} else if (prop.equals(JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) {
if(getFileChooser().isMultiSelectionEnabled()) {
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else {
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fileList.clearSelection();
getFileChooser().setSelectedFiles(null);
}
} else if (prop.equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) {
if(getAccessoryPanel() != null) {
if(e.getOldValue() != null) {
getAccessoryPanel().remove((JComponent) e.getOldValue());
}
JComponent accessory = (JComponent) e.getNewValue();
if(accessory != null) {
getAccessoryPanel().add(accessory, BorderLayout.CENTER);
getAccessoryPanel().setPreferredSize(PREF_ACC_SIZE);
getAccessoryPanel().setMaximumSize(MAX_SIZE);
} else {
getAccessoryPanel().setPreferredSize(ZERO_ACC_SIZE);
getAccessoryPanel().setMaximumSize(ZERO_ACC_SIZE);
}
}
} else if (prop.equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) ||
prop.equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY) ||
prop.equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) {
approveButton.setText(getApproveButtonText(getFileChooser()));
approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser()));
} else if (prop.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
doControlButtonsChanged(e);
} else if (prop.equals("componentOrientation")) {
ComponentOrientation o = (ComponentOrientation)e.getNewValue();
JFileChooser cc = (JFileChooser)e.getSource();
if (o != (ComponentOrientation)e.getOldValue()) {
cc.applyComponentOrientation(o);
}
}
}
};
}
//
// ComponentUI Interface Implementation methods
//
public static ComponentUI createUI(JComponent c) {
return new MotifFileChooserUI((JFileChooser)c);
}
public void installUI(JComponent c) {
super.installUI(c);
}
public void uninstallUI(JComponent c) {
c.removePropertyChangeListener(filterComboBoxModel);
approveButton.removeActionListener(getApproveSelectionAction());
filenameTextField.removeActionListener(getApproveSelectionAction());
super.uninstallUI(c);
}
public void installComponents(JFileChooser fc) {
fc.setLayout(new BorderLayout(10, 10));
fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);
JPanel interior = new JPanel() {
public Insets getInsets() {
return insets;
}
};
interior.setInheritsPopupMenu(true);
align(interior);
interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));
fc.add(interior, BorderLayout.CENTER);
// PENDING(jeff) - I18N
JLabel l = new JLabel(pathLabelText);
l.setDisplayedMnemonic(pathLabelMnemonic);
align(l);
interior.add(l);
File currentDirectory = fc.getCurrentDirectory();
String curDirName = null;
if(currentDirectory != null) {
curDirName = currentDirectory.getPath();
}
pathField = new JTextField(curDirName) {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
pathField.setInheritsPopupMenu(true);
l.setLabelFor(pathField);
align(pathField);
// Change to folder on return
pathField.addActionListener(getUpdateAction());
interior.add(pathField);
interior.add(Box.createRigidArea(vstrut10));
// CENTER: left, right accessory
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
align(centerPanel);
// left panel - Filter & folderList
JPanel leftPanel = new JPanel();
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
align(leftPanel);
// add the filter PENDING(jeff) - I18N
l = new JLabel(filterLabelText);
l.setDisplayedMnemonic(filterLabelMnemonic);
align(l);
leftPanel.add(l);
filterComboBox = new JComboBox<FileFilter>() {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
filterComboBox.setInheritsPopupMenu(true);
l.setLabelFor(filterComboBox);
filterComboBoxModel = createFilterComboBoxModel();
filterComboBox.setModel(filterComboBoxModel);
filterComboBox.setRenderer(createFilterComboBoxRenderer());
fc.addPropertyChangeListener(filterComboBoxModel);
align(filterComboBox);
leftPanel.add(filterComboBox);
// leftPanel.add(Box.createRigidArea(vstrut10));
// Add the Folder List PENDING(jeff) - I18N
l = new JLabel(foldersLabelText);
l.setDisplayedMnemonic(foldersLabelMnemonic);
align(l);
leftPanel.add(l);
JScrollPane sp = createDirectoryList();
sp.getVerticalScrollBar().setFocusable(false);
sp.getHorizontalScrollBar().setFocusable(false);
sp.setInheritsPopupMenu(true);
l.setLabelFor(sp.getViewport().getView());
leftPanel.add(sp);
leftPanel.setInheritsPopupMenu(true);
// create files list
JPanel rightPanel = new JPanel();
align(rightPanel);
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));
rightPanel.setInheritsPopupMenu(true);
l = new JLabel(filesLabelText);
l.setDisplayedMnemonic(filesLabelMnemonic);
align(l);
rightPanel.add(l);
sp = createFilesList();
l.setLabelFor(sp.getViewport().getView());
rightPanel.add(sp);
sp.setInheritsPopupMenu(true);
centerPanel.add(leftPanel);
centerPanel.add(Box.createRigidArea(hstrut10));
centerPanel.add(rightPanel);
centerPanel.setInheritsPopupMenu(true);
JComponent accessoryPanel = getAccessoryPanel();
JComponent accessory = fc.getAccessory();
if(accessoryPanel != null) {
if(accessory == null) {
accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
} else {
getAccessoryPanel().add(accessory, BorderLayout.CENTER);
accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
accessoryPanel.setMaximumSize(MAX_SIZE);
}
align(accessoryPanel);
centerPanel.add(accessoryPanel);
accessoryPanel.setInheritsPopupMenu(true);
}
interior.add(centerPanel);
interior.add(Box.createRigidArea(vstrut10));
// add the filename field PENDING(jeff) - I18N
fileNameLabel = new JLabel();
populateFileNameLabel();
align(fileNameLabel);
interior.add(fileNameLabel);
filenameTextField = new JTextField() {
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
d.height = getPreferredSize().height;
return d;
}
};
filenameTextField.setInheritsPopupMenu(true);
fileNameLabel.setLabelFor(filenameTextField);
filenameTextField.addActionListener(getApproveSelectionAction());
align(filenameTextField);
filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
interior.add(filenameTextField);
bottomPanel = getBottomPanel();
bottomPanel.add(new JSeparator(), BorderLayout.NORTH);
// Add buttons
JPanel buttonPanel = new JPanel();
align(buttonPanel);
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
buttonPanel.add(Box.createGlue());
approveButton = new JButton(getApproveButtonText(fc)) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
approveButton.setMnemonic(getApproveButtonMnemonic(fc));
approveButton.setToolTipText(getApproveButtonToolTipText(fc));
approveButton.setInheritsPopupMenu(true);
align(approveButton);
approveButton.setMargin(buttonMargin);
approveButton.addActionListener(getApproveSelectionAction());
buttonPanel.add(approveButton);
buttonPanel.add(Box.createGlue());
JButton updateButton = new JButton(updateButtonText) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
updateButton.setMnemonic(updateButtonMnemonic);
updateButton.setToolTipText(updateButtonToolTipText);
updateButton.setInheritsPopupMenu(true);
align(updateButton);
updateButton.setMargin(buttonMargin);
updateButton.addActionListener(getUpdateAction());
buttonPanel.add(updateButton);
buttonPanel.add(Box.createGlue());
JButton cancelButton = new JButton(cancelButtonText) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
cancelButton.setMnemonic(cancelButtonMnemonic);
cancelButton.setToolTipText(cancelButtonToolTipText);
cancelButton.setInheritsPopupMenu(true);
align(cancelButton);
cancelButton.setMargin(buttonMargin);
cancelButton.addActionListener(getCancelSelectionAction());
buttonPanel.add(cancelButton);
buttonPanel.add(Box.createGlue());
JButton helpButton = new JButton(helpButtonText) {
public Dimension getMaximumSize() {
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
}
};
helpButton.setMnemonic(helpButtonMnemonic);
helpButton.setToolTipText(helpButtonToolTipText);
align(helpButton);
helpButton.setMargin(buttonMargin);
helpButton.setEnabled(false);
helpButton.setInheritsPopupMenu(true);
buttonPanel.add(helpButton);
buttonPanel.add(Box.createGlue());
buttonPanel.setInheritsPopupMenu(true);
bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
bottomPanel.setInheritsPopupMenu(true);
if (fc.getControlButtonsAreShown()) {
fc.add(bottomPanel, BorderLayout.SOUTH);
}
}
protected JPanel getBottomPanel() {
if (bottomPanel == null) {
bottomPanel = new JPanel(new BorderLayout(0, 4));
}
return bottomPanel;
}
private void doControlButtonsChanged(PropertyChangeEvent e) {
if (getFileChooser().getControlButtonsAreShown()) {
getFileChooser().add(bottomPanel,BorderLayout.SOUTH);
} else {
getFileChooser().remove(getBottomPanel());
}
}
public void uninstallComponents(JFileChooser fc) {
fc.removeAll();
bottomPanel = null;
if (filterComboBoxModel != null) {
fc.removePropertyChangeListener(filterComboBoxModel);
}
}
protected void installStrings(JFileChooser fc) {
super.installStrings(fc);
Locale l = fc.getLocale();
enterFolderNameLabelText = UIManager.getString("FileChooser.enterFolderNameLabelText",l);
enterFolderNameLabelMnemonic = getMnemonic("FileChooser.enterFolderNameLabelMnemonic", l);
enterFileNameLabelText = UIManager.getString("FileChooser.enterFileNameLabelText",l);
enterFileNameLabelMnemonic = getMnemonic("FileChooser.enterFileNameLabelMnemonic", l);
filesLabelText = UIManager.getString("FileChooser.filesLabelText",l);
filesLabelMnemonic = getMnemonic("FileChooser.filesLabelMnemonic", l);
foldersLabelText = UIManager.getString("FileChooser.foldersLabelText",l);
foldersLabelMnemonic = getMnemonic("FileChooser.foldersLabelMnemonic", l);
pathLabelText = UIManager.getString("FileChooser.pathLabelText",l);
pathLabelMnemonic = getMnemonic("FileChooser.pathLabelMnemonic", l);
filterLabelText = UIManager.getString("FileChooser.filterLabelText",l);
filterLabelMnemonic = getMnemonic("FileChooser.filterLabelMnemonic", l);
}
private Integer getMnemonic(String key, Locale l) {
return SwingUtilities2.getUIDefaultsInt(key, l);
}
protected void installIcons(JFileChooser fc) {
// Since motif doesn't have button icons, leave this empty
// which overrides the supertype icon loading
}
protected void uninstallIcons(JFileChooser fc) {
// Since motif doesn't have button icons, leave this empty
// which overrides the supertype icon loading
}
protected JScrollPane createFilesList() {
fileList = new JList<File>();
if(getFileChooser().isMultiSelectionEnabled()) {
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
} else {
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
fileList.setModel(new MotifFileListModel());
fileList.getSelectionModel().removeSelectionInterval(0, 0);
fileList.setCellRenderer(new FileCellRenderer());
fileList.addListSelectionListener(createListSelectionListener(getFileChooser()));
fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList));
fileList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
JFileChooser chooser = getFileChooser();
if (SwingUtilities.isLeftMouseButton(e) && !chooser.isMultiSelectionEnabled()) {
int index = SwingUtilities2.loc2IndexFileList(fileList, e.getPoint());
if (index >= 0) {
File file = fileList.getModel().getElementAt(index);
setFileName(chooser.getName(file));
}
}
}
});
align(fileList);
JScrollPane scrollpane = new JScrollPane(fileList);
scrollpane.setPreferredSize(prefListSize);
scrollpane.setMaximumSize(MAX_SIZE);
align(scrollpane);
fileList.setInheritsPopupMenu(true);
scrollpane.setInheritsPopupMenu(true);
return scrollpane;
}
protected JScrollPane createDirectoryList() {
directoryList = new JList<File>();
align(directoryList);
directoryList.setCellRenderer(new DirectoryCellRenderer());
directoryList.setModel(new MotifDirectoryListModel());
directoryList.getSelectionModel().removeSelectionInterval(0, 0);
directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList));
directoryList.addListSelectionListener(createListSelectionListener(getFileChooser()));
directoryList.setInheritsPopupMenu(true);
JScrollPane scrollpane = new JScrollPane(directoryList);
scrollpane.setMaximumSize(MAX_SIZE);
scrollpane.setPreferredSize(prefListSize);
scrollpane.setInheritsPopupMenu(true);
align(scrollpane);
return scrollpane;
}
@Override
public Dimension getPreferredSize(JComponent c) {
Dimension prefSize =
(getFileChooser().getAccessory() != null) ? WITH_ACCELERATOR_PREF_SIZE : PREF_SIZE;
Dimension d = c.getLayout().preferredLayoutSize(c);
if (d != null) {
return new Dimension(d.width < prefSize.width ? prefSize.width : d.width,
d.height < prefSize.height ? prefSize.height : d.height);
} else {
return prefSize;
}
}
@Override
public Dimension getMinimumSize(JComponent x) {
return new Dimension(MIN_WIDTH, MIN_HEIGHT);
}
@Override
public Dimension getMaximumSize(JComponent x) {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
protected void align(JComponent c) {
c.setAlignmentX(JComponent.LEFT_ALIGNMENT);
c.setAlignmentY(JComponent.TOP_ALIGNMENT);
}
protected class FileCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setText(getFileChooser().getName((File) value));
setInheritsPopupMenu(true);
return this;
}
}
protected class DirectoryCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setText(getFileChooser().getName((File) value));
setInheritsPopupMenu(true);
return this;
}
}
protected class MotifDirectoryListModel extends AbstractListModel<File> implements ListDataListener {
public MotifDirectoryListModel() {
getModel().addListDataListener(this);
}
public int getSize() {
return getModel().getDirectories().size();
}
public File getElementAt(int index) {
return getModel().getDirectories().elementAt(index);
}
public void intervalAdded(ListDataEvent e) {
fireIntervalAdded(this, e.getIndex0(), e.getIndex1());
}
public void intervalRemoved(ListDataEvent e) {
fireIntervalRemoved(this, e.getIndex0(), e.getIndex1());
}
// PENDING(jeff) - this is inefficient - should sent out
// incremental adjustment values instead of saying that the
// whole list has changed.
public void fireContentsChanged() {
fireContentsChanged(this, 0, getModel().getDirectories().size()-1);
}
// PENDING(jeff) - fire the correct interval changed - currently sending
// out that everything has changed
public void contentsChanged(ListDataEvent e) {
fireContentsChanged();
}
}
protected class MotifFileListModel extends AbstractListModel<File> implements ListDataListener {
public MotifFileListModel() {
getModel().addListDataListener(this);
}
public int getSize() {
return getModel().getFiles().size();
}
public boolean contains(Object o) {
return getModel().getFiles().contains(o);
}
public int indexOf(Object o) {
return getModel().getFiles().indexOf(o);
}
public File getElementAt(int index) {
return getModel().getFiles().elementAt(index);
}
public void intervalAdded(ListDataEvent e) {
fireIntervalAdded(this, e.getIndex0(), e.getIndex1());
}
public void intervalRemoved(ListDataEvent e) {
fireIntervalRemoved(this, e.getIndex0(), e.getIndex1());
}
// PENDING(jeff) - this is inefficient - should sent out
// incremental adjustment values instead of saying that the
// whole list has changed.
public void fireContentsChanged() {
fireContentsChanged(this, 0, getModel().getFiles().size()-1);
}
// PENDING(jeff) - fire the interval changed
public void contentsChanged(ListDataEvent e) {
fireContentsChanged();
}
}
//
// DataModel for Types Comboxbox
//
protected FilterComboBoxModel createFilterComboBoxModel() {
return new FilterComboBoxModel();
}
//
// Renderer for Types ComboBox
//
protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
return new FilterComboBoxRenderer();
}
/**
* Render different type sizes and styles.
*/
public class FilterComboBoxRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null && value instanceof FileFilter) {
setText(((FileFilter)value).getDescription());
}
return this;
}
}
/**
* Data model for a type-face selection combo-box.
*/
protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
PropertyChangeListener {
protected FileFilter[] filters;
protected FilterComboBoxModel() {
super();
filters = getFileChooser().getChoosableFileFilters();
}
public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {
filters = (FileFilter[]) e.getNewValue();
fireContentsChanged(this, -1, -1);
} else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
fireContentsChanged(this, -1, -1);
}
}
public void setSelectedItem(Object filter) {
if(filter != null) {
getFileChooser().setFileFilter((FileFilter) filter);
fireContentsChanged(this, -1, -1);
}
}
public Object getSelectedItem() {
// Ensure that the current filter is in the list.
// NOTE: we shouldnt' have to do this, since JFileChooser adds
// the filter to the choosable filters list when the filter
// is set. Lets be paranoid just in case someone overrides
// setFileFilter in JFileChooser.
FileFilter currentFilter = getFileChooser().getFileFilter();
boolean found = false;
if(currentFilter != null) {
for (FileFilter filter : filters) {
if (filter == currentFilter) {
found = true;
}
}
if (!found) {
getFileChooser().addChoosableFileFilter(currentFilter);
}
}
return getFileChooser().getFileFilter();
}
public int getSize() {
if(filters != null) {
return filters.length;
} else {
return 0;
}
}
public FileFilter getElementAt(int index) {
if(index > getSize() - 1) {
// This shouldn't happen. Try to recover gracefully.
return getFileChooser().getFileFilter();
}
if(filters != null) {
return filters[index];
} else {
return null;
}
}
}
protected JButton getApproveButton(JFileChooser fc) {
return approveButton;
}
}

View File

@@ -0,0 +1,476 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.swing.SwingUtilities2;
import javax.swing.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.awt.Component;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.awt.Container;
import javax.swing.plaf.basic.*;
import javax.swing.text.View;
/*
* @author Jeff Dinkins
* @author Dave Kloba
*/
public class MotifGraphicsUtils implements SwingConstants
{
/* Client Property keys for text and accelerator text widths */
private static final String MAX_ACC_WIDTH = "maxAccWidth";
/**
* Draws the point (<b>x</b>, <b>y</b>) in the current color.
*/
static void drawPoint(Graphics g, int x, int y) {
g.drawLine(x, y, x, y);
}
/*
* Convenience method for drawing a grooved line
*
*/
public static void drawGroove(Graphics g, int x, int y, int w, int h,
Color shadow, Color highlight)
{
Color oldColor = g.getColor(); // Make no net change to g
g.translate(x, y);
g.setColor(shadow);
g.drawRect(0, 0, w-2, h-2);
g.setColor(highlight);
g.drawLine(1, h-3, 1, 1);
g.drawLine(1, 1, w-3, 1);
g.drawLine(0, h-1, w-1, h-1);
g.drawLine(w-1, h-1, w-1, 0);
g.translate(-x, -y);
g.setColor(oldColor);
}
/** Draws <b>aString</b> in the rectangle defined by
* (<b>x</b>, <b>y</b>, <b>width</b>, <b>height</b>).
* <b>justification</b> specifies the text's justification, one of
* LEFT, CENTER, or RIGHT.
* <b>drawStringInRect()</b> does not clip to the rectangle, but instead
* uses this rectangle and the desired justification to compute the point
* at which to begin drawing the text.
* @see #drawString
*/
public static void drawStringInRect(Graphics g, String aString, int x, int y,
int width, int height, int justification) {
drawStringInRect(null, g, aString, x, y, width, height, justification);
}
static void drawStringInRect(JComponent c, Graphics g, String aString,
int x, int y, int width, int height,
int justification) {
FontMetrics fontMetrics;
int drawWidth, startX, startY, delta;
if (g.getFont() == null) {
// throw new InconsistencyException("No font set");
return;
}
fontMetrics = SwingUtilities2.getFontMetrics(c, g);
if (fontMetrics == null) {
// throw new InconsistencyException("No metrics for Font " + font());
return;
}
if (justification == CENTER) {
drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString);
if (drawWidth > width) {
drawWidth = width;
}
startX = x + (width - drawWidth) / 2;
} else if (justification == RIGHT) {
drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString);
if (drawWidth > width) {
drawWidth = width;
}
startX = x + width - drawWidth;
} else {
startX = x;
}
delta = (height - fontMetrics.getAscent() - fontMetrics.getDescent()) / 2;
if (delta < 0) {
delta = 0;
}
startY = y + height - delta - fontMetrics.getDescent();
SwingUtilities2.drawString(c, g, aString, startX, startY);
}
/**
* This method is not being used to paint menu item since
* 6.0 This code left for compatibility only. Do not use or
* override it, this will not cause any visible effect.
*/
public static void paintMenuItem(Graphics g, JComponent c,
Icon checkIcon, Icon arrowIcon,
Color background, Color foreground,
int defaultTextIconGap)
{
JMenuItem b = (JMenuItem) c;
ButtonModel model = b.getModel();
Dimension size = b.getSize();
Insets i = c.getInsets();
Rectangle viewRect = new Rectangle(size);
viewRect.x += i.left;
viewRect.y += i.top;
viewRect.width -= (i.right + viewRect.x);
viewRect.height -= (i.bottom + viewRect.y);
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
Rectangle acceleratorRect = new Rectangle();
Rectangle checkRect = new Rectangle();
Rectangle arrowRect = new Rectangle();
Font holdf = g.getFont();
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f);
FontMetrics fmAccel = SwingUtilities2.getFontMetrics(
c, g, UIManager.getFont("MenuItem.acceleratorFont"));
if (c.isOpaque()) {
if (model.isArmed()|| (c instanceof JMenu && model.isSelected())) {
g.setColor(background);
} else {
g.setColor(c.getBackground());
}
g.fillRect(0,0, size.width, size.height);
}
// get Accelerator text
KeyStroke accelerator = b.getAccelerator();
String acceleratorText = "";
if (accelerator != null) {
int modifiers = accelerator.getModifiers();
if (modifiers > 0) {
acceleratorText = KeyEvent.getKeyModifiersText(modifiers);
acceleratorText += "+";
}
acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode());
}
// layout the text and icon
String text = layoutMenuItem(c, fm, b.getText(), fmAccel,
acceleratorText, b.getIcon(),
checkIcon, arrowIcon,
b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getVerticalTextPosition(),
b.getHorizontalTextPosition(),
viewRect, iconRect,
textRect, acceleratorRect,
checkRect, arrowRect,
b.getText() == null
? 0 : defaultTextIconGap,
defaultTextIconGap
);
// Paint the Check
Color holdc = g.getColor();
if (checkIcon != null) {
if(model.isArmed() || (c instanceof JMenu && model.isSelected()))
g.setColor(foreground);
checkIcon.paintIcon(c, g, checkRect.x, checkRect.y);
g.setColor(holdc);
}
// Paint the Icon
if(b.getIcon() != null) {
Icon icon;
if(!model.isEnabled()) {
icon = b.getDisabledIcon();
} else if(model.isPressed() && model.isArmed()) {
icon = b.getPressedIcon();
if(icon == null) {
// Use default icon
icon = b.getIcon();
}
} else {
icon = b.getIcon();
}
if (icon!=null) {
icon.paintIcon(c, g, iconRect.x, iconRect.y);
}
}
// Draw the Text
if(text != null && !text.equals("")) {
// Once BasicHTML becomes public, use BasicHTML.propertyKey
// instead of the hardcoded string below!
View v = (View) c.getClientProperty("html");
if (v != null) {
v.paint(g, textRect);
} else {
int mnemIndex = b.getDisplayedMnemonicIndex();
if(!model.isEnabled()) {
// *** paint the text disabled
g.setColor(b.getBackground().brighter());
SwingUtilities2.drawStringUnderlineCharAt(b, g,text,
mnemIndex,
textRect.x, textRect.y + fmAccel.getAscent());
g.setColor(b.getBackground().darker());
SwingUtilities2.drawStringUnderlineCharAt(b, g,text,
mnemIndex,
textRect.x - 1, textRect.y + fmAccel.getAscent() - 1);
} else {
// *** paint the text normally
if (model.isArmed()|| (c instanceof JMenu && model.isSelected())) {
g.setColor(foreground);
} else {
g.setColor(b.getForeground());
}
SwingUtilities2.drawStringUnderlineCharAt(b, g,text,
mnemIndex,
textRect.x,
textRect.y + fm.getAscent());
}
}
}
// Draw the Accelerator Text
if(acceleratorText != null && !acceleratorText.equals("")) {
//Get the maxAccWidth from the parent to calculate the offset.
int accOffset = 0;
Container parent = b.getParent();
if (parent != null && parent instanceof JComponent) {
JComponent p = (JComponent) parent;
Integer maxValueInt = (Integer) p.getClientProperty(MotifGraphicsUtils.MAX_ACC_WIDTH);
int maxValue = maxValueInt != null ?
maxValueInt.intValue() : acceleratorRect.width;
//Calculate the offset, with which the accelerator texts will be drawn with.
accOffset = maxValue - acceleratorRect.width;
}
g.setFont( UIManager.getFont("MenuItem.acceleratorFont") );
if(!model.isEnabled()) {
// *** paint the acceleratorText disabled
g.setColor(b.getBackground().brighter());
SwingUtilities2.drawString(c, g,acceleratorText,
acceleratorRect.x - accOffset, acceleratorRect.y + fm.getAscent());
g.setColor(b.getBackground().darker());
SwingUtilities2.drawString(c, g,acceleratorText,
acceleratorRect.x - accOffset - 1, acceleratorRect.y + fm.getAscent() - 1);
} else {
// *** paint the acceleratorText normally
if (model.isArmed()|| (c instanceof JMenu && model.isSelected()))
{
g.setColor(foreground);
} else {
g.setColor(b.getForeground());
}
SwingUtilities2.drawString(c, g,acceleratorText,
acceleratorRect.x - accOffset,
acceleratorRect.y + fmAccel.getAscent());
}
}
// Paint the Arrow
if (arrowIcon != null) {
if(model.isArmed() || (c instanceof JMenu && model.isSelected()))
g.setColor(foreground);
if( !(b.getParent() instanceof JMenuBar) )
arrowIcon.paintIcon(c, g, arrowRect.x, arrowRect.y);
}
g.setColor(holdc);
g.setFont(holdf);
}
/**
* Compute and return the location of the icons origin, the
* location of origin of the text baseline, and a possibly clipped
* version of the compound labels string. Locations are computed
* relative to the viewR rectangle.
*/
private static String layoutMenuItem(
JComponent c,
FontMetrics fm,
String text,
FontMetrics fmAccel,
String acceleratorText,
Icon icon,
Icon checkIcon,
Icon arrowIcon,
int verticalAlignment,
int horizontalAlignment,
int verticalTextPosition,
int horizontalTextPosition,
Rectangle viewR,
Rectangle iconR,
Rectangle textR,
Rectangle acceleratorR,
Rectangle checkIconR,
Rectangle arrowIconR,
int textIconGap,
int menuItemGap
)
{
SwingUtilities.layoutCompoundLabel(c,
fm,
text,
icon,
verticalAlignment,
horizontalAlignment,
verticalTextPosition,
horizontalTextPosition,
viewR,
iconR,
textR,
textIconGap);
/* Initialize the acceelratorText bounds rectangle textR. If a null
* or and empty String was specified we substitute "" here
* and use 0,0,0,0 for acceleratorTextR.
*/
if( (acceleratorText == null) || acceleratorText.equals("") ) {
acceleratorR.width = acceleratorR.height = 0;
acceleratorText = "";
}
else {
acceleratorR.width
= SwingUtilities2.stringWidth(c, fmAccel, acceleratorText);
acceleratorR.height = fmAccel.getHeight();
}
/* Initialize the checkIcon bounds rectangle checkIconR.
*/
if (checkIcon != null) {
checkIconR.width = checkIcon.getIconWidth();
checkIconR.height = checkIcon.getIconHeight();
}
else {
checkIconR.width = checkIconR.height = 0;
}
/* Initialize the arrowIcon bounds rectangle arrowIconR.
*/
if (arrowIcon != null) {
arrowIconR.width = arrowIcon.getIconWidth();
arrowIconR.height = arrowIcon.getIconHeight();
}
else {
arrowIconR.width = arrowIconR.height = 0;
}
Rectangle labelR = iconR.union(textR);
if( MotifGraphicsUtils.isLeftToRight(c) ) {
textR.x += checkIconR.width + menuItemGap;
iconR.x += checkIconR.width + menuItemGap;
// Position the Accelerator text rect
acceleratorR.x = viewR.x + viewR.width - arrowIconR.width
- menuItemGap - acceleratorR.width;
// Position the Check and Arrow Icons
checkIconR.x = viewR.x;
arrowIconR.x = viewR.x + viewR.width - menuItemGap
- arrowIconR.width;
} else {
textR.x -= (checkIconR.width + menuItemGap);
iconR.x -= (checkIconR.width + menuItemGap);
// Position the Accelerator text rect
acceleratorR.x = viewR.x + arrowIconR.width + menuItemGap;
// Position the Check and Arrow Icons
checkIconR.x = viewR.x + viewR.width - checkIconR.width;
arrowIconR.x = viewR.x + menuItemGap;
}
// Align the accelertor text and the check and arrow icons vertically
// with the center of the label rect.
acceleratorR.y = labelR.y + (labelR.height/2) - (acceleratorR.height/2);
arrowIconR.y = labelR.y + (labelR.height/2) - (arrowIconR.height/2);
checkIconR.y = labelR.y + (labelR.height/2) - (checkIconR.height/2);
/*
System.out.println("Layout: v=" +viewR+" c="+checkIconR+" i="+
iconR+" t="+textR+" acc="+acceleratorR+" a="+arrowIconR);
*/
return text;
}
private static void drawMenuBezel(Graphics g, Color background,
int x, int y,
int width, int height)
{
// shadowed button region
g.setColor(background);
g.fillRect(x,y,width,height);
g.setColor(background.brighter().brighter());
g.drawLine(x+1, y+height-1, x+width-1, y+height-1);
g.drawLine(x+width-1, y+height-2, x+width-1, y+1);
g.setColor(background.darker().darker());
g.drawLine(x, y, x+width-2, y);
g.drawLine(x, y+1, x, y+height-2);
}
/*
* Convenience function for determining ComponentOrientation. Helps us
* avoid having Munge directives throughout the code.
*/
static boolean isLeftToRight( Component c ) {
return c.getComponentOrientation().isLeftToRight();
}
}

View File

@@ -0,0 +1,460 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Polygon;
import java.io.Serializable;
/**
* Icon factory for the CDE/Motif Look and Feel
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* 1.20 04/27/99
* @author Georges Saab
*/
public class MotifIconFactory implements Serializable
{
private static Icon checkBoxIcon;
private static Icon radioButtonIcon;
private static Icon menuItemCheckIcon;
private static Icon menuItemArrowIcon;
private static Icon menuArrowIcon;
public static Icon getMenuItemCheckIcon() {
return null;
}
public static Icon getMenuItemArrowIcon() {
if (menuItemArrowIcon == null) {
menuItemArrowIcon = new MenuItemArrowIcon();
}
return menuItemArrowIcon;
}
public static Icon getMenuArrowIcon() {
if (menuArrowIcon == null) {
menuArrowIcon = new MenuArrowIcon();
}
return menuArrowIcon;
}
public static Icon getCheckBoxIcon() {
if (checkBoxIcon == null) {
checkBoxIcon = new CheckBoxIcon();
}
return checkBoxIcon;
}
public static Icon getRadioButtonIcon() {
if (radioButtonIcon == null) {
radioButtonIcon = new RadioButtonIcon();
}
return radioButtonIcon;
}
private static class CheckBoxIcon implements Icon, UIResource, Serializable {
final static int csize = 13;
private Color control = UIManager.getColor("control");
private Color foreground = UIManager.getColor("CheckBox.foreground");
private Color shadow = UIManager.getColor("controlShadow");
private Color highlight = UIManager.getColor("controlHighlight");
private Color lightShadow = UIManager.getColor("controlLightShadow");
public void paintIcon(Component c, Graphics g, int x, int y) {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
boolean flat = false;
if(b instanceof JCheckBox) {
flat = ((JCheckBox)b).isBorderPaintedFlat();
}
boolean isPressed = model.isPressed();
boolean isArmed = model.isArmed();
boolean isEnabled = model.isEnabled();
boolean isSelected = model.isSelected();
// There are 4 "looks" to the Motif CheckBox:
// drawCheckBezelOut - default unchecked state
// drawBezel - when we uncheck in toggled state
// drawCheckBezel - when we check in toggle state
// drawCheckBezelIn - selected, mouseReleased
boolean checkToggleIn = ((isPressed &&
!isArmed &&
isSelected) ||
(isPressed &&
isArmed &&
!isSelected));
boolean uncheckToggleOut = ((isPressed &&
!isArmed &&
!isSelected) ||
(isPressed &&
isArmed &&
isSelected));
boolean checkIn = (!isPressed &&
isArmed &&
isSelected ||
(!isPressed &&
!isArmed &&
isSelected));
if(flat) {
g.setColor(shadow);
g.drawRect(x+2,y,csize-1,csize-1);
if(uncheckToggleOut || checkToggleIn) {
g.setColor(control);
g.fillRect(x+3,y+1,csize-2,csize-2);
}
}
if (checkToggleIn) {
// toggled from unchecked to checked
drawCheckBezel(g,x,y,csize,true,false,false,flat);
} else if (uncheckToggleOut) {
// MotifBorderFactory.drawBezel(g,x,y,csize,csize,false,false);
drawCheckBezel(g,x,y,csize,true,true,false,flat);
} else if (checkIn) {
// show checked, unpressed state
drawCheckBezel(g,x,y,csize,false,false,true,flat);
} else if(!flat) {
// show unchecked state
drawCheckBezelOut(g,x,y,csize);
}
}
public int getIconWidth() {
return csize;
}
public int getIconHeight() {
return csize;
}
public void drawCheckBezelOut(Graphics g, int x, int y, int csize){
Color controlShadow = UIManager.getColor("controlShadow");
int w = csize;
int h = csize;
Color oldColor = g.getColor();
g.translate(x,y);
g.setColor(highlight); // inner 3D border
g.drawLine(0, 0, 0, h-1);
g.drawLine(1, 0, w-1, 0);
g.setColor(shadow); // black drop shadow __|
g.drawLine(1, h-1, w-1, h-1);
g.drawLine(w-1, h-1, w-1, 1);
g.translate(-x,-y);
g.setColor(oldColor);
}
public void drawCheckBezel(Graphics g, int x, int y, int csize,
boolean shade, boolean out, boolean check, boolean flat)
{
Color oldColor = g.getColor();
g.translate(x, y);
//bottom
if(!flat) {
if (out) {
g.setColor(control);
g.fillRect(1,1,csize-2,csize-2);
g.setColor(shadow);
} else {
g.setColor(lightShadow);
g.fillRect(0,0,csize,csize);
g.setColor(highlight);
}
g.drawLine(1,csize-1,csize-2,csize-1);
if (shade) {
g.drawLine(2,csize-2,csize-3,csize-2);
g.drawLine(csize-2,2,csize-2 ,csize-1);
if (out) {
g.setColor(highlight);
} else {
g.setColor(shadow);
}
g.drawLine(1,2,1,csize-2);
g.drawLine(1,1,csize-3,1);
if (out) {
g.setColor(shadow);
} else {
g.setColor(highlight);
}
}
//right
g.drawLine(csize-1,1,csize-1,csize-1);
//left
if (out) {
g.setColor(highlight);
} else {
g.setColor(shadow);
}
g.drawLine(0,1,0,csize-1);
//top
g.drawLine(0,0,csize-1,0);
}
if (check) {
// draw check
g.setColor(foreground);
g.drawLine(csize-2,1,csize-2,2);
g.drawLine(csize-3,2,csize-3,3);
g.drawLine(csize-4,3,csize-4,4);
g.drawLine(csize-5,4,csize-5,6);
g.drawLine(csize-6,5,csize-6,8);
g.drawLine(csize-7,6,csize-7,10);
g.drawLine(csize-8,7,csize-8,10);
g.drawLine(csize-9,6,csize-9,9);
g.drawLine(csize-10,5,csize-10,8);
g.drawLine(csize-11,5,csize-11,7);
g.drawLine(csize-12,6,csize-12,6);
}
g.translate(-x, -y);
g.setColor(oldColor);
}
} // end class CheckBoxIcon
private static class RadioButtonIcon implements Icon, UIResource, Serializable {
private Color dot = UIManager.getColor("activeCaptionBorder");
private Color highlight = UIManager.getColor("controlHighlight");
private Color shadow = UIManager.getColor("controlShadow");
public void paintIcon(Component c, Graphics g, int x, int y) {
// fill interior
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
int w = getIconWidth();
int h = getIconHeight();
boolean isPressed = model.isPressed();
boolean isArmed = model.isArmed();
boolean isEnabled = model.isEnabled();
boolean isSelected = model.isSelected();
boolean checkIn = ((isPressed &&
!isArmed &&
isSelected) ||
(isPressed &&
isArmed &&
!isSelected)
||
(!isPressed &&
isArmed &&
isSelected ||
(!isPressed &&
!isArmed &&
isSelected)));
if (checkIn){
g.setColor(shadow);
g.drawLine(x+5,y+0,x+8,y+0);
g.drawLine(x+3,y+1,x+4,y+1);
g.drawLine(x+9,y+1,x+9,y+1);
g.drawLine(x+2,y+2,x+2,y+2);
g.drawLine(x+1,y+3,x+1,y+3);
g.drawLine(x,y+4,x,y+9);
g.drawLine(x+1,y+10,x+1,y+10);
g.drawLine(x+2,y+11,x+2,y+11);
g.setColor(highlight);
g.drawLine(x+3,y+12,x+4,y+12);
g.drawLine(x+5,y+13,x+8,y+13);
g.drawLine(x+9,y+12,x+10,y+12);
g.drawLine(x+11,y+11,x+11,y+11);
g.drawLine(x+12,y+10,x+12,y+10);
g.drawLine(x+13,y+9,x+13,y+4);
g.drawLine(x+12,y+3,x+12,y+3);
g.drawLine(x+11,y+2,x+11,y+2);
g.drawLine(x+10,y+1,x+10,y+1);
g.setColor(dot);
g.fillRect(x+4,y+5,6,4);
g.drawLine(x+5,y+4,x+8,y+4);
g.drawLine(x+5,y+9,x+8,y+9);
}
else {
g.setColor(highlight);
g.drawLine(x+5,y+0,x+8,y+0);
g.drawLine(x+3,y+1,x+4,y+1);
g.drawLine(x+9,y+1,x+9,y+1);
g.drawLine(x+2,y+2,x+2,y+2);
g.drawLine(x+1,y+3,x+1,y+3);
g.drawLine(x,y+4,x,y+9);
g.drawLine(x+1,y+10,x+1,y+10);
g.drawLine(x+2,y+11,x+2,y+11);
g.setColor(shadow);
g.drawLine(x+3,y+12,x+4,y+12);
g.drawLine(x+5,y+13,x+8,y+13);
g.drawLine(x+9,y+12,x+10,y+12);
g.drawLine(x+11,y+11,x+11,y+11);
g.drawLine(x+12,y+10,x+12,y+10);
g.drawLine(x+13,y+9,x+13,y+4);
g.drawLine(x+12,y+3,x+12,y+3);
g.drawLine(x+11,y+2,x+11,y+2);
g.drawLine(x+10,y+1,x+10,y+1);
}
}
public int getIconWidth() {
return 14;
}
public int getIconHeight() {
return 14;
}
} // end class RadioButtonIcon
private static class MenuItemCheckIcon implements Icon, UIResource, Serializable
{
public void paintIcon(Component c,Graphics g, int x, int y)
{
}
public int getIconWidth() { return 0; }
public int getIconHeight() { return 0; }
} // end class MenuItemCheckIcon
private static class MenuItemArrowIcon implements Icon, UIResource, Serializable
{
public void paintIcon(Component c,Graphics g, int x, int y)
{
}
public int getIconWidth() { return 0; }
public int getIconHeight() { return 0; }
} // end class MenuItemArrowIcon
private static class MenuArrowIcon implements Icon, UIResource, Serializable
{
private Color focus = UIManager.getColor("windowBorder");
private Color shadow = UIManager.getColor("controlShadow");
private Color highlight = UIManager.getColor("controlHighlight");
public void paintIcon(Component c, Graphics g, int x, int y) {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
// These variables are kind of pointless as the following code
// assumes the icon will be 10 x 10 regardless of their value.
int w = getIconWidth();
int h = getIconHeight();
Color oldColor = g.getColor();
if (model.isSelected()){
if( MotifGraphicsUtils.isLeftToRight(c) ){
g.setColor(shadow);
g.fillRect(x+1,y+1,2,h);
g.drawLine(x+4,y+2,x+4,y+2);
g.drawLine(x+6,y+3,x+6,y+3);
g.drawLine(x+8,y+4,x+8,y+5);
g.setColor(focus);
g.fillRect(x+2,y+2,2,h-2);
g.fillRect(x+4,y+3,2,h-4);
g.fillRect(x+6,y+4,2,h-6);
g.setColor(highlight);
g.drawLine(x+2,y+h,x+2,y+h);
g.drawLine(x+4,y+h-1,x+4,y+h-1);
g.drawLine(x+6,y+h-2,x+6,y+h-2);
g.drawLine(x+8,y+h-4,x+8,y+h-3);
} else {
g.setColor(highlight);
g.fillRect(x+7,y+1,2,10);
g.drawLine(x+5,y+9,x+5,y+9);
g.drawLine(x+3,y+8,x+3,y+8);
g.drawLine(x+1,y+6,x+1,y+7);
g.setColor(focus);
g.fillRect(x+6,y+2,2,8);
g.fillRect(x+4,y+3,2,6);
g.fillRect(x+2,y+4,2,4);
g.setColor(shadow);
g.drawLine(x+1,y+4,x+1,y+5);
g.drawLine(x+3,y+3,x+3,y+3);
g.drawLine(x+5,y+2,x+5,y+2);
g.drawLine(x+7,y+1,x+7,y+1);
}
} else {
if( MotifGraphicsUtils.isLeftToRight(c) ){
g.setColor(highlight);
g.drawLine(x+1,y+1,x+1,y+h);
g.drawLine(x+2,y+1,x+2,y+h-2);
g.fillRect(x+3,y+2,2,2);
g.fillRect(x+5,y+3,2,2);
g.fillRect(x+7,y+4,2,2);
g.setColor(shadow);
g.drawLine(x+2,y+h-1,x+2,y+h);
g.fillRect(x+3,y+h-2,2,2);
g.fillRect(x+5,y+h-3,2,2);
g.fillRect(x+7,y+h-4,2,2);
g.setColor(oldColor);
} else {
g.setColor(highlight);
g.fillRect(x+1,y+4,2,2);
g.fillRect(x+3,y+3,2,2);
g.fillRect(x+5,y+2,2,2);
g.drawLine(x+7,y+1,x+7,y+2);
g.setColor(shadow);
g.fillRect(x+1,y+h-4,2,2);
g.fillRect(x+3,y+h-3,2,2);
g.fillRect(x+5,y+h-2,2,2);
g.drawLine(x+7,y+3,x+7,y+h);
g.drawLine(x+8,y+1,x+8,y+h);
g.setColor(oldColor);
}
}
}
public int getIconWidth() { return 10; }
public int getIconHeight() { return 10; }
} // End class MenuArrowIcon
}

View File

@@ -0,0 +1,389 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.InternalFrameEvent;
import javax.swing.plaf.basic.*;
import java.util.EventListener;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.beans.VetoableChangeListener;
import java.beans.PropertyVetoException;
import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.MouseEventAccessor;
/**
* Class that manages a Motif title bar
*
* @since 1.3
*/
public class MotifInternalFrameTitlePane
extends BasicInternalFrameTitlePane implements LayoutManager, ActionListener, PropertyChangeListener
{
SystemButton systemButton;
MinimizeButton minimizeButton;
MaximizeButton maximizeButton;
JPopupMenu systemMenu;
Title title;
Color color;
Color highlight;
Color shadow;
// The width and height of a title pane button
public final static int BUTTON_SIZE = 19; // 17 + 1 pixel border
public MotifInternalFrameTitlePane(JInternalFrame frame) {
super(frame);
}
protected void installDefaults() {
setFont(UIManager.getFont("InternalFrame.titleFont"));
setPreferredSize(new Dimension(100, BUTTON_SIZE));
}
protected void uninstallListeners() {
// Get around protected method in superclass
super.uninstallListeners();
}
protected PropertyChangeListener createPropertyChangeListener() {
return this;
}
protected LayoutManager createLayout() {
return this;
}
JPopupMenu getSystemMenu() {
return systemMenu;
}
protected void assembleSystemMenu() {
systemMenu = new JPopupMenu();
JMenuItem mi = systemMenu.add(restoreAction);
mi.setMnemonic(getButtonMnemonic("restore"));
mi = systemMenu.add(moveAction);
mi.setMnemonic(getButtonMnemonic("move"));
mi = systemMenu.add(sizeAction);
mi.setMnemonic(getButtonMnemonic("size"));
mi = systemMenu.add(iconifyAction);
mi.setMnemonic(getButtonMnemonic("minimize"));
mi = systemMenu.add(maximizeAction);
mi.setMnemonic(getButtonMnemonic("maximize"));
systemMenu.add(new JSeparator());
mi = systemMenu.add(closeAction);
mi.setMnemonic(getButtonMnemonic("close"));
systemButton = new SystemButton();
systemButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
systemMenu.show(systemButton, 0, BUTTON_SIZE);
}
});
systemButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent evt) {
try {
frame.setSelected(true);
} catch (PropertyVetoException pve) {
}
if ((evt.getClickCount() == 2)) {
closeAction.actionPerformed(new
ActionEvent(evt.getSource(),
ActionEvent.ACTION_PERFORMED,
null, evt.getWhen(), 0));
systemMenu.setVisible(false);
}
}
});
}
private static int getButtonMnemonic(String button) {
try {
return Integer.parseInt(UIManager.getString(
"InternalFrameTitlePane." + button + "Button.mnemonic"));
} catch (NumberFormatException e) {
return -1;
}
}
protected void createButtons() {
minimizeButton = new MinimizeButton();
minimizeButton.addActionListener(iconifyAction);
maximizeButton = new MaximizeButton();
maximizeButton.addActionListener(maximizeAction);
}
protected void addSubComponents() {
title = new Title(frame.getTitle());
title.setFont(getFont());
add(systemButton);
add(title);
add(minimizeButton);
add(maximizeButton);
}
public void paintComponent(Graphics g) {
}
void setColors(Color c, Color h, Color s) {
color = c;
highlight = h;
shadow = s;
}
public void actionPerformed(ActionEvent e) {
}
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
JInternalFrame f = (JInternalFrame)evt.getSource();
boolean value = false;
if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
repaint();
} else if (prop.equals("maximizable")) {
if ((Boolean)evt.getNewValue() == Boolean.TRUE)
add(maximizeButton);
else
remove(maximizeButton);
revalidate();
repaint();
} else if (prop.equals("iconable")) {
if ((Boolean)evt.getNewValue() == Boolean.TRUE)
add(minimizeButton);
else
remove(minimizeButton);
revalidate();
repaint();
} else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
repaint();
}
enableActions();
}
public void addLayoutComponent(String name, Component c) {}
public void removeLayoutComponent(Component c) {}
public Dimension preferredLayoutSize(Container c) {
return minimumLayoutSize(c);
}
public Dimension minimumLayoutSize(Container c) {
return new Dimension(100, BUTTON_SIZE);
}
public void layoutContainer(Container c) {
int w = getWidth();
systemButton.setBounds(0, 0, BUTTON_SIZE, BUTTON_SIZE);
int x = w - BUTTON_SIZE;
if(frame.isMaximizable()) {
maximizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE);
x -= BUTTON_SIZE;
} else if(maximizeButton.getParent() != null) {
maximizeButton.getParent().remove(maximizeButton);
}
if(frame.isIconifiable()) {
minimizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE);
x -= BUTTON_SIZE;
} else if(minimizeButton.getParent() != null) {
minimizeButton.getParent().remove(minimizeButton);
}
title.setBounds(BUTTON_SIZE, 0, x, BUTTON_SIZE);
}
protected void showSystemMenu(){
systemMenu.show(systemButton, 0, BUTTON_SIZE);
}
protected void hideSystemMenu(){
systemMenu.setVisible(false);
}
static Dimension buttonDimension = new Dimension(BUTTON_SIZE, BUTTON_SIZE);
private abstract class FrameButton extends JButton {
FrameButton() {
super();
setFocusPainted(false);
setBorderPainted(false);
}
public boolean isFocusTraversable() {
return false;
}
public void requestFocus() {
// ignore request.
}
public Dimension getMinimumSize() {
return buttonDimension;
}
public Dimension getPreferredSize() {
return buttonDimension;
}
public void paintComponent(Graphics g) {
Dimension d = getSize();
int maxX = d.width - 1;
int maxY = d.height - 1;
// draw background
g.setColor(color);
g.fillRect(1, 1, d.width, d.height);
// draw border
boolean pressed = getModel().isPressed();
g.setColor(pressed ? shadow : highlight);
g.drawLine(0, 0, maxX, 0);
g.drawLine(0, 0, 0, maxY);
g.setColor(pressed ? highlight : shadow);
g.drawLine(1, maxY, maxX, maxY);
g.drawLine(maxX, 1, maxX, maxY);
}
}
private class MinimizeButton extends FrameButton {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(highlight);
g.drawLine(7, 8, 7, 11);
g.drawLine(7, 8, 10, 8);
g.setColor(shadow);
g.drawLine(8, 11, 10, 11);
g.drawLine(11, 9, 11, 11);
}
}
private class MaximizeButton extends FrameButton {
public void paintComponent(Graphics g) {
super.paintComponent(g);
int max = BUTTON_SIZE - 5;
boolean isMaxed = frame.isMaximum();
g.setColor(isMaxed ? shadow : highlight);
g.drawLine(4, 4, 4, max);
g.drawLine(4, 4, max, 4);
g.setColor(isMaxed ? highlight : shadow);
g.drawLine(5, max, max, max);
g.drawLine(max, 5, max, max);
}
}
private class SystemButton extends FrameButton {
public boolean isFocusTraversable() { return false; }
public void requestFocus() {}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(highlight);
g.drawLine(4, 8, 4, 11);
g.drawLine(4, 8, BUTTON_SIZE - 5, 8);
g.setColor(shadow);
g.drawLine(5, 11, BUTTON_SIZE - 5, 11);
g.drawLine(BUTTON_SIZE - 5, 9, BUTTON_SIZE - 5, 11);
}
}
private class Title extends FrameButton {
Title(String title) {
super();
setText(title);
setHorizontalAlignment(SwingConstants.CENTER);
setBorder(BorderFactory.createBevelBorder(
BevelBorder.RAISED,
UIManager.getColor("activeCaptionBorder"),
UIManager.getColor("inactiveCaptionBorder")));
// Forward mouse events to titlebar for moves.
addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseMoved(MouseEvent e) {
forwardEventToParent(e);
}
});
addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
forwardEventToParent(e);
}
public void mousePressed(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseReleased(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseEntered(MouseEvent e) {
forwardEventToParent(e);
}
public void mouseExited(MouseEvent e) {
forwardEventToParent(e);
}
});
}
void forwardEventToParent(MouseEvent e) {
MouseEvent newEvent = new MouseEvent(
getParent(), e.getID(), e.getWhen(), e.getModifiers(),
e.getX(), e.getY(), e.getXOnScreen(),
e.getYOnScreen(), e.getClickCount(),
e.isPopupTrigger(), MouseEvent.NOBUTTON);
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
meAccessor.setCausedByTouchEvent(newEvent,
meAccessor.isCausedByTouchEvent(e));
getParent().dispatchEvent(newEvent);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (frame.isSelected()) {
g.setColor(UIManager.getColor("activeCaptionText"));
} else {
g.setColor(UIManager.getColor("inactiveCaptionText"));
}
Dimension d = getSize();
String frameTitle = frame.getTitle();
if (frameTitle != null) {
MotifGraphicsUtils.drawStringInRect(frame, g, frameTitle,
0, 0, d.width, d.height,
SwingConstants.CENTER);
}
}
}
}

View File

@@ -0,0 +1,223 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.EventListener;
import javax.swing.plaf.basic.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
/**
* A Motif L&F implementation of InternalFrame.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Tom Ball
*/
public class MotifInternalFrameUI extends BasicInternalFrameUI {
Color color;
Color highlight;
Color shadow;
MotifInternalFrameTitlePane titlePane;
/**
* As of Java 2 platform v1.3 this previously undocumented field is no
* longer used.
* Key bindings are now defined by the LookAndFeel, please refer to
* the key bindings specification for further details.
*
* @deprecated As of Java 2 platform v1.3.
*/
@Deprecated
protected KeyStroke closeMenuKey;
/////////////////////////////////////////////////////////////////////////////
// ComponentUI Interface Implementation methods
/////////////////////////////////////////////////////////////////////////////
public static ComponentUI createUI(JComponent w) {
return new MotifInternalFrameUI((JInternalFrame)w);
}
public MotifInternalFrameUI(JInternalFrame w) {
super(w);
}
public void installUI(JComponent c) {
super.installUI(c);
setColors((JInternalFrame)c);
}
protected void installDefaults() {
Border frameBorder = frame.getBorder();
frame.setLayout(internalFrameLayout = createLayoutManager());
if (frameBorder == null || frameBorder instanceof UIResource) {
frame.setBorder(new MotifBorders.InternalFrameBorder(frame));
}
}
protected void installKeyboardActions(){
super.installKeyboardActions();
// We replace the
// we use JPopup in our TitlePane so need escape support
closeMenuKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
}
protected void uninstallDefaults() {
LookAndFeel.uninstallBorder(frame);
frame.setLayout(null);
internalFrameLayout = null;
}
private JInternalFrame getFrame(){
return frame;
}
public JComponent createNorthPane(JInternalFrame w) {
titlePane = new MotifInternalFrameTitlePane(w);
return titlePane;
}
public Dimension getMaximumSize(JComponent x) {
return Toolkit.getDefaultToolkit().getScreenSize();
}
protected void uninstallKeyboardActions(){
super.uninstallKeyboardActions();
if (isKeyBindingRegistered()){
JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
SwingUtilities.replaceUIActionMap(di, null);
SwingUtilities.replaceUIInputMap(di, JComponent.WHEN_IN_FOCUSED_WINDOW,
null);
}
}
protected void setupMenuOpenKey(){
super.setupMenuOpenKey();
ActionMap map = SwingUtilities.getUIActionMap(frame);
if (map != null) {
// BasicInternalFrameUI creates an action with the same name, we override
// it as MotifInternalFrameTitlePane has a titlePane ivar that shadows the
// titlePane ivar in BasicInternalFrameUI, making supers action throw
// an NPE for us.
map.put("showSystemMenu", new AbstractAction(){
public void actionPerformed(ActionEvent e){
titlePane.showSystemMenu();
}
public boolean isEnabled(){
return isKeyBindingActive();
}
});
}
}
protected void setupMenuCloseKey(){
ActionMap map = SwingUtilities.getUIActionMap(frame);
if (map != null) {
map.put("hideSystemMenu", new AbstractAction(){
public void actionPerformed(ActionEvent e){
titlePane.hideSystemMenu();
}
public boolean isEnabled(){
return isKeyBindingActive();
}
});
}
// Set up the bindings for the DesktopIcon, it is odd that
// we install them, and not the desktop icon.
JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
InputMap diInputMap = SwingUtilities.getUIInputMap
(di, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (diInputMap == null) {
Object[] bindings = (Object[])UIManager.get
("DesktopIcon.windowBindings");
if (bindings != null) {
diInputMap = LookAndFeel.makeComponentInputMap(di, bindings);
SwingUtilities.replaceUIInputMap(di, JComponent.
WHEN_IN_FOCUSED_WINDOW,
diInputMap);
}
}
ActionMap diActionMap = SwingUtilities.getUIActionMap(di);
if (diActionMap == null) {
diActionMap = new ActionMapUIResource();
diActionMap.put("hideSystemMenu", new AbstractAction(){
public void actionPerformed(ActionEvent e){
JInternalFrame.JDesktopIcon icon = getFrame().
getDesktopIcon();
MotifDesktopIconUI micon = (MotifDesktopIconUI)icon.
getUI();
micon.hideSystemMenu();
}
public boolean isEnabled(){
return isKeyBindingActive();
}
});
SwingUtilities.replaceUIActionMap(di, diActionMap);
}
}
/** This method is called when the frame becomes selected.
*/
protected void activateFrame(JInternalFrame f) {
super.activateFrame(f);
setColors(f);
}
/** This method is called when the frame is no longer selected.
*/
protected void deactivateFrame(JInternalFrame f) {
setColors(f);
super.deactivateFrame(f);
}
void setColors(JInternalFrame frame) {
if (frame.isSelected()) {
color = UIManager.getColor("InternalFrame.activeTitleBackground");
} else {
color = UIManager.getColor("InternalFrame.inactiveTitleBackground");
}
highlight = color.brighter();
shadow = color.darker().darker();
titlePane.setColors(color, highlight, shadow);
}
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.plaf.ComponentUI;
/**
* A Motif L&F implementation of LabelUI.
* This merely sets up new default values in MotifLookAndFeel.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Amy Fowler
*/
public class MotifLabelUI extends BasicLabelUI
{
private static final Object MOTIF_LABEL_UI_KEY = new Object();
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifLabelUI motifLabelUI =
(MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY);
if (motifLabelUI == null) {
motifLabelUI = new MotifLabelUI();
appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI);
}
return motifLabelUI;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.*;
import java.io.Serializable;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicMenuBarUI;
//REMIND
import javax.swing.plaf.basic.*;
/**
* A Windows L&F implementation of MenuBarUI. This implementation
* is a "combined" view/controller.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Georges Saab
* @author Rich Schiavi
*/
public class MotifMenuBarUI extends BasicMenuBarUI
{
public static ComponentUI createUI(JComponent x) {
return new MotifMenuBarUI();
}
} // end class

View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicMenuItemUI;
/**
* MotifMenuItem implementation
* <p>
*
* @author Rich Schiavi
* @author Georges Saab
*/
public class MotifMenuItemUI extends BasicMenuItemUI
{
protected ChangeListener changeListener;
public static ComponentUI createUI(JComponent c)
{
return new MotifMenuItemUI();
}
protected void installListeners() {
super.installListeners();
changeListener = createChangeListener(menuItem);
menuItem.addChangeListener(changeListener);
}
protected void uninstallListeners() {
super.uninstallListeners();
menuItem.removeChangeListener(changeListener);
}
protected ChangeListener createChangeListener(JComponent c) {
return new ChangeHandler();
}
protected MouseInputListener createMouseInputListener(JComponent c) {
return new MouseInputHandler();
}
protected class ChangeHandler implements ChangeListener {
public void stateChanged(ChangeEvent e) {
JMenuItem c = (JMenuItem)e.getSource();
LookAndFeel.installProperty(c, "borderPainted",
Boolean.valueOf(c.isArmed() || c.isSelected()));
}
}
protected class MouseInputHandler implements MouseInputListener {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(getPath());
}
public void mouseReleased(MouseEvent e) {
MenuSelectionManager manager =
MenuSelectionManager.defaultManager();
JMenuItem menuItem = (JMenuItem)e.getComponent();
Point p = e.getPoint();
if(p.x >= 0 && p.x < menuItem.getWidth() &&
p.y >= 0 && p.y < menuItem.getHeight()) {
manager.clearSelectedPath();
menuItem.doClick(0);
} else {
manager.processMouseEvent(e);
}
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseDragged(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseMoved(MouseEvent e) { }
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.event.*;
import javax.swing.MenuSelectionManager;
/**
* A default MouseListener for menu elements
*
* @author Arnaud Weber
*/
class MotifMenuMouseListener extends MouseAdapter {
public void mousePressed(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseReleased(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseEntered(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseExited(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.event.*;
import javax.swing.MenuSelectionManager;
/**
* A default MouseListener for menu elements
*
* @author Arnaud Weber
*/
class MotifMenuMouseMotionListener implements MouseMotionListener {
public void mouseDragged(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseMoved(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
}

View File

@@ -0,0 +1,151 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.basic.BasicMenuUI;
/**
* A Motif L&F implementation of MenuUI.
* <p>
*
* @author Georges Saab
* @author Rich Schiavi
*/
public class MotifMenuUI extends BasicMenuUI
{
public static ComponentUI createUI( JComponent x ) {
return new MotifMenuUI();
}
// These should not be necessary because BasicMenuUI does this,
// and this class overrides createChangeListener.
// protected void installListeners() {
// super.installListeners();
// changeListener = createChangeListener(menuItem);
// menuItem.addChangeListener(changeListener);
// }
//
// protected void uninstallListeners() {
// super.uninstallListeners();
// menuItem.removeChangeListener(changeListener);
// }
protected ChangeListener createChangeListener(JComponent c) {
return new MotifChangeHandler((JMenu)c, this);
}
private boolean popupIsOpen(JMenu m,MenuElement me[]) {
int i;
JPopupMenu pm = m.getPopupMenu();
for(i=me.length-1;i>=0;i--) {
if(me[i].getComponent() == pm)
return true;
}
return false;
}
protected MouseInputListener createMouseInputListener(JComponent c) {
return new MouseInputHandler();
}
public class MotifChangeHandler extends ChangeHandler {
public MotifChangeHandler(JMenu m, MotifMenuUI ui) {
super(m, ui);
}
public void stateChanged(ChangeEvent e) {
JMenuItem c = (JMenuItem)e.getSource();
if (c.isArmed() || c.isSelected()) {
c.setBorderPainted(true);
// c.repaint();
} else {
c.setBorderPainted(false);
}
super.stateChanged(e);
}
}
protected class MouseInputHandler implements MouseInputListener {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
JMenu menu = (JMenu)e.getComponent();
if(menu.isEnabled()) {
if(menu.isTopLevelMenu()) {
if(menu.isSelected()) {
manager.clearSelectedPath();
} else {
Container cnt = menu.getParent();
if(cnt != null && cnt instanceof JMenuBar) {
MenuElement me[] = new MenuElement[2];
me[0]=(MenuElement)cnt;
me[1]=menu;
manager.setSelectedPath(me);
}
}
}
MenuElement path[] = getPath();
if (path.length > 0) {
MenuElement newPath[] = new MenuElement[path.length+1];
System.arraycopy(path,0,newPath,0,path.length);
newPath[path.length] = menu.getPopupMenu();
manager.setSelectedPath(newPath);
}
}
}
public void mouseReleased(MouseEvent e) {
MenuSelectionManager manager =
MenuSelectionManager.defaultManager();
JMenuItem menuItem = (JMenuItem)e.getComponent();
Point p = e.getPoint();
if(!(p.x >= 0 && p.x < menuItem.getWidth() &&
p.y >= 0 && p.y < menuItem.getHeight())) {
manager.processMouseEvent(e);
}
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseDragged(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseMoved(MouseEvent e) { }
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.plaf.basic.BasicOptionPaneUI;
import javax.swing.plaf.ComponentUI;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
/**
* Provides the CDE/Motif look and feel for a JOptionPane.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Scott Violet
*/
public class MotifOptionPaneUI extends BasicOptionPaneUI
{
/**
* Creates a new MotifOptionPaneUI instance.
*/
public static ComponentUI createUI(JComponent x) {
return new MotifOptionPaneUI();
}
/**
* Creates and returns a Container containin the buttons. The buttons
* are created by calling <code>getButtons</code>.
*/
protected Container createButtonArea() {
Container b = super.createButtonArea();
if(b != null && b.getLayout() instanceof ButtonAreaLayout) {
((ButtonAreaLayout)b.getLayout()).setCentersChildren(false);
}
return b;
}
/**
* Returns null, CDE/Motif does not impose a minimum size.
*/
public Dimension getMinimumOptionPaneSize() {
return null;
}
protected Container createSeparator() {
return new JPanel() {
public Dimension getPreferredSize() {
return new Dimension(10, 2);
}
public void paint(Graphics g) {
int width = getWidth();
g.setColor(Color.darkGray);
g.drawLine(0, 0, width, 0);
g.setColor(Color.white);
g.drawLine(0, 1, width, 1);
}
};
}
/**
* Creates and adds a JLabel representing the icon returned from
* <code>getIcon</code> to <code>top</code>. This is messaged from
* <code>createMessageArea</code>
*/
protected void addIcon(Container top) {
/* Create the icon. */
Icon sideIcon = getIcon();
if (sideIcon != null) {
JLabel iconLabel = new JLabel(sideIcon);
iconLabel.setVerticalAlignment(SwingConstants.CENTER);
top.add(iconLabel, "West");
}
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicPasswordFieldUI;
/**
* Provides the Motif look and feel for a password field.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Timothy Prinzing
*/
public class MotifPasswordFieldUI extends BasicPasswordFieldUI {
/**
* Creates a UI for a JPasswordField.
*
* @param c the JPasswordField
* @return the UI
*/
public static ComponentUI createUI(JComponent c) {
return new MotifPasswordFieldUI();
}
/**
* Creates the object to use for a caret. By default an
* instance of MotifTextUI.MotifCaret is created. This method
* can be redefined to provide something else that implements
* the Caret interface.
*
* @return the caret object
*/
protected Caret createCaret() {
return MotifTextUI.createCaret();
}
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.plaf.*;
/**
* A Motif L&F implementation of PopupMenuSeparatorUI. This implementation
* is a "combined" view/controller.
*
* @author Jeff Shapiro
*/
public class MotifPopupMenuSeparatorUI extends MotifSeparatorUI
{
public static ComponentUI createUI( JComponent c )
{
return new MotifPopupMenuSeparatorUI();
}
public void paint( Graphics g, JComponent c )
{
Dimension s = c.getSize();
g.setColor( c.getForeground() );
g.drawLine( 0, 0, s.width, 0 );
g.setColor( c.getBackground() );
g.drawLine( 0, 1, s.width, 1 );
}
public Dimension getPreferredSize( JComponent c )
{
return new Dimension( 0, 2 );
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.swing.SwingUtilities2;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicPopupMenuUI;
/**
* A Motif L&F implementation of PopupMenuUI.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Georges Saab
* @author Rich Schiavi
*/
public class MotifPopupMenuUI extends BasicPopupMenuUI {
private static Border border = null;
private Font titleFont = null;
public static ComponentUI createUI(JComponent x) {
return new MotifPopupMenuUI();
}
/* This has to deal with the fact that the title may be wider than
the widest child component.
*/
public Dimension getPreferredSize(JComponent c) {
LayoutManager layout = c.getLayout();
Dimension d = layout.preferredLayoutSize(c);
String title = ((JPopupMenu)c).getLabel();
if (titleFont == null) {
UIDefaults table = UIManager.getLookAndFeelDefaults();
titleFont = table.getFont("PopupMenu.font");
}
FontMetrics fm = c.getFontMetrics(titleFont);
int stringWidth = 0;
if (title!=null) {
stringWidth += SwingUtilities2.stringWidth(c, fm, title);
}
if (d.width < stringWidth) {
d.width = stringWidth + 8;
Insets i = c.getInsets();
if (i!=null) {
d.width += i.left + i.right;
}
if (border != null) {
i = border.getBorderInsets(c);
d.width += i.left + i.right;
}
return d;
}
return null;
}
protected ChangeListener createChangeListener(JPopupMenu m) {
return new ChangeListener() {
public void stateChanged(ChangeEvent e) {}
};
}
public boolean isPopupTrigger(MouseEvent e) {
return ((e.getID()==MouseEvent.MOUSE_PRESSED)
&& ((e.getModifiers() & MouseEvent.BUTTON3_MASK)!=0));
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import java.io.Serializable;
import javax.swing.plaf.basic.BasicProgressBarUI;
/**
* A Motif ProgressBarUI.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Michael C. Albers
*/
public class MotifProgressBarUI extends BasicProgressBarUI
{
/**
* Creates the ProgressBar's UI
*/
public static ComponentUI createUI(JComponent x) {
return new MotifProgressBarUI();
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI;
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable;
/**
* MotifRadioButtonMenuItem implementation
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Georges Saab
* @author Rich Schiavi
*/
public class MotifRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI
{
protected ChangeListener changeListener;
public static ComponentUI createUI(JComponent b) {
return new MotifRadioButtonMenuItemUI();
}
protected void installListeners() {
super.installListeners();
changeListener = createChangeListener(menuItem);
menuItem.addChangeListener(changeListener);
}
protected void uninstallListeners() {
super.uninstallListeners();
menuItem.removeChangeListener(changeListener);
}
protected ChangeListener createChangeListener(JComponent c) {
return new ChangeHandler();
}
protected class ChangeHandler implements ChangeListener, Serializable {
public void stateChanged(ChangeEvent e) {
JMenuItem c = (JMenuItem)e.getSource();
LookAndFeel.installProperty(c, "borderPainted", c.isArmed());
}
}
protected MouseInputListener createMouseInputListener(JComponent c) {
return new MouseInputHandler();
}
protected class MouseInputHandler implements MouseInputListener {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(getPath());
}
public void mouseReleased(MouseEvent e) {
MenuSelectionManager manager =
MenuSelectionManager.defaultManager();
JMenuItem menuItem = (JMenuItem)e.getComponent();
Point p = e.getPoint();
if(p.x >= 0 && p.x < menuItem.getWidth() &&
p.y >= 0 && p.y < menuItem.getHeight()) {
manager.clearSelectedPath();
menuItem.doClick(0);
} else {
manager.processMouseEvent(e);
}
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseDragged(MouseEvent e) {
MenuSelectionManager.defaultManager().processMouseEvent(e);
}
public void mouseMoved(MouseEvent e) { }
}
}

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.BasicRadioButtonUI;
import javax.swing.plaf.*;
import java.awt.*;
/**
* RadioButtonUI implementation for MotifRadioButtonUI
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Rich Schiavi
*/
public class MotifRadioButtonUI extends BasicRadioButtonUI {
private static final Object MOTIF_RADIO_BUTTON_UI_KEY = new Object();
protected Color focusColor;
private boolean defaults_initialized = false;
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifRadioButtonUI motifRadioButtonUI =
(MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY);
if (motifRadioButtonUI == null) {
motifRadioButtonUI = new MotifRadioButtonUI();
appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI);
}
return motifRadioButtonUI;
}
// ********************************
// Install Defaults
// ********************************
public void installDefaults(AbstractButton b) {
super.installDefaults(b);
if(!defaults_initialized) {
focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
defaults_initialized = true;
}
}
protected void uninstallDefaults(AbstractButton b) {
super.uninstallDefaults(b);
defaults_initialized = false;
}
// ********************************
// Default Accessors
// ********************************
protected Color getFocusColor() {
return focusColor;
}
// ********************************
// Paint Methods
// ********************************
protected void paintFocus(Graphics g, Rectangle t, Dimension d){
g.setColor(getFocusColor());
g.drawRect(0,0,d.width-1,d.height-1);
}
}

View File

@@ -0,0 +1,211 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicArrowButton;
import java.awt.*;
import java.awt.event.*;
/**
* Motif scroll bar button.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*/
public class MotifScrollBarButton extends BasicArrowButton
{
private Color darkShadow = UIManager.getColor("controlShadow");
private Color lightShadow = UIManager.getColor("controlLtHighlight");
public MotifScrollBarButton(int direction)
{
super(direction);
switch (direction) {
case NORTH:
case SOUTH:
case EAST:
case WEST:
this.direction = direction;
break;
default:
throw new IllegalArgumentException("invalid direction");
}
setRequestFocusEnabled(false);
setOpaque(true);
setBackground(UIManager.getColor("ScrollBar.background"));
setForeground(UIManager.getColor("ScrollBar.foreground"));
}
public Dimension getPreferredSize() {
switch (direction) {
case NORTH:
case SOUTH:
return new Dimension(11, 12);
case EAST:
case WEST:
default:
return new Dimension(12, 11);
}
}
public Dimension getMinimumSize() {
return getPreferredSize();
}
public Dimension getMaximumSize() {
return getPreferredSize();
}
public boolean isFocusTraversable() {
return false;
}
public void paint(Graphics g)
{
int w = getWidth();
int h = getHeight();
if (isOpaque()) {
g.setColor(getBackground());
g.fillRect(0, 0, w, h);
}
boolean isPressed = getModel().isPressed();
Color lead = (isPressed) ? darkShadow : lightShadow;
Color trail = (isPressed) ? lightShadow : darkShadow;
Color fill = getBackground();
int cx = w / 2;
int cy = h / 2;
int s = Math.min(w, h);
switch (direction) {
case NORTH:
g.setColor(lead);
g.drawLine(cx, 0, cx, 0);
for (int x = cx - 1, y = 1, dx = 1; y <= s - 2; y += 2) {
g.setColor(lead);
g.drawLine(x, y, x, y);
if (y >= (s - 2)) {
g.drawLine(x, y + 1, x, y + 1);
}
g.setColor(fill);
g.drawLine(x + 1, y, x + dx, y);
if (y < (s - 2)) {
g.drawLine(x, y + 1, x + dx + 1, y + 1);
}
g.setColor(trail);
g.drawLine(x + dx + 1, y, x + dx + 1, y);
if (y >= (s - 2)) {
g.drawLine(x + 1, y + 1, x + dx + 1, y + 1);
}
dx += 2;
x -= 1;
}
break;
case SOUTH:
g.setColor(trail);
g.drawLine(cx, s, cx, s);
for (int x = cx - 1, y = s - 1, dx = 1; y >= 1; y -= 2) {
g.setColor(lead);
g.drawLine(x, y, x, y);
if (y <= 2) {
g.drawLine(x, y - 1, x + dx + 1, y - 1);
}
g.setColor(fill);
g.drawLine(x + 1, y, x + dx, y);
if (y > 2) {
g.drawLine(x, y - 1, x + dx + 1, y - 1);
}
g.setColor(trail);
g.drawLine(x + dx + 1, y, x + dx + 1, y);
dx += 2;
x -= 1;
}
break;
case EAST:
g.setColor(lead);
g.drawLine(s, cy, s, cy);
for (int y = cy - 1, x = s - 1, dy = 1; x >= 1; x -= 2) {
g.setColor(lead);
g.drawLine(x, y, x, y);
if (x <= 2) {
g.drawLine(x - 1, y, x - 1, y + dy + 1);
}
g.setColor(fill);
g.drawLine(x, y + 1, x, y + dy);
if (x > 2) {
g.drawLine(x - 1, y, x - 1, y + dy + 1);
}
g.setColor(trail);
g.drawLine(x, y + dy + 1, x, y + dy + 1);
dy += 2;
y -= 1;
}
break;
case WEST:
g.setColor(trail);
g.drawLine(0, cy, 0, cy);
for (int y = cy - 1, x = 1, dy = 1; x <= s - 2; x += 2) {
g.setColor(lead);
g.drawLine(x, y, x, y);
if (x >= (s - 2)) {
g.drawLine(x + 1, y, x + 1, y);
}
g.setColor(fill);
g.drawLine(x, y + 1, x, y + dy);
if (x < (s - 2)) {
g.drawLine(x + 1, y, x + 1, y + dy + 1);
}
g.setColor(trail);
g.drawLine(x, y + dy + 1, x, y + dy + 1);
if (x >= (s - 2)) {
g.drawLine(x + 1, y + 1, x + 1, y + dy + 1);
}
dy += 2;
y -= 1;
}
break;
}
}
}

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
import static sun.swing.SwingUtilities2.drawHLine;
import static sun.swing.SwingUtilities2.drawVLine;
/**
* Implementation of ScrollBarUI for the Motif Look and Feel
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Rich Schiavi
* @author Hans Muller
*/
public class MotifScrollBarUI extends BasicScrollBarUI
{
public static ComponentUI createUI(JComponent c) {
return new MotifScrollBarUI();
}
public Dimension getPreferredSize(JComponent c) {
Insets insets = c.getInsets();
int dx = insets.left + insets.right;
int dy = insets.top + insets.bottom;
return (scrollbar.getOrientation() == JScrollBar.VERTICAL)
? new Dimension(dx + 11, dy + 33)
: new Dimension(dx + 33, dy + 11);
}
protected JButton createDecreaseButton(int orientation) {
return new MotifScrollBarButton(orientation);
}
protected JButton createIncreaseButton(int orientation) {
return new MotifScrollBarButton(orientation);
}
public void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
g.setColor(trackColor);
g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
}
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
return;
}
int w = thumbBounds.width;
int h = thumbBounds.height;
g.translate(thumbBounds.x, thumbBounds.y);
g.setColor(thumbColor);
g.fillRect(0, 0, w - 1, h - 1);
g.setColor(thumbHighlightColor);
drawVLine(g, 0, 0, h - 1);
drawHLine(g, 1, w - 1, 0);
g.setColor(thumbLightShadowColor);
drawHLine(g, 1, w - 1, h - 1);
drawVLine(g, w - 1, 1, h - 2);
g.translate(-thumbBounds.x, -thumbBounds.y);
}
}

View File

@@ -0,0 +1,147 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicScrollPaneUI;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
/**
* A CDE/Motif L&F implementation of ScrollPaneUI.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Hans Muller
*/
public class MotifScrollPaneUI extends BasicScrollPaneUI
{
private final static Border vsbMarginBorderR = new EmptyBorder(0, 4, 0, 0);
private final static Border vsbMarginBorderL = new EmptyBorder(0, 0, 0, 4);
private final static Border hsbMarginBorder = new EmptyBorder(4, 0, 0, 0);
private CompoundBorder vsbBorder;
private CompoundBorder hsbBorder;
private PropertyChangeListener propertyChangeHandler;
@Override
protected void installListeners(JScrollPane scrollPane) {
super.installListeners(scrollPane);
propertyChangeHandler = createPropertyChangeHandler();
scrollPane.addPropertyChangeListener(propertyChangeHandler);
}
@Override
protected void uninstallListeners(JComponent scrollPane) {
super.uninstallListeners(scrollPane);
scrollPane.removePropertyChangeListener(propertyChangeHandler);
}
private PropertyChangeListener createPropertyChangeHandler() {
return new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (propertyName.equals("componentOrientation")) {
JScrollPane pane = (JScrollPane)e.getSource();
JScrollBar vsb = pane.getVerticalScrollBar();
if (vsb != null && vsbBorder != null &&
vsb.getBorder() == vsbBorder) {
// The Border on the verticall scrollbar matches
// what we installed, reset it.
if (MotifGraphicsUtils.isLeftToRight(pane)) {
vsbBorder = new CompoundBorder(vsbMarginBorderR,
vsbBorder.getInsideBorder());
} else {
vsbBorder = new CompoundBorder(vsbMarginBorderL,
vsbBorder.getInsideBorder());
}
vsb.setBorder(vsbBorder);
}
}
}};
}
@Override
protected void installDefaults(JScrollPane scrollpane) {
super.installDefaults(scrollpane);
JScrollBar vsb = scrollpane.getVerticalScrollBar();
if (vsb != null) {
if (MotifGraphicsUtils.isLeftToRight(scrollpane)) {
vsbBorder = new CompoundBorder(vsbMarginBorderR,
vsb.getBorder());
}
else {
vsbBorder = new CompoundBorder(vsbMarginBorderL,
vsb.getBorder());
}
vsb.setBorder(vsbBorder);
}
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
if (hsb != null) {
hsbBorder = new CompoundBorder(hsbMarginBorder, hsb.getBorder());
hsb.setBorder(hsbBorder);
}
}
@Override
protected void uninstallDefaults(JScrollPane c) {
super.uninstallDefaults(c);
JScrollBar vsb = scrollpane.getVerticalScrollBar();
if (vsb != null) {
if (vsb.getBorder() == vsbBorder) {
vsb.setBorder(null);
}
vsbBorder = null;
}
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
if (hsb != null) {
if (hsb.getBorder() == hsbBorder) {
hsb.setBorder(null);
}
hsbBorder = null;
}
}
public static ComponentUI createUI(JComponent x) {
return new MotifScrollPaneUI();
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicSeparatorUI;
/**
* A Motif L&F implementation of SeparatorUI. This implementation
* is a "combined" view/controller.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Georges Saab
* @author Jeff Shapiro
*/
public class MotifSeparatorUI extends BasicSeparatorUI
{
public static ComponentUI createUI( JComponent c )
{
return new MotifSeparatorUI();
}
}

View File

@@ -0,0 +1,162 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JComponent;
import javax.swing.JSlider;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSliderUI;
import static sun.swing.SwingUtilities2.drawHLine;
import static sun.swing.SwingUtilities2.drawVLine;
/**
* Motif Slider
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Jeff Dinkins
*/
public class MotifSliderUI extends BasicSliderUI {
static final Dimension PREFERRED_HORIZONTAL_SIZE = new Dimension(164, 15);
static final Dimension PREFERRED_VERTICAL_SIZE = new Dimension(15, 164);
static final Dimension MINIMUM_HORIZONTAL_SIZE = new Dimension(43, 15);
static final Dimension MINIMUM_VERTICAL_SIZE = new Dimension(15, 43);
/**
* MotifSliderUI Constructor
*/
public MotifSliderUI(JSlider b) {
super(b);
}
/**
* create a MotifSliderUI object
*/
public static ComponentUI createUI(JComponent b) {
return new MotifSliderUI((JSlider)b);
}
public Dimension getPreferredHorizontalSize() {
return PREFERRED_HORIZONTAL_SIZE;
}
public Dimension getPreferredVerticalSize() {
return PREFERRED_VERTICAL_SIZE;
}
public Dimension getMinimumHorizontalSize() {
return MINIMUM_HORIZONTAL_SIZE;
}
public Dimension getMinimumVerticalSize() {
return MINIMUM_VERTICAL_SIZE;
}
protected Dimension getThumbSize() {
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
return new Dimension( 30, 15 );
}
else {
return new Dimension( 15, 30 );
}
}
public void paintFocus(Graphics g) {
}
public void paintTrack(Graphics g) {
}
public void paintThumb(Graphics g) {
Rectangle knobBounds = thumbRect;
int x = knobBounds.x;
int y = knobBounds.y;
int w = knobBounds.width;
int h = knobBounds.height;
if ( slider.isEnabled() ) {
g.setColor(slider.getForeground());
}
else {
// PENDING(jeff) - the thumb should be dithered when disabled
g.setColor(slider.getForeground().darker());
}
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
g.translate(x, knobBounds.y-1);
// fill
g.fillRect(0, 1, w, h - 1);
// highlight
g.setColor(getHighlightColor());
drawHLine(g, 0, w - 1, 1); // top
drawVLine(g, 0, 1, h); // left
drawVLine(g, w / 2, 2, h - 1); // center
// shadow
g.setColor(getShadowColor());
drawHLine(g, 0, w - 1, h); // bottom
drawVLine(g, w - 1, 1, h); // right
drawVLine(g, w / 2 - 1, 2, h); // center
g.translate(-x, -(knobBounds.y-1));
}
else {
g.translate(knobBounds.x-1, 0);
// fill
g.fillRect(1, y, w - 1, h);
// highlight
g.setColor(getHighlightColor());
drawHLine(g, 1, w, y); // top
drawVLine(g, 1, y + 1, y + h - 1); // left
drawHLine(g, 2, w - 1, y + h / 2); // center
// shadow
g.setColor(getShadowColor());
drawHLine(g, 2, w, y + h - 1); // bottom
drawVLine(g, w, y + h - 1, y); // right
drawHLine(g, 2, w - 1, y + h / 2 - 1);// center
g.translate(-(knobBounds.x-1), 0);
}
}
}

View File

@@ -0,0 +1,295 @@
/*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JSplitPane;
import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
/**
* Divider used for Motif split pane.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Jeff Dinkins
*/
public class MotifSplitPaneDivider extends BasicSplitPaneDivider
{
/**
* Default cursor, supers is package private, so we have to have one
* too.
*/
private static final Cursor defaultCursor =
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
public static final int minimumThumbSize = 6;
public static final int defaultDividerSize = 18;
protected static final int pad = 6;
private int hThumbOffset = 30;
private int vThumbOffset = 40;
protected int hThumbWidth = 12;
protected int hThumbHeight = 18;
protected int vThumbWidth = 18;
protected int vThumbHeight = 12;
protected Color highlightColor;
protected Color shadowColor;
protected Color focusedColor;
/**
* Creates a new Motif SplitPaneDivider
*/
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
super(ui);
highlightColor = UIManager.getColor("SplitPane.highlight");
shadowColor = UIManager.getColor("SplitPane.shadow");
focusedColor = UIManager.getColor("SplitPane.activeThumb");
setDividerSize(hThumbWidth + pad);
}
/**
* overrides to hardcode the size of the divider
* PENDING(jeff) - rewrite JSplitPane so that this ins't needed
*/
public void setDividerSize(int newSize) {
Insets insets = getInsets();
int borderSize = 0;
if (getBasicSplitPaneUI().getOrientation() ==
JSplitPane.HORIZONTAL_SPLIT) {
if (insets != null) {
borderSize = insets.left + insets.right;
}
}
else if (insets != null) {
borderSize = insets.top + insets.bottom;
}
if (newSize < pad + minimumThumbSize + borderSize) {
setDividerSize(pad + minimumThumbSize + borderSize);
} else {
vThumbHeight = hThumbWidth = newSize - pad - borderSize;
super.setDividerSize(newSize);
}
}
/**
* Paints the divider.
*/
// PENDING(jeff) - the thumb's location and size is currently hard coded.
// It should be dynamic.
public void paint(Graphics g) {
Color bgColor = getBackground();
Dimension size = getSize();
// fill
g.setColor(getBackground());
g.fillRect(0, 0, size.width, size.height);
if(getBasicSplitPaneUI().getOrientation() ==
JSplitPane.HORIZONTAL_SPLIT) {
int center = size.width/2;
int x = center - hThumbWidth/2;
int y = hThumbOffset;
// split line
g.setColor(shadowColor);
g.drawLine(center-1, 0, center-1, size.height);
g.setColor(highlightColor);
g.drawLine(center, 0, center, size.height);
// draw thumb
g.setColor((splitPane.hasFocus()) ? focusedColor :
getBackground());
g.fillRect(x+1, y+1, hThumbWidth-2, hThumbHeight-1);
g.setColor(highlightColor);
g.drawLine(x, y, x+hThumbWidth-1, y); // top
g.drawLine(x, y+1, x, y+hThumbHeight-1); // left
g.setColor(shadowColor);
g.drawLine(x+1, y+hThumbHeight-1,
x+hThumbWidth-1, y+hThumbHeight-1); // bottom
g.drawLine(x+hThumbWidth-1, y+1,
x+hThumbWidth-1, y+hThumbHeight-2); // right
} else {
int center = size.height/2;
int x = size.width - vThumbOffset;
int y = size.height/2 - vThumbHeight/2;
// split line
g.setColor(shadowColor);
g.drawLine(0, center-1, size.width, center-1);
g.setColor(highlightColor);
g.drawLine(0, center, size.width, center);
// draw thumb
g.setColor((splitPane.hasFocus()) ? focusedColor :
getBackground());
g.fillRect(x+1, y+1, vThumbWidth-1, vThumbHeight-1);
g.setColor(highlightColor);
g.drawLine(x, y, x+vThumbWidth, y); // top
g.drawLine(x, y+1, x, y+vThumbHeight); // left
g.setColor(shadowColor);
g.drawLine(x+1, y+vThumbHeight,
x+vThumbWidth, y+vThumbHeight); // bottom
g.drawLine(x+vThumbWidth, y+1,
x+vThumbWidth, y+vThumbHeight-1); // right
}
super.paint(g);
}
/**
* The minimums size is the same as the preferredSize
*/
public Dimension getMinimumSize() {
return getPreferredSize();
}
/**
* Sets the SplitPaneUI that is using the receiver. This is completely
* overriden from super to create a different MouseHandler.
*/
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
if (splitPane != null) {
splitPane.removePropertyChangeListener(this);
if (mouseHandler != null) {
splitPane.removeMouseListener(mouseHandler);
splitPane.removeMouseMotionListener(mouseHandler);
removeMouseListener(mouseHandler);
removeMouseMotionListener(mouseHandler);
mouseHandler = null;
}
}
splitPaneUI = newUI;
if (newUI != null) {
splitPane = newUI.getSplitPane();
if (splitPane != null) {
if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
splitPane.addMouseListener(mouseHandler);
splitPane.addMouseMotionListener(mouseHandler);
addMouseListener(mouseHandler);
addMouseMotionListener(mouseHandler);
splitPane.addPropertyChangeListener(this);
if (splitPane.isOneTouchExpandable()) {
oneTouchExpandableChanged();
}
}
}
else {
splitPane = null;
}
}
/**
* Returns true if the point at <code>x</code>, <code>y</code>
* is inside the thumb.
*/
private boolean isInThumb(int x, int y) {
Dimension size = getSize();
int thumbX;
int thumbY;
int thumbWidth;
int thumbHeight;
if (getBasicSplitPaneUI().getOrientation() ==
JSplitPane.HORIZONTAL_SPLIT) {
int center = size.width/2;
thumbX = center - hThumbWidth/2;
thumbY = hThumbOffset;
thumbWidth = hThumbWidth;
thumbHeight = hThumbHeight;
}
else {
int center = size.height/2;
thumbX = size.width - vThumbOffset;
thumbY = size.height/2 - vThumbHeight/2;
thumbWidth = vThumbWidth;
thumbHeight = vThumbHeight;
}
return (x >= thumbX && x < (thumbX + thumbWidth) &&
y >= thumbY && y < (thumbY + thumbHeight));
}
//
// Two methods are exposed so that MotifMouseHandler can see the
// superclass protected ivars
//
private DragController getDragger() {
return dragger;
}
private JSplitPane getSplitPane() {
return splitPane;
}
/**
* MouseHandler is subclassed to only pass off to super if the mouse
* is in the thumb. Motif only allows dragging when the thumb is clicked
* in.
*/
private class MotifMouseHandler extends MouseHandler {
public void mousePressed(MouseEvent e) {
// Constrain the mouse pressed to the thumb.
if (e.getSource() == MotifSplitPaneDivider.this &&
getDragger() == null && getSplitPane().isEnabled() &&
isInThumb(e.getX(), e.getY())) {
super.mousePressed(e);
}
}
public void mouseMoved(MouseEvent e) {
if (getDragger() != null) {
return;
}
if (!isInThumb(e.getX(), e.getY())) {
if (getCursor() != defaultCursor) {
setCursor(defaultCursor);
}
return;
}
super.mouseMoved(e);
}
}
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.*;
import javax.swing.*;
import java.awt.*;
/**
* Motif rendition of a split pane.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Jeff Dinkins
*/
public class MotifSplitPaneUI extends BasicSplitPaneUI
{
public MotifSplitPaneUI() {
super();
}
/**
* Creates a new MotifSplitPaneUI instance
*/
public static ComponentUI createUI(JComponent x) {
return new MotifSplitPaneUI();
}
/**
* Creates the default divider.
*/
public BasicSplitPaneDivider createDefaultDivider() {
return new MotifSplitPaneDivider(this);
}
}

View File

@@ -0,0 +1,306 @@
/*
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
import java.io.Serializable;
/**
* A Motif L&F implementation of TabbedPaneUI.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Amy Fowler
* @author Philip Milne
*/
public class MotifTabbedPaneUI extends BasicTabbedPaneUI
{
// Instance variables initialized at installation
protected Color unselectedTabBackground;
protected Color unselectedTabForeground;
protected Color unselectedTabShadow;
protected Color unselectedTabHighlight;
// UI creation
public static ComponentUI createUI(JComponent tabbedPane) {
return new MotifTabbedPaneUI();
}
// UI Installation/De-installation
protected void installDefaults() {
super.installDefaults();
unselectedTabBackground = UIManager.getColor("TabbedPane.unselectedTabBackground");
unselectedTabForeground = UIManager.getColor("TabbedPane.unselectedTabForeground");
unselectedTabShadow = UIManager.getColor("TabbedPane.unselectedTabShadow");
unselectedTabHighlight = UIManager.getColor("TabbedPane.unselectedTabHighlight");
}
protected void uninstallDefaults() {
super.uninstallDefaults();
unselectedTabBackground = null;
unselectedTabForeground = null;
unselectedTabShadow = null;
unselectedTabHighlight = null;
}
// UI Rendering
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
int selectedIndex,
int x, int y, int w, int h) {
Rectangle selRect = selectedIndex < 0? null :
getTabBounds(selectedIndex, calcRect);
g.setColor(lightHighlight);
// Draw unbroken line if tabs are not on TOP, OR
// selected tab is not visible (SCROLL_TAB_LAYOUT)
//
if (tabPlacement != TOP || selectedIndex < 0 ||
(selRect.x < x || selRect.x > x + w)) {
g.drawLine(x, y, x+w-2, y);
} else {
// Break line to show visual connection to selected tab
g.drawLine(x, y, selRect.x - 1, y);
if (selRect.x + selRect.width < x + w - 2) {
g.drawLine(selRect.x + selRect.width, y,
x+w-2, y);
}
}
}
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
int selectedIndex,
int x, int y, int w, int h) {
Rectangle selRect = selectedIndex < 0? null :
getTabBounds(selectedIndex, calcRect);
g.setColor(shadow);
// Draw unbroken line if tabs are not on BOTTOM, OR
// selected tab is not visible (SCROLL_TAB_LAYOUT)
//
if (tabPlacement != BOTTOM || selectedIndex < 0 ||
(selRect.x < x || selRect.x > x + w)) {
g.drawLine(x+1, y+h-1, x+w-1, y+h-1);
} else {
// Break line to show visual connection to selected tab
g.drawLine(x+1, y+h-1, selRect.x - 1, y+h-1);
if (selRect.x + selRect.width < x + w - 2) {
g.drawLine(selRect.x + selRect.width, y+h-1, x+w-2, y+h-1);
}
}
}
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
int selectedIndex,
int x, int y, int w, int h) {
Rectangle selRect = selectedIndex < 0? null :
getTabBounds(selectedIndex, calcRect);
g.setColor(shadow);
// Draw unbroken line if tabs are not on RIGHT, OR
// selected tab is not visible (SCROLL_TAB_LAYOUT)
//
if (tabPlacement != RIGHT || selectedIndex < 0 ||
(selRect.y < y || selRect.y > y + h)) {
g.drawLine(x+w-1, y+1, x+w-1, y+h-1);
} else {
// Break line to show visual connection to selected tab
g.drawLine(x+w-1, y+1, x+w-1, selRect.y - 1);
if (selRect.y + selRect.height < y + h - 2 ) {
g.drawLine(x+w-1, selRect.y + selRect.height,
x+w-1, y+h-2);
}
}
}
protected void paintTabBackground(Graphics g,
int tabPlacement, int tabIndex,
int x, int y, int w, int h,
boolean isSelected ) {
g.setColor(isSelected? tabPane.getBackgroundAt(tabIndex) : unselectedTabBackground);
switch(tabPlacement) {
case LEFT:
g.fillRect(x+1, y+1, w-1, h-2);
break;
case RIGHT:
g.fillRect(x, y+1, w-1, h-2);
break;
case BOTTOM:
g.fillRect(x+1, y, w-2, h-3);
g.drawLine(x+2, y+h-3, x+w-3, y+h-3);
g.drawLine(x+3, y+h-2, x+w-4, y+h-2);
break;
case TOP:
default:
g.fillRect(x+1, y+3, w-2, h-3);
g.drawLine(x+2, y+2, x+w-3, y+2);
g.drawLine(x+3, y+1, x+w-4, y+1);
}
}
protected void paintTabBorder(Graphics g,
int tabPlacement, int tabIndex,
int x, int y, int w, int h,
boolean isSelected) {
g.setColor(isSelected? lightHighlight : unselectedTabHighlight);
switch(tabPlacement) {
case LEFT:
g.drawLine(x, y+2, x, y+h-3);
g.drawLine(x+1, y+1, x+1, y+2);
g.drawLine(x+2, y, x+2, y+1);
g.drawLine(x+3, y, x+w-1, y);
g.setColor(isSelected? shadow : unselectedTabShadow);
g.drawLine(x+1, y+h-3, x+1, y+h-2);
g.drawLine(x+2, y+h-2, x+2, y+h-1);
g.drawLine(x+3, y+h-1, x+w-1, y+h-1);
break;
case RIGHT:
g.drawLine(x, y, x+w-3, y);
g.setColor(isSelected? shadow : unselectedTabShadow);
g.drawLine(x+w-3, y, x+w-3, y+1);
g.drawLine(x+w-2, y+1, x+w-2, y+2);
g.drawLine(x+w-1, y+2, x+w-1, y+h-3);
g.drawLine(x+w-2, y+h-3, x+w-2, y+h-2);
g.drawLine(x+w-3, y+h-2, x+w-3, y+h-1);
g.drawLine(x, y+h-1, x+w-3, y+h-1);
break;
case BOTTOM:
g.drawLine(x, y, x, y+h-3);
g.drawLine(x+1, y+h-3, x+1, y+h-2);
g.drawLine(x+2, y+h-2, x+2, y+h-1);
g.setColor(isSelected? shadow : unselectedTabShadow);
g.drawLine(x+3, y+h-1, x+w-4, y+h-1);
g.drawLine(x+w-3, y+h-2, x+w-3, y+h-1);
g.drawLine(x+w-2, y+h-3, x+w-2, y+h-2);
g.drawLine(x+w-1, y, x+w-1, y+h-3);
break;
case TOP:
default:
g.drawLine(x, y+2, x, y+h-1);
g.drawLine(x+1, y+1, x+1, y+2);
g.drawLine(x+2, y, x+2, y+1);
g.drawLine(x+3, y, x+w-4, y);
g.setColor(isSelected? shadow : unselectedTabShadow);
g.drawLine(x+w-3, y, x+w-3, y+1);
g.drawLine(x+w-2, y+1, x+w-2, y+2);
g.drawLine(x+w-1, y+2, x+w-1, y+h-1);
}
}
protected void paintFocusIndicator(Graphics g, int tabPlacement,
Rectangle[] rects, int tabIndex,
Rectangle iconRect, Rectangle textRect,
boolean isSelected) {
Rectangle tabRect = rects[tabIndex];
if (tabPane.hasFocus() && isSelected) {
int x, y, w, h;
g.setColor(focus);
switch(tabPlacement) {
case LEFT:
x = tabRect.x + 3;
y = tabRect.y + 3;
w = tabRect.width - 6;
h = tabRect.height - 7;
break;
case RIGHT:
x = tabRect.x + 2;
y = tabRect.y + 3;
w = tabRect.width - 6;
h = tabRect.height - 7;
break;
case BOTTOM:
x = tabRect.x + 3;
y = tabRect.y + 2;
w = tabRect.width - 7;
h = tabRect.height - 6;
break;
case TOP:
default:
x = tabRect.x + 3;
y = tabRect.y + 3;
w = tabRect.width - 7;
h = tabRect.height - 6;
}
g.drawRect(x, y, w, h);
}
}
protected int getTabRunIndent(int tabPlacement, int run) {
return run*3;
}
protected int getTabRunOverlay(int tabPlacement) {
tabRunOverlay = (tabPlacement == LEFT || tabPlacement == RIGHT)?
(int)Math.round((float)maxTabWidth * .10) :
(int)Math.round((float)maxTabHeight * .22);
// Ensure that runover lay is not more than insets
// 2 pixel offset is set from insets to each run
switch(tabPlacement) {
case LEFT:
if( tabRunOverlay > tabInsets.right - 2 )
tabRunOverlay = tabInsets.right - 2 ;
break;
case RIGHT:
if( tabRunOverlay > tabInsets.left - 2 )
tabRunOverlay = tabInsets.left - 2 ;
break;
case TOP:
if( tabRunOverlay > tabInsets.bottom - 2 )
tabRunOverlay = tabInsets.bottom - 2 ;
break;
case BOTTOM:
if( tabRunOverlay > tabInsets.top - 2 )
tabRunOverlay = tabInsets.top - 2 ;
break;
}
return tabRunOverlay;
}
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicTextAreaUI;
/**
* Provides the look and feel for a plain text editor. In this
* implementation the default UI is extended to act as a simple
* view factory.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Timothy Prinzing
*/
public class MotifTextAreaUI extends BasicTextAreaUI {
/**
* Creates a UI for a JTextArea.
*
* @param ta a text area
* @return the UI
*/
public static ComponentUI createUI(JComponent ta) {
return new MotifTextAreaUI();
}
/**
* Creates the object to use for a caret. By default an
* instance of MotifTextUI.MotifCaret is created. This method
* can be redefined to provide something else that implements
* the Caret interface.
*
* @return the caret object
*/
protected Caret createCaret() {
return MotifTextUI.createCaret();
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.plaf.basic.BasicTextFieldUI;
import javax.swing.plaf.*;
import javax.swing.text.Caret;
/**
* Provides the Motif look and feel for a text field.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Timothy Prinzing
*/
public class MotifTextFieldUI extends BasicTextFieldUI {
/**
* Creates a UI for a JTextField.
*
* @param c the text field
* @return the UI
*/
public static ComponentUI createUI(JComponent c) {
return new MotifTextFieldUI();
}
/**
* Creates the object to use for a caret. By default an
* instance of MotifTextUI.MotifCaret is created. This method
* can be redefined to provide something else that implements
* the Caret interface.
*
* @return the caret object
*/
protected Caret createCaret() {
return MotifTextUI.createCaret();
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicTextPaneUI;
/**
* Provides the look and feel for a styled text editor.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Timothy Prinzing
*/
public class MotifTextPaneUI extends BasicTextPaneUI {
/**
* Creates a UI for the JTextPane.
*
* @param c the JTextPane object
* @return the UI
*/
public static ComponentUI createUI(JComponent c) {
return new MotifTextPaneUI();
}
/**
* Creates the object to use for a caret. By default an
* instance of MotifTextUI.MotifCaret is created. This method
* can be redefined to provide something else that implements
* the Caret interface.
*
* @return the caret object
*/
protected Caret createCaret() {
return MotifTextUI.createCaret();
}
}

View File

@@ -0,0 +1,175 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.plaf.*;
/**
* Provides the look and feel features that are common across
* the Motif/CDE text LAF implementations.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Timothy Prinzing
*/
public class MotifTextUI {
/**
* Creates the object to use for a caret for all of the Motif
* text components. The caret is rendered as an I-beam on Motif.
*
* @return the caret object
*/
public static Caret createCaret() {
return new MotifCaret();
}
/**
* The motif caret is rendered as an I beam.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*/
public static class MotifCaret extends DefaultCaret implements UIResource {
/**
* Called when the component containing the caret gains
* focus. This is implemented to repaint the component
* so the focus rectangle will be re-rendered, as well
* as providing the superclass behavior.
*
* @param e the focus event
* @see FocusListener#focusGained
*/
public void focusGained(FocusEvent e) {
super.focusGained(e);
getComponent().repaint();
}
/**
* Called when the component containing the caret loses
* focus. This is implemented to set the caret to visibility
* to false.
*
* @param e the focus event
* @see FocusListener#focusLost
*/
public void focusLost(FocusEvent e) {
super.focusLost(e);
getComponent().repaint();
}
/**
* Damages the area surrounding the caret to cause
* it to be repainted. If paint() is reimplemented,
* this method should also be reimplemented.
*
* @param r the current location of the caret, does nothing if null
* @see #paint
*/
protected void damage(Rectangle r) {
if (r != null) {
x = r.x - IBeamOverhang - 1;
y = r.y;
width = r.width + (2 * IBeamOverhang) + 3;
height = r.height;
repaint();
}
}
/**
* Renders the caret as a vertical line. If this is reimplemented
* the damage method should also be reimplemented as it assumes the
* shape of the caret is a vertical line. Does nothing if isVisible()
* is false. The caret color is derived from getCaretColor() if
* the component has focus, else from getDisabledTextColor().
*
* @param g the graphics context
* @see #damage
*/
public void paint(Graphics g) {
if(isVisible()) {
try {
JTextComponent c = getComponent();
Color fg = c.hasFocus() ? c.getCaretColor() :
c.getDisabledTextColor();
TextUI mapper = c.getUI();
int dot = getDot();
Rectangle r = mapper.modelToView(c, dot);
int x0 = r.x - IBeamOverhang;
int x1 = r.x + IBeamOverhang;
int y0 = r.y + 1;
int y1 = r.y + r.height - 2;
g.setColor(fg);
g.drawLine(r.x, y0, r.x, y1);
g.drawLine(x0, y0, x1, y0);
g.drawLine(x0, y1, x1, y1);
} catch (BadLocationException e) {
// can't render I guess
//System.err.println("Can't render caret");
}
}
}
static final int IBeamOverhang = 2;
}
/**
* Default bindings all keymaps implementing the Motif feel.
*/
static final JTextComponent.KeyBinding[] defaultBindings = {
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
InputEvent.CTRL_MASK),
DefaultEditorKit.copyAction),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
InputEvent.SHIFT_MASK),
DefaultEditorKit.pasteAction),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,
InputEvent.SHIFT_MASK),
DefaultEditorKit.cutAction),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
InputEvent.SHIFT_MASK),
DefaultEditorKit.selectionBackwardAction),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
InputEvent.SHIFT_MASK),
DefaultEditorKit.selectionForwardAction),
};
}

View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
/**
* BasicToggleButton implementation
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Rich Schiavi
*/
public class MotifToggleButtonUI extends BasicToggleButtonUI
{
private static final Object MOTIF_TOGGLE_BUTTON_UI_KEY = new Object();
protected Color selectColor;
private boolean defaults_initialized = false;
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
MotifToggleButtonUI motifToggleButtonUI =
(MotifToggleButtonUI) appContext.get(MOTIF_TOGGLE_BUTTON_UI_KEY);
if (motifToggleButtonUI == null) {
motifToggleButtonUI = new MotifToggleButtonUI();
appContext.put(MOTIF_TOGGLE_BUTTON_UI_KEY, motifToggleButtonUI);
}
return motifToggleButtonUI;
}
// ********************************
// Install Defaults
// ********************************
public void installDefaults(AbstractButton b) {
super.installDefaults(b);
if(!defaults_initialized) {
selectColor = UIManager.getColor(getPropertyPrefix() + "select");
defaults_initialized = true;
}
LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
}
protected void uninstallDefaults(AbstractButton b) {
super.uninstallDefaults(b);
defaults_initialized = false;
}
// ********************************
// Default Accessors
// ********************************
protected Color getSelectColor() {
return selectColor;
}
// ********************************
// Paint Methods
// ********************************
protected void paintButtonPressed(Graphics g, AbstractButton b) {
if (b.isContentAreaFilled()) {
Color oldColor = g.getColor();
Dimension size = b.getSize();
Insets insets = b.getInsets();
Insets margin = b.getMargin();
if(b.getBackground() instanceof UIResource) {
g.setColor(getSelectColor());
}
g.fillRect(insets.left - margin.left,
insets.top - margin.top,
size.width - (insets.left-margin.left) - (insets.right - margin.right),
size.height - (insets.top-margin.top) - (insets.bottom - margin.bottom));
g.setColor(oldColor);
}
}
public Insets getInsets(JComponent c) {
Border border = c.getBorder();
Insets i = border != null? border.getBorderInsets(c) : new Insets(0,0,0,0);
return i;
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.*;
import java.util.*;
/**
* Motif rendered to display a tree cell.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Jeff Dinkins
*/
public class MotifTreeCellRenderer extends DefaultTreeCellRenderer
{
static final int LEAF_SIZE = 13;
static final Icon LEAF_ICON = new IconUIResource(new TreeLeafIcon());
public MotifTreeCellRenderer() {
super();
}
public static Icon loadLeafIcon() {
return LEAF_ICON;
}
/**
* Icon for a node with no children.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*/
public static class TreeLeafIcon implements Icon, Serializable {
Color bg;
Color shadow;
Color highlight;
public TreeLeafIcon() {
bg = UIManager.getColor("Tree.iconBackground");
shadow = UIManager.getColor("Tree.iconShadow");
highlight = UIManager.getColor("Tree.iconHighlight");
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(bg);
y -= 3;
g.fillRect(x + 4, y + 7, 5, 5);
g.drawLine(x + 6, y + 6, x + 6, y + 6);
g.drawLine(x + 3, y + 9, x + 3, y + 9);
g.drawLine(x + 6, y + 12, x + 6, y + 12);
g.drawLine(x + 9, y + 9, x + 9, y + 9);
g.setColor(highlight);
g.drawLine(x + 2, y + 9, x + 5, y + 6);
g.drawLine(x + 3, y + 10, x + 5, y + 12);
g.setColor(shadow);
g.drawLine(x + 6, y + 13, x + 10, y + 9);
g.drawLine(x + 9, y + 8, x + 7, y + 6);
}
public int getIconWidth() {
return LEAF_SIZE;
}
public int getIconHeight() {
return LEAF_SIZE;
}
}
}

View File

@@ -0,0 +1,166 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.java.swing.plaf.motif;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.tree.*;
import javax.swing.plaf.basic.*;
/**
* Motif rendition of the tree component.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
* @author Jeff Dinkins
*/
public class MotifTreeUI extends BasicTreeUI
{
static final int HALF_SIZE = 7;
static final int SIZE = 14;
/**
* creates a UI object to represent a Motif Tree widget
*/
public MotifTreeUI() {
super();
}
public void installUI(JComponent c) {
super.installUI(c);
}
// BasicTreeUI overrides
protected void paintVerticalLine( Graphics g, JComponent c, int x, int top, int bottom )
{
if (tree.getComponentOrientation().isLeftToRight()) {
g.fillRect( x, top, 2, bottom - top + 2 );
} else {
g.fillRect( x - 1, top, 2, bottom - top + 2 );
}
}
protected void paintHorizontalLine( Graphics g, JComponent c, int y, int left, int right )
{
g.fillRect( left, y, right - left + 1, 2 );
}
/**
* The minus sign button icon.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*/
public static class MotifExpandedIcon implements Icon, Serializable {
static Color bg;
static Color fg;
static Color highlight;
static Color shadow;
public MotifExpandedIcon() {
bg = UIManager.getColor("Tree.iconBackground");
fg = UIManager.getColor("Tree.iconForeground");
highlight = UIManager.getColor("Tree.iconHighlight");
shadow = UIManager.getColor("Tree.iconShadow");
}
public static Icon createExpandedIcon() {
return new MotifExpandedIcon();
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(highlight);
g.drawLine(x, y, x+SIZE-1, y);
g.drawLine(x, y+1, x, y+SIZE-1);
g.setColor(shadow);
g.drawLine(x+SIZE-1, y+1, x+SIZE-1, y+SIZE-1);
g.drawLine(x+1, y+SIZE-1, x+SIZE-1, y+SIZE-1);
g.setColor(bg);
g.fillRect(x+1, y+1, SIZE-2, SIZE-2);
g.setColor(fg);
g.drawLine(x+3, y+HALF_SIZE-1, x+SIZE-4, y+HALF_SIZE-1);
g.drawLine(x+3, y+HALF_SIZE, x+SIZE-4, y+HALF_SIZE);
}
public int getIconWidth() { return SIZE; }
public int getIconHeight() { return SIZE; }
}
/**
* The plus sign button icon.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is appropriate
* for short term storage or RMI between applications running the same
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*/
public static class MotifCollapsedIcon extends MotifExpandedIcon {
public static Icon createCollapsedIcon() {
return new MotifCollapsedIcon();
}
public void paintIcon(Component c, Graphics g, int x, int y) {
super.paintIcon(c, g, x, y);
g.drawLine(x + HALF_SIZE-1, y + 3, x + HALF_SIZE-1, y + (SIZE - 4));
g.drawLine(x + HALF_SIZE, y + 3, x + HALF_SIZE, y + (SIZE - 4));
}
}
public static ComponentUI createUI(JComponent x) {
return new MotifTreeUI();
}
/**
* Returns the default cell renderer that is used to do the
* stamping of each node.
*/
public TreeCellRenderer createDefaultCellRenderer() {
return new MotifTreeCellRenderer();
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "Cancel" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Abort file chooser dialog." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "E&nter file name:" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Enter folder name:" },
{ "FileChooser.filesLabel.textAndMnemonic", "F&iles" },
{ "FileChooser.filterLabel.textAndMnemonic", "Filte&r" },
{ "FileChooser.foldersLabel.textAndMnemonic", "Fo&lders" },
{ "FileChooser.helpButton.textAndMnemonic", "Help" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser help." },
{ "FileChooser.openButton.textAndMnemonic", "OK" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Open selected file." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "Open" },
{ "FileChooser.pathLabel.textAndMnemonic", "Enter &path or folder name:" },
{ "FileChooser.saveButton.textAndMnemonic", "Save" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Save selected file." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Save" },
{ "FileChooser.updateButton.textAndMnemonic", "Update" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Update directory listing." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_de extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "Abbrechen" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Dialogfeld f\u00FCr Dateiauswahl schlie\u00DFen." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "Dateina&me eingeben:" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Ordnernamen eingeben:" },
{ "FileChooser.filesLabel.textAndMnemonic", "Date&ien" },
{ "FileChooser.filterLabel.textAndMnemonic", "Filte&r" },
{ "FileChooser.foldersLabel.textAndMnemonic", "Ord&ner" },
{ "FileChooser.helpButton.textAndMnemonic", "Hilfe" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser-Hilfe." },
{ "FileChooser.openButton.textAndMnemonic", "OK" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Ausgew\u00E4hlte Datei \u00F6ffnen." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u00D6ffnen" },
{ "FileChooser.pathLabel.textAndMnemonic", "&Pfad- oder Ordnername eingeben:" },
{ "FileChooser.saveButton.textAndMnemonic", "Speichern" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Ausgew\u00E4hlte Datei speichern." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Speichern" },
{ "FileChooser.updateButton.textAndMnemonic", "Aktualisieren" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Verzeichnisliste aktualisieren." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_es extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "Cancelar" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Abortar cuadro de di\u00E1logo del selector de archivos." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "I&ntroducir nombre de archivo:" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Introducir nombre de carpeta:" },
{ "FileChooser.filesLabel.textAndMnemonic", "Arch&ivos" },
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&ro" },
{ "FileChooser.foldersLabel.textAndMnemonic", "Carpe&tas" },
{ "FileChooser.helpButton.textAndMnemonic", "Ayuda" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Ayuda del selector de archivos." },
{ "FileChooser.openButton.textAndMnemonic", "Aceptar" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Abrir archivo seleccionado." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "Abrir" },
{ "FileChooser.pathLabel.textAndMnemonic", "Introducir nombre de ruta de acceso o car&peta:" },
{ "FileChooser.saveButton.textAndMnemonic", "Guardar" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Guardar archivo seleccionado." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Guardar" },
{ "FileChooser.updateButton.textAndMnemonic", "Actualizar" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Actualizar lista de directorios." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_fr extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "Annuler" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Ferme la bo\u00EEte de dialogue du s\u00E9lecteur de fichiers." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "E&ntrez le nom du fichier :" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Entrez le nom du dossier :" },
{ "FileChooser.filesLabel.textAndMnemonic", "F&ichiers" },
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&re" },
{ "FileChooser.foldersLabel.textAndMnemonic", "&Dossiers" },
{ "FileChooser.helpButton.textAndMnemonic", "Aide" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Aide du s\u00E9lecteur de fichiers" },
{ "FileChooser.openButton.textAndMnemonic", "OK" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Ouvre le fichier s\u00E9lectionn\u00E9." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "Ouvrir" },
{ "FileChooser.pathLabel.textAndMnemonic", "Entrez le c&hemin ou le nom du dossier :" },
{ "FileChooser.saveButton.textAndMnemonic", "Enregistrer" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Enregistre le fichier s\u00E9lectionn\u00E9." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Enregistrer" },
{ "FileChooser.updateButton.textAndMnemonic", "Mettre \u00E0 jour" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Met \u00E0 jour la liste des r\u00E9pertoires." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_it extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "Annulla" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Chiude la finestra di dialogo di selezione file." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "Immettere il &nome file: " },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Nome cartella:" },
{ "FileChooser.filesLabel.textAndMnemonic", "F&ile" },
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&ro" },
{ "FileChooser.foldersLabel.textAndMnemonic", "Car&telle" },
{ "FileChooser.helpButton.textAndMnemonic", "?" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Guida FileChooser." },
{ "FileChooser.openButton.textAndMnemonic", "OK" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Apre il file selezionato." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "Apri" },
{ "FileChooser.pathLabel.textAndMnemonic", "&Percorso o nome cartella:" },
{ "FileChooser.saveButton.textAndMnemonic", "Salva" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Salva il file selezionato." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Salva" },
{ "FileChooser.updateButton.textAndMnemonic", "Aggiorna" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Aggiorna lista directory." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_ja extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "\u53D6\u6D88" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB\u30FB\u30C1\u30E5\u30FC\u30B6\u30FB\u30C0\u30A4\u30A2\u30ED\u30B0\u3092\u7D42\u4E86\u3057\u307E\u3059\u3002" },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB\u540D\u3092\u5165\u529B(&N):" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\u30D5\u30A9\u30EB\u30C0\u540D\u3092\u5165\u529B:" },
{ "FileChooser.filesLabel.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB(&I)" },
{ "FileChooser.filterLabel.textAndMnemonic", "\u30D5\u30A3\u30EB\u30BF(&R)" },
{ "FileChooser.foldersLabel.textAndMnemonic", "\u30D5\u30A9\u30EB\u30C0(&L)" },
{ "FileChooser.helpButton.textAndMnemonic", "\u30D8\u30EB\u30D7" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser\u306E\u30D8\u30EB\u30D7\u3067\u3059\u3002" },
{ "FileChooser.openButton.textAndMnemonic", "OK" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u9078\u629E\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u304D\u307E\u3059\u3002" },
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u958B\u304F" },
{ "FileChooser.pathLabel.textAndMnemonic", "\u30D1\u30B9\u307E\u305F\u306F\u30D5\u30A9\u30EB\u30C0\u540D\u3092\u5165\u529B(&P):" },
{ "FileChooser.saveButton.textAndMnemonic", "\u4FDD\u5B58" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\u9078\u629E\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u4FDD\u5B58\u3057\u307E\u3059\u3002" },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\u4FDD\u5B58" },
{ "FileChooser.updateButton.textAndMnemonic", "\u66F4\u65B0" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30EA\u30B9\u30C8\u3092\u66F4\u65B0\u3057\u307E\u3059\u3002" },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_ko extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "\uCDE8\uC18C" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\uD30C\uC77C \uC120\uD0DD\uAE30 \uB300\uD654\uC0C1\uC790\uB97C \uC911\uB2E8\uD569\uB2C8\uB2E4." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\uD30C\uC77C \uC774\uB984 \uC785\uB825(&N):" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\uD3F4\uB354 \uC774\uB984 \uC785\uB825:" },
{ "FileChooser.filesLabel.textAndMnemonic", "\uD30C\uC77C(&I)" },
{ "FileChooser.filterLabel.textAndMnemonic", "\uD544\uD130(&R)" },
{ "FileChooser.foldersLabel.textAndMnemonic", "\uD3F4\uB354(&L)" },
{ "FileChooser.helpButton.textAndMnemonic", "\uB3C4\uC6C0\uB9D0" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser \uB3C4\uC6C0\uB9D0\uC785\uB2C8\uB2E4." },
{ "FileChooser.openButton.textAndMnemonic", "\uD655\uC778" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\uC120\uD0DD\uB41C \uD30C\uC77C\uC744 \uC5FD\uB2C8\uB2E4." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "\uC5F4\uAE30" },
{ "FileChooser.pathLabel.textAndMnemonic", "\uACBD\uB85C \uB610\uB294 \uD3F4\uB354 \uC774\uB984 \uC785\uB825(&P):" },
{ "FileChooser.saveButton.textAndMnemonic", "\uC800\uC7A5" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\uC120\uD0DD\uB41C \uD30C\uC77C\uC744 \uC800\uC7A5\uD569\uB2C8\uB2E4." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\uC800\uC7A5" },
{ "FileChooser.updateButton.textAndMnemonic", "\uC5C5\uB370\uC774\uD2B8" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\uB514\uB809\uD1A0\uB9AC \uBAA9\uB85D\uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_pt_BR extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "Cancelar" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Abortar caixa de di\u00E1logo do seletor de arquivos." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "I&nforme o nome do arquivo:" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Informar nome da pasta:" },
{ "FileChooser.filesLabel.textAndMnemonic", "Arqu&ivos" },
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&ro" },
{ "FileChooser.foldersLabel.textAndMnemonic", "Pa&stas" },
{ "FileChooser.helpButton.textAndMnemonic", "Ajuda" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Ajuda do FileChooser." },
{ "FileChooser.openButton.textAndMnemonic", "OK" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Abrir arquivo selecionado." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "Abrir" },
{ "FileChooser.pathLabel.textAndMnemonic", "Informar &caminho ou nome da pasta:" },
{ "FileChooser.saveButton.textAndMnemonic", "Salvar" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Salvar arquivo selecionado." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Salvar" },
{ "FileChooser.updateButton.textAndMnemonic", "Atualizar" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Atualizar lista de diret\u00F3rios." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_sv extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "Avbryt" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Avbryt dialogrutan f\u00F6r filval." },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "A&nge filnamn:" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Ange ett mappnamn:" },
{ "FileChooser.filesLabel.textAndMnemonic", "F&iler" },
{ "FileChooser.filterLabel.textAndMnemonic", "Filte&r" },
{ "FileChooser.foldersLabel.textAndMnemonic", "Ma&ppar" },
{ "FileChooser.helpButton.textAndMnemonic", "Hj\u00E4lp" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Hj\u00E4lp f\u00F6r val av fil." },
{ "FileChooser.openButton.textAndMnemonic", "OK" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u00D6ppna vald fil." },
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u00D6ppna" },
{ "FileChooser.pathLabel.textAndMnemonic", "Ange &s\u00F6kv\u00E4g eller mappnamn:" },
{ "FileChooser.saveButton.textAndMnemonic", "Spara" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Spara vald fil." },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Spara" },
{ "FileChooser.updateButton.textAndMnemonic", "Uppdatera" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Uppdatera kataloglistan." },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_zh_CN extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "\u53D6\u6D88" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\u4E2D\u6B62\u6587\u4EF6\u9009\u62E9\u5668\u5BF9\u8BDD\u6846\u3002" },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\u8F93\u5165\u6587\u4EF6\u540D(&N):" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\u8F93\u5165\u6587\u4EF6\u5939\u540D:" },
{ "FileChooser.filesLabel.textAndMnemonic", "\u6587\u4EF6(&I)" },
{ "FileChooser.filterLabel.textAndMnemonic", "\u7B5B\u9009\u5668(&R)" },
{ "FileChooser.foldersLabel.textAndMnemonic", "\u6587\u4EF6\u5939(&L)" },
{ "FileChooser.helpButton.textAndMnemonic", "\u5E2E\u52A9" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser \u5E2E\u52A9\u3002" },
{ "FileChooser.openButton.textAndMnemonic", "\u786E\u5B9A" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u6253\u5F00\u6240\u9009\u6587\u4EF6\u3002" },
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u6253\u5F00" },
{ "FileChooser.pathLabel.textAndMnemonic", "\u8F93\u5165\u8DEF\u5F84\u6216\u6587\u4EF6\u5939\u540D(&P):" },
{ "FileChooser.saveButton.textAndMnemonic", "\u4FDD\u5B58" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\u4FDD\u5B58\u6240\u9009\u6587\u4EF6\u3002" },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\u4FDD\u5B58" },
{ "FileChooser.updateButton.textAndMnemonic", "\u66F4\u65B0" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\u66F4\u65B0\u76EE\u5F55\u5217\u8868\u3002" },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_zh_HK extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "\u53D6\u6D88" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\u4E2D\u6B62\u6A94\u6848\u9078\u64C7\u5668\u5C0D\u8A71\u65B9\u584A\u3002" },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\u8F38\u5165\u6A94\u6848\u540D\u7A31(&N):" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\u8F38\u5165\u8CC7\u6599\u593E\u540D\u7A31:" },
{ "FileChooser.filesLabel.textAndMnemonic", "\u6A94\u6848(&I)" },
{ "FileChooser.filterLabel.textAndMnemonic", "\u7BE9\u9078(&R)" },
{ "FileChooser.foldersLabel.textAndMnemonic", "\u8CC7\u6599\u593E(&L)" },
{ "FileChooser.helpButton.textAndMnemonic", "\u8AAA\u660E" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "\u300C\u6A94\u6848\u9078\u64C7\u5668\u300D\u8AAA\u660E\u3002" },
{ "FileChooser.openButton.textAndMnemonic", "\u78BA\u5B9A" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u958B\u555F\u9078\u53D6\u7684\u6A94\u6848\u3002" },
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u958B\u555F" },
{ "FileChooser.pathLabel.textAndMnemonic", "\u8F38\u5165\u8DEF\u5F91\u6216\u8CC7\u6599\u593E\u540D\u7A31(&P):" },
{ "FileChooser.saveButton.textAndMnemonic", "\u5132\u5B58" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\u5132\u5B58\u9078\u53D6\u7684\u6A94\u6848\u3002" },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\u5132\u5B58" },
{ "FileChooser.updateButton.textAndMnemonic", "\u66F4\u65B0" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\u66F4\u65B0\u76EE\u9304\u6E05\u55AE\u3002" },
};
}
}

View File

@@ -0,0 +1,29 @@
package com.sun.java.swing.plaf.motif.resources;
import java.util.ListResourceBundle;
public final class motif_zh_TW extends ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
{ "FileChooser.cancelButton.textAndMnemonic", "\u53D6\u6D88" },
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\u4E2D\u6B62\u6A94\u6848\u9078\u64C7\u5668\u5C0D\u8A71\u65B9\u584A\u3002" },
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\u8F38\u5165\u6A94\u6848\u540D\u7A31(&N):" },
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\u8F38\u5165\u8CC7\u6599\u593E\u540D\u7A31:" },
{ "FileChooser.filesLabel.textAndMnemonic", "\u6A94\u6848(&I)" },
{ "FileChooser.filterLabel.textAndMnemonic", "\u7BE9\u9078(&R)" },
{ "FileChooser.foldersLabel.textAndMnemonic", "\u8CC7\u6599\u593E(&L)" },
{ "FileChooser.helpButton.textAndMnemonic", "\u8AAA\u660E" },
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "\u300C\u6A94\u6848\u9078\u64C7\u5668\u300D\u8AAA\u660E\u3002" },
{ "FileChooser.openButton.textAndMnemonic", "\u78BA\u5B9A" },
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u958B\u555F\u9078\u53D6\u7684\u6A94\u6848\u3002" },
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u958B\u555F" },
{ "FileChooser.pathLabel.textAndMnemonic", "\u8F38\u5165\u8DEF\u5F91\u6216\u8CC7\u6599\u593E\u540D\u7A31(&P):" },
{ "FileChooser.saveButton.textAndMnemonic", "\u5132\u5B58" },
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\u5132\u5B58\u9078\u53D6\u7684\u6A94\u6848\u3002" },
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\u5132\u5B58" },
{ "FileChooser.updateButton.textAndMnemonic", "\u66F4\u65B0" },
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\u66F4\u65B0\u76EE\u9304\u6E05\u55AE\u3002" },
};
}
}