提交 b834c127 编写于 作者: M mrkam

7027696: /jfc/Metalworks demo needs to be improved

Reviewed-by: rupashka
上级 10d94077
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,31 +29,39 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
/**
* This class describes a theme using "blue-green" colors.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class AquaMetalTheme extends DefaultMetalTheme {
public String getName() { return "Oxide"; }
@Override
public String getName() {
return "Oxide";
}
private final ColorUIResource primary1 = new ColorUIResource(102, 153, 153);
private final ColorUIResource primary2 = new ColorUIResource(128, 192, 192);
private final ColorUIResource primary3 = new ColorUIResource(159, 235, 235);
protected ColorUIResource getPrimary1() { return primary1; }
protected ColorUIResource getPrimary2() { return primary2; }
protected ColorUIResource getPrimary3() { return primary3; }
@Override
protected ColorUIResource getPrimary1() {
return primary1;
}
@Override
protected ColorUIResource getPrimary2() {
return primary2;
}
@Override
protected ColorUIResource getPrimary3() {
return primary3;
}
}
/*
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,9 +29,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
......@@ -39,54 +36,91 @@ import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
/**
* This class describes a theme using "green" colors.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class BigContrastMetalTheme extends ContrastMetalTheme {
public String getName() { return "Low Vision"; }
@Override
public String getName() {
return "Low Vision";
}
private final FontUIResource controlFont = new FontUIResource("Dialog",
Font.BOLD, 24);
private final FontUIResource systemFont = new FontUIResource("Dialog",
Font.PLAIN, 24);
private final FontUIResource windowTitleFont = new FontUIResource("Dialog",
Font.BOLD, 24);
private final FontUIResource userFont = new FontUIResource("SansSerif",
Font.PLAIN, 24);
private final FontUIResource smallFont = new FontUIResource("Dialog",
Font.PLAIN, 20);
@Override
public FontUIResource getControlTextFont() {
return controlFont;
}
private final FontUIResource controlFont = new FontUIResource("Dialog", Font.BOLD, 24);
private final FontUIResource systemFont = new FontUIResource("Dialog", Font.PLAIN, 24);
private final FontUIResource windowTitleFont = new FontUIResource("Dialog", Font.BOLD, 24);
private final FontUIResource userFont = new FontUIResource("SansSerif", Font.PLAIN, 24);
private final FontUIResource smallFont = new FontUIResource("Dialog", Font.PLAIN, 20);
@Override
public FontUIResource getSystemTextFont() {
return systemFont;
}
@Override
public FontUIResource getUserTextFont() {
return userFont;
}
public FontUIResource getControlTextFont() { return controlFont;}
public FontUIResource getSystemTextFont() { return systemFont;}
public FontUIResource getUserTextFont() { return userFont;}
public FontUIResource getMenuTextFont() { return controlFont;}
public FontUIResource getWindowTitleFont() { return windowTitleFont;}
public FontUIResource getSubTextFont() { return smallFont;}
@Override
public FontUIResource getMenuTextFont() {
return controlFont;
}
@Override
public FontUIResource getWindowTitleFont() {
return windowTitleFont;
}
@Override
public FontUIResource getSubTextFont() {
return smallFont;
}
@Override
public void addCustomEntriesToTable(UIDefaults table) {
super.addCustomEntriesToTable(table);
final int internalFrameIconSize = 30;
table.put("InternalFrame.closeIcon", MetalIconFactory.getInternalFrameCloseIcon(internalFrameIconSize));
table.put("InternalFrame.maximizeIcon", MetalIconFactory.getInternalFrameMaximizeIcon(internalFrameIconSize));
table.put("InternalFrame.iconifyIcon", MetalIconFactory.getInternalFrameMinimizeIcon(internalFrameIconSize));
table.put("InternalFrame.minimizeIcon", MetalIconFactory.getInternalFrameAltMaximizeIcon(internalFrameIconSize));
Border blackLineBorder = new BorderUIResource( new MatteBorder( 2,2,2,2, Color.black) );
table.put("InternalFrame.closeIcon", MetalIconFactory.
getInternalFrameCloseIcon(internalFrameIconSize));
table.put("InternalFrame.maximizeIcon", MetalIconFactory.
getInternalFrameMaximizeIcon(internalFrameIconSize));
table.put("InternalFrame.iconifyIcon", MetalIconFactory.
getInternalFrameMinimizeIcon(internalFrameIconSize));
table.put("InternalFrame.minimizeIcon", MetalIconFactory.
getInternalFrameAltMaximizeIcon(internalFrameIconSize));
Border blackLineBorder = new BorderUIResource(new MatteBorder(2, 2, 2, 2,
Color.black));
Border textBorder = blackLineBorder;
table.put( "ToolTip.border", blackLineBorder);
table.put( "TitledBorder.border", blackLineBorder);
table.put("ToolTip.border", blackLineBorder);
table.put("TitledBorder.border", blackLineBorder);
table.put( "TextField.border", textBorder);
table.put( "PasswordField.border", textBorder);
table.put( "TextArea.border", textBorder);
table.put( "TextPane.font", textBorder);
table.put("TextField.border", textBorder);
table.put("PasswordField.border", textBorder);
table.put("TextArea.border", textBorder);
table.put("TextPane.font", textBorder);
table.put( "ScrollPane.border", blackLineBorder);
table.put("ScrollPane.border", blackLineBorder);
table.put( "ScrollBar.width", new Integer(25) );
table.put("ScrollBar.width", 25);
......
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,75 +29,131 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import javax.swing.UIDefaults;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.basic.BasicBorders;
import javax.swing.plaf.metal.DefaultMetalTheme;
/**
* This class describes a higher-contrast Metal Theme.
*
* @author Michael C. Albers
* @author Alexander Kouznetsov
*/
public class ContrastMetalTheme extends DefaultMetalTheme {
public String getName() { return "Contrast"; }
@Override
public String getName() {
return "Contrast";
}
private final ColorUIResource primary1 = new ColorUIResource(0, 0, 0);
private final ColorUIResource primary2 = new ColorUIResource(204, 204, 204);
private final ColorUIResource primary3 = new ColorUIResource(255, 255, 255);
private final ColorUIResource primaryHighlight = new ColorUIResource(102,102,102);
private final ColorUIResource primaryHighlight = new ColorUIResource(102,
102, 102);
private final ColorUIResource secondary2 =
new ColorUIResource(204, 204, 204);
private final ColorUIResource secondary3 =
new ColorUIResource(255, 255, 255);
@Override
protected ColorUIResource getPrimary1() {
return primary1;
}
private final ColorUIResource secondary2 = new ColorUIResource(204, 204, 204);
private final ColorUIResource secondary3 = new ColorUIResource(255, 255, 255);
private final ColorUIResource controlHighlight = new ColorUIResource(102,102,102);
@Override
protected ColorUIResource getPrimary2() {
return primary2;
}
protected ColorUIResource getPrimary1() { return primary1; }
protected ColorUIResource getPrimary2() { return primary2; }
protected ColorUIResource getPrimary3() { return primary3; }
public ColorUIResource getPrimaryControlHighlight() { return primaryHighlight;}
@Override
protected ColorUIResource getPrimary3() {
return primary3;
}
protected ColorUIResource getSecondary2() { return secondary2; }
protected ColorUIResource getSecondary3() { return secondary3; }
public ColorUIResource getControlHighlight() { return super.getSecondary3(); }
@Override
public ColorUIResource getPrimaryControlHighlight() {
return primaryHighlight;
}
public ColorUIResource getFocusColor() { return getBlack(); }
@Override
protected ColorUIResource getSecondary2() {
return secondary2;
}
public ColorUIResource getTextHighlightColor() { return getBlack(); }
public ColorUIResource getHighlightedTextColor() { return getWhite(); }
@Override
protected ColorUIResource getSecondary3() {
return secondary3;
}
public ColorUIResource getMenuSelectedBackground() { return getBlack(); }
public ColorUIResource getMenuSelectedForeground() { return getWhite(); }
public ColorUIResource getAcceleratorForeground() { return getBlack(); }
public ColorUIResource getAcceleratorSelectedForeground() { return getWhite(); }
@Override
public ColorUIResource getControlHighlight() {
return super.getSecondary3();
}
@Override
public ColorUIResource getFocusColor() {
return getBlack();
}
@Override
public ColorUIResource getTextHighlightColor() {
return getBlack();
}
@Override
public ColorUIResource getHighlightedTextColor() {
return getWhite();
}
@Override
public ColorUIResource getMenuSelectedBackground() {
return getBlack();
}
@Override
public ColorUIResource getMenuSelectedForeground() {
return getWhite();
}
@Override
public ColorUIResource getAcceleratorForeground() {
return getBlack();
}
@Override
public ColorUIResource getAcceleratorSelectedForeground() {
return getWhite();
}
@Override
public void addCustomEntriesToTable(UIDefaults table) {
Border blackLineBorder = new BorderUIResource(new LineBorder( getBlack() ));
Border whiteLineBorder = new BorderUIResource(new LineBorder( getWhite() ));
Border blackLineBorder =
new BorderUIResource(new LineBorder(getBlack()));
Border whiteLineBorder =
new BorderUIResource(new LineBorder(getWhite()));
Object textBorder = new BorderUIResource( new CompoundBorder(
Object textBorder = new BorderUIResource(new CompoundBorder(
blackLineBorder,
new BasicBorders.MarginBorder()));
table.put( "ToolTip.border", blackLineBorder);
table.put( "TitledBorder.border", blackLineBorder);
table.put( "Table.focusCellHighlightBorder", whiteLineBorder);
table.put( "Table.focusCellForeground", getWhite());
table.put("ToolTip.border", blackLineBorder);
table.put("TitledBorder.border", blackLineBorder);
table.put("Table.focusCellHighlightBorder", whiteLineBorder);
table.put("Table.focusCellForeground", getWhite());
table.put( "TextField.border", textBorder);
table.put( "PasswordField.border", textBorder);
table.put( "TextArea.border", textBorder);
table.put( "TextPane.font", textBorder);
table.put("TextField.border", textBorder);
table.put("PasswordField.border", textBorder);
table.put("TextArea.border", textBorder);
table.put("TextPane.font", textBorder);
}
}
/*
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,15 +29,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.Font;
import javax.swing.UIDefaults;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalIconFactory;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
/**
* This class describes a theme using large fonts.
......@@ -45,37 +43,71 @@ import java.awt.*;
* where people will have trouble seeing what you're doing.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class DemoMetalTheme extends DefaultMetalTheme {
public String getName() { return "Presentation"; }
@Override
public String getName() {
return "Presentation";
}
private final FontUIResource controlFont = new FontUIResource("Dialog",
Font.BOLD, 18);
private final FontUIResource systemFont = new FontUIResource("Dialog",
Font.PLAIN, 18);
private final FontUIResource userFont = new FontUIResource("SansSerif",
Font.PLAIN, 18);
private final FontUIResource smallFont = new FontUIResource("Dialog",
Font.PLAIN, 14);
@Override
public FontUIResource getControlTextFont() {
return controlFont;
}
@Override
public FontUIResource getSystemTextFont() {
return systemFont;
}
@Override
public FontUIResource getUserTextFont() {
return userFont;
}
private final FontUIResource controlFont = new FontUIResource("Dialog", Font.BOLD, 18);
private final FontUIResource systemFont = new FontUIResource("Dialog", Font.PLAIN, 18);
private final FontUIResource userFont = new FontUIResource("SansSerif", Font.PLAIN, 18);
private final FontUIResource smallFont = new FontUIResource("Dialog", Font.PLAIN, 14);
@Override
public FontUIResource getMenuTextFont() {
return controlFont;
}
public FontUIResource getControlTextFont() { return controlFont;}
public FontUIResource getSystemTextFont() { return systemFont;}
public FontUIResource getUserTextFont() { return userFont;}
public FontUIResource getMenuTextFont() { return controlFont;}
public FontUIResource getWindowTitleFont() { return controlFont;}
public FontUIResource getSubTextFont() { return smallFont;}
@Override
public FontUIResource getWindowTitleFont() {
return controlFont;
}
@Override
public FontUIResource getSubTextFont() {
return smallFont;
}
@Override
public void addCustomEntriesToTable(UIDefaults table) {
super.addCustomEntriesToTable(table);
final int internalFrameIconSize = 22;
table.put("InternalFrame.closeIcon", MetalIconFactory.getInternalFrameCloseIcon(internalFrameIconSize));
table.put("InternalFrame.maximizeIcon", MetalIconFactory.getInternalFrameMaximizeIcon(internalFrameIconSize));
table.put("InternalFrame.iconifyIcon", MetalIconFactory.getInternalFrameMinimizeIcon(internalFrameIconSize));
table.put("InternalFrame.minimizeIcon", MetalIconFactory.getInternalFrameAltMaximizeIcon(internalFrameIconSize));
table.put("InternalFrame.closeIcon", MetalIconFactory.
getInternalFrameCloseIcon(internalFrameIconSize));
table.put("InternalFrame.maximizeIcon", MetalIconFactory.
getInternalFrameMaximizeIcon(internalFrameIconSize));
table.put("InternalFrame.iconifyIcon", MetalIconFactory.
getInternalFrameMinimizeIcon(internalFrameIconSize));
table.put("InternalFrame.minimizeIcon", MetalIconFactory.
getInternalFrameAltMaximizeIcon(internalFrameIconSize));
table.put( "ScrollBar.width", new Integer(21) );
table.put("ScrollBar.width", 21);
}
}
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,32 +29,40 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
/**
* This class describes a theme using "green" colors.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class GreenMetalTheme extends DefaultMetalTheme {
public String getName() { return "Emerald"; }
@Override
public String getName() {
return "Emerald";
}
// greenish colors
private final ColorUIResource primary1 = new ColorUIResource(51, 102, 51);
private final ColorUIResource primary2 = new ColorUIResource(102, 153, 102);
private final ColorUIResource primary3 = new ColorUIResource(153, 204, 153);
protected ColorUIResource getPrimary1() { return primary1; }
protected ColorUIResource getPrimary2() { return primary2; }
protected ColorUIResource getPrimary3() { return primary3; }
@Override
protected ColorUIResource getPrimary1() {
return primary1;
}
@Override
protected ColorUIResource getPrimary2() {
return primary2;
}
@Override
protected ColorUIResource getPrimary3() {
return primary3;
}
}
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,39 +29,60 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
/**
* This class describes a theme using "khaki" colors.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class KhakiMetalTheme extends DefaultMetalTheme {
public String getName() { return "Sandstone"; }
private final ColorUIResource primary1 = new ColorUIResource( 87, 87, 47);
@Override
public String getName() {
return "Sandstone";
}
private final ColorUIResource primary1 = new ColorUIResource(87, 87, 47);
private final ColorUIResource primary2 = new ColorUIResource(159, 151, 111);
private final ColorUIResource primary3 = new ColorUIResource(199, 183, 143);
private final ColorUIResource secondary1 =
new ColorUIResource(111, 111, 111);
private final ColorUIResource secondary2 =
new ColorUIResource(159, 159, 159);
private final ColorUIResource secondary3 =
new ColorUIResource(231, 215, 183);
@Override
protected ColorUIResource getPrimary1() {
return primary1;
}
@Override
protected ColorUIResource getPrimary2() {
return primary2;
}
private final ColorUIResource secondary1 = new ColorUIResource( 111, 111, 111);
private final ColorUIResource secondary2 = new ColorUIResource(159, 159, 159);
private final ColorUIResource secondary3 = new ColorUIResource(231, 215, 183);
@Override
protected ColorUIResource getPrimary3() {
return primary3;
}
protected ColorUIResource getPrimary1() { return primary1; }
protected ColorUIResource getPrimary2() { return primary2; }
protected ColorUIResource getPrimary3() { return primary3; }
@Override
protected ColorUIResource getSecondary1() {
return secondary1;
}
protected ColorUIResource getSecondary1() { return secondary1; }
protected ColorUIResource getSecondary2() { return secondary2; }
protected ColorUIResource getSecondary3() { return secondary3; }
@Override
protected ColorUIResource getSecondary2() {
return secondary2;
}
@Override
protected ColorUIResource getSecondary3() {
return secondary3;
}
}
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,43 +29,50 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
/**
* This class describes a theme using "green" colors.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class MetalThemeMenu extends JMenu implements ActionListener{
@SuppressWarnings("serial")
public class MetalThemeMenu extends JMenu implements ActionListener {
MetalTheme[] themes;
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
super(name);
themes = themeArray;
ButtonGroup group = new ButtonGroup();
for (int i = 0; i < themes.length; i++) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem( themes[i].getName() );
JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
getName());
group.add(item);
add( item );
item.setActionCommand(i+"");
add(item);
item.setActionCommand(i + "");
item.addActionListener(this);
if ( i == 0)
if (i == 0) {
item.setSelected(true);
}
}
}
public void actionPerformed(ActionEvent e) {
String numStr = e.getActionCommand();
MetalTheme selectedTheme = themes[ Integer.parseInt(numStr) ];
MetalTheme selectedTheme = themes[Integer.parseInt(numStr)];
MetalLookAndFeel.setCurrentTheme(selectedTheme);
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
......@@ -75,5 +82,4 @@ public class MetalThemeMenu extends JMenu implements ActionListener{
}
}
}
/*
* Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,34 +29,35 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.Toolkit;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.metal.MetalLookAndFeel;
/**
* This application is a demo of the Metal Look & Feel
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class Metalworks {
public static void main( String[] args ) {
public static void main(String[] args) {
UIManager.put("swing.boldMetal", Boolean.FALSE);
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame.setDefaultLookAndFeelDecorated(true);
Toolkit.getDefaultToolkit().setDynamicLayout(true);
System.setProperty("sun.awt.noerasebackground","true");
System.setProperty("sun.awt.noerasebackground", "true");
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
}
catch ( UnsupportedLookAndFeelException e ) {
System.out.println ("Metal Look & Feel not supported on this platform. \nProgram Terminated");
} catch (UnsupportedLookAndFeelException e) {
System.out.println(
"Metal Look & Feel not supported on this platform. \n"
+ "Program Terminated");
System.exit(0);
}
JFrame frame = new MetalworksFrame();
......
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,14 +29,24 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
/**
......@@ -44,6 +54,7 @@ import javax.swing.border.*;
*
* @author Steve Wilson
*/
@SuppressWarnings("serial")
public class MetalworksDocumentFrame extends JInternalFrame {
static int openFrameCount = 0;
......@@ -59,27 +70,27 @@ public class MetalworksDocumentFrame extends JInternalFrame {
top.setLayout(new BorderLayout());
top.add(buildAddressPanel(), BorderLayout.NORTH);
JTextArea content = new JTextArea( 15, 30 );
content.setBorder( new EmptyBorder(0,5 ,0, 5) );
JTextArea content = new JTextArea(15, 30);
content.setBorder(new EmptyBorder(0, 5, 0, 5));
content.setLineWrap(true);
JScrollPane textScroller = new JScrollPane(content,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
top.add( textScroller, BorderLayout.CENTER);
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
top.add(textScroller, BorderLayout.CENTER);
setContentPane(top);
pack();
setLocation( offset * openFrameCount, offset *openFrameCount);
setLocation(offset * openFrameCount, offset * openFrameCount);
}
private JPanel buildAddressPanel() {
JPanel p = new JPanel();
p.setLayout( new LabeledPairLayout() );
p.setLayout(new LabeledPairLayout());
JLabel toLabel = new JLabel("To: ", JLabel.RIGHT);
......@@ -103,19 +114,19 @@ public class MetalworksDocumentFrame extends JInternalFrame {
}
class LabeledPairLayout implements LayoutManager {
Vector labels = new Vector();
Vector fields = new Vector();
class LabeledPairLayout implements LayoutManager {
List<Component> labels = new ArrayList<Component>();
List<Component> fields = new ArrayList<Component>();
int yGap = 2;
int xGap = 2;
public void addLayoutComponent(String s, Component c) {
if (s.equals("label")) {
labels.addElement(c);
labels.add(c);
} else {
fields.addElement(c);
fields.add(c);
}
}
......@@ -123,52 +134,50 @@ public class MetalworksDocumentFrame extends JInternalFrame {
Insets insets = c.getInsets();
int labelWidth = 0;
Enumeration labelIter = labels.elements();
while(labelIter.hasMoreElements()) {
JComponent comp = (JComponent)labelIter.nextElement();
labelWidth = Math.max( labelWidth, comp.getPreferredSize().width );
for (Component comp : labels) {
labelWidth = Math.max(labelWidth, comp.getPreferredSize().width);
}
int yPos = insets.top;
Enumeration fieldIter = fields.elements();
labelIter = labels.elements();
while(labelIter.hasMoreElements() && fieldIter.hasMoreElements()) {
JComponent label = (JComponent)labelIter.nextElement();
JComponent field = (JComponent)fieldIter.nextElement();
int height = Math.max(label.getPreferredSize().height, field.getPreferredSize().height);
label.setBounds( insets.left, yPos, labelWidth, height );
field.setBounds( insets.left + labelWidth + xGap,
Iterator<Component> fieldIter = fields.listIterator();
Iterator<Component> labelIter = labels.listIterator();
while (labelIter.hasNext() && fieldIter.hasNext()) {
JComponent label = (JComponent) labelIter.next();
JComponent field = (JComponent) fieldIter.next();
int height = Math.max(label.getPreferredSize().height, field.
getPreferredSize().height);
label.setBounds(insets.left, yPos, labelWidth, height);
field.setBounds(insets.left + labelWidth + xGap,
yPos,
c.getSize().width - (labelWidth +xGap + insets.left + insets.right),
height );
c.getSize().width - (labelWidth + xGap + insets.left
+ insets.right),
height);
yPos += (height + yGap);
}
}
public Dimension minimumLayoutSize(Container c) {
Insets insets = c.getInsets();
int labelWidth = 0;
Enumeration labelIter = labels.elements();
while(labelIter.hasMoreElements()) {
JComponent comp = (JComponent)labelIter.nextElement();
labelWidth = Math.max( labelWidth, comp.getPreferredSize().width );
for (Component comp : labels) {
labelWidth = Math.max(labelWidth, comp.getPreferredSize().width);
}
int yPos = insets.top;
labelIter = labels.elements();
Enumeration fieldIter = fields.elements();
while(labelIter.hasMoreElements() && fieldIter.hasMoreElements()) {
JComponent label = (JComponent)labelIter.nextElement();
JComponent field = (JComponent)fieldIter.nextElement();
int height = Math.max(label.getPreferredSize().height, field.getPreferredSize().height);
Iterator<Component> labelIter = labels.listIterator();
Iterator<Component> fieldIter = fields.listIterator();
while (labelIter.hasNext() && fieldIter.hasNext()) {
Component label = labelIter.next();
Component field = fieldIter.next();
int height = Math.max(label.getPreferredSize().height, field.
getPreferredSize().height);
yPos += (height + yGap);
}
return new Dimension( labelWidth * 3 , yPos );
return new Dimension(labelWidth * 3, yPos);
}
public Dimension preferredLayoutSize(Container c) {
......@@ -177,9 +186,7 @@ public class MetalworksDocumentFrame extends JInternalFrame {
return d;
}
public void removeLayoutComponent(Component c) {}
}
public void removeLayoutComponent(Component c) {
}
}
}
/*
* Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,50 +29,70 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.metal.*;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.InputStream;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.UIManager;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalTheme;
import javax.swing.plaf.metal.OceanTheme;
/**
* This is the main container frame for the Metalworks demo app
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class MetalworksFrame extends JFrame {
@SuppressWarnings("serial")
public final class MetalworksFrame extends JFrame {
JMenuBar menuBar;
JDesktopPane desktop;
JInternalFrame toolPalette;
JCheckBoxMenuItem showToolPaletteMenuItem;
static final Integer DOCLAYER = new Integer(5);
static final Integer TOOLLAYER = new Integer(6);
static final Integer HELPLAYER = new Integer(7);
static final String ABOUTMSG = "Metalworks \n \nAn application written to show off the Java Look & Feel. \n \nWritten by the JavaSoft Look & Feel Team \n Michael Albers\n Tom Santos\n Jeff Shapiro\n Steve Wilson";
static final Integer DOCLAYER = 5;
static final Integer TOOLLAYER = 6;
static final Integer HELPLAYER = 7;
static final String ABOUTMSG = "Metalworks \n \nAn application written to "
+ "show off the Java Look & Feel. \n \nWritten by the JavaSoft "
+ "Look & Feel Team \n Michael Albers\n Tom Santos\n "
+ "Jeff Shapiro\n Steve Wilson";
public MetalworksFrame() {
super("Metalworks");
final int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds ( inset, inset, screenSize.width - inset*2, screenSize.height - inset*2 );
setBounds(inset, inset, screenSize.width - inset * 2, screenSize.height - inset
* 2);
buildContent();
buildMenus();
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
quit();
}});
UIManager.addPropertyChangeListener(new UISwitchListener((JComponent)getRootPane()));
}
});
UIManager.addPropertyChangeListener(new UISwitchListener(
(JComponent) getRootPane()));
}
protected void buildMenus() {
......@@ -87,9 +107,12 @@ public class MetalworksFrame extends JFrame {
// load a theme from a text file
MetalTheme myTheme = null;
try {
InputStream istream = getClass().getResourceAsStream("/resources/MyTheme.theme");
InputStream istream = getClass().getResourceAsStream(
"/resources/MyTheme.theme");
myTheme = new PropertiesMetalTheme(istream);
} catch (NullPointerException e) {System.out.println(e);}
} catch (NullPointerException e) {
System.out.println(e);
}
// build an array of themes
MetalTheme[] themes = { new OceanTheme(),
......@@ -121,19 +144,25 @@ public class MetalworksFrame extends JFrame {
JMenuItem quit = new JMenuItem("Quit");
newWin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
newDocument();
}});
}
});
open.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openDocument();
}});
}
});
quit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
quit();
}});
}
});
file.add(newWin);
file.add(open);
......@@ -156,9 +185,11 @@ public class MetalworksFrame extends JFrame {
paste.setEnabled(false);
prefs.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openPrefsWindow();
}});
}
});
edit.add(undo);
edit.addSeparator();
......@@ -178,9 +209,11 @@ public class MetalworksFrame extends JFrame {
outBox.setEnabled(false);
inBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openInBox();
}});
}
});
views.add(inBox);
views.add(outBox);
......@@ -203,21 +236,30 @@ public class MetalworksFrame extends JFrame {
live.setSelected(true);
slow.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
slow.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// for right now I'm saying if you set the mode
// to something other than a specified mode
// it will revert to the old way
// This is mostly for comparison's sake
desktop.setDragMode(-1);}});
desktop.setDragMode(-1);
}
});
live.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
}
});
live.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE);}});
outline.addActionListener(new ActionListener() {
outline.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);}});
public void actionPerformed(ActionEvent e) {
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
}
});
speed.add(live);
......@@ -232,15 +274,18 @@ public class MetalworksFrame extends JFrame {
JMenuItem openHelp = new JMenuItem("Open Help Window");
about.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showAboutBox();
}
});
openHelp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openHelpWindow();
}});
}
});
help.add(about);
help.add(openHelp);
......@@ -263,7 +308,8 @@ public class MetalworksFrame extends JFrame {
try {
doc.setVisible(true);
doc.setSelected(true);
} catch (java.beans.PropertyVetoException e2) {}
} catch (java.beans.PropertyVetoException e2) {
}
}
public void openDocument() {
......@@ -277,7 +323,8 @@ public class MetalworksFrame extends JFrame {
try {
help.setVisible(true);
help.setSelected(true);
} catch (java.beans.PropertyVetoException e2) {}
} catch (java.beans.PropertyVetoException e2) {
}
}
public void showAboutBox() {
......@@ -286,7 +333,7 @@ public class MetalworksFrame extends JFrame {
public void openPrefsWindow() {
MetalworksPrefs dialog = new MetalworksPrefs(this);
dialog.show();
dialog.setVisible(true);
}
......@@ -296,6 +343,7 @@ public class MetalworksFrame extends JFrame {
try {
doc.setVisible(true);
doc.setSelected(true);
} catch (java.beans.PropertyVetoException e2) {}
} catch (java.beans.PropertyVetoException e2) {
}
}
}
/*
* Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,8 +29,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import javax.swing.*;
import java.awt.*;
......@@ -40,26 +38,31 @@ import java.io.*;
import javax.swing.text.*;
import javax.swing.event.*;
/*
/**
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
@SuppressWarnings("serial")
public class MetalworksHelp extends JInternalFrame {
public MetalworksHelp() {
super("Help", true, true, true, true);
setFrameIcon( (Icon)UIManager.get("Tree.openIcon")); // PENDING(steve) need more general palce to get this icon
setBounds( 200, 25, 400, 400);
setFrameIcon((Icon) UIManager.get("Tree.openIcon")); // PENDING(steve) need more general place to get this icon
setBounds(200, 25, 400, 400);
HtmlPane html = new HtmlPane();
setContentPane(html);
}
}
@SuppressWarnings("serial")
class HtmlPane extends JScrollPane implements HyperlinkListener {
JEditorPane html;
@SuppressWarnings("LeakingThisInConstructor")
public HtmlPane() {
try {
URL url = getClass().getResource("/resources/HelpFiles/toc.html");
......@@ -106,6 +109,7 @@ class HtmlPane extends JScrollPane implements HyperlinkListener {
SwingUtilities.invokeLater(new PageLoader(u, c));
}
/**
* temporary class that loads synchronously (although
* later than the request so that a cursor change
......@@ -142,9 +146,7 @@ class HtmlPane extends JScrollPane implements HyperlinkListener {
}
}
}
URL url;
Cursor cursor;
}
}
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,22 +29,20 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.tree.*;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
/**
* This is a subclass of JInternalFrame which displays a tree.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
@SuppressWarnings("serial")
public class MetalworksInBox extends JInternalFrame {
public MetalworksInBox() {
......@@ -57,49 +55,47 @@ public class MetalworksInBox extends JInternalFrame {
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Mail Boxes");
top.add( unread = new DefaultMutableTreeNode("Unread Mail") );
top.add( personal = new DefaultMutableTreeNode("Personal") );
top.add( business = new DefaultMutableTreeNode("Business") );
top.add( spam = new DefaultMutableTreeNode("Spam") );
unread.add( new DefaultMutableTreeNode("Buy Stuff Now") );
unread.add( new DefaultMutableTreeNode("Read Me Now") );
unread.add( new DefaultMutableTreeNode("Hot Offer") );
unread.add( new DefaultMutableTreeNode("Re: Re: Thank You") );
unread.add( new DefaultMutableTreeNode("Fwd: Good Joke") );
personal.add( new DefaultMutableTreeNode("Hi") );
personal.add( new DefaultMutableTreeNode("Good to hear from you") );
personal.add( new DefaultMutableTreeNode("Re: Thank You") );
business.add( new DefaultMutableTreeNode("Thanks for your order") );
business.add( new DefaultMutableTreeNode("Price Quote") );
business.add( new DefaultMutableTreeNode("Here is the invoice") );
business.add( new DefaultMutableTreeNode("Project Metal: delivered on time") );
business.add( new DefaultMutableTreeNode("Your salary raise approved") );
spam.add( new DefaultMutableTreeNode("Buy Now") );
spam.add( new DefaultMutableTreeNode("Make $$$ Now") );
spam.add( new DefaultMutableTreeNode("HOT HOT HOT") );
spam.add( new DefaultMutableTreeNode("Buy Now") );
spam.add( new DefaultMutableTreeNode("Don't Miss This") );
spam.add( new DefaultMutableTreeNode("Opportunity in Precious Metals") );
spam.add( new DefaultMutableTreeNode("Buy Now") );
spam.add( new DefaultMutableTreeNode("Last Chance") );
spam.add( new DefaultMutableTreeNode("Buy Now") );
spam.add( new DefaultMutableTreeNode("Make $$$ Now") );
spam.add( new DefaultMutableTreeNode("To Hot To Handle") );
spam.add( new DefaultMutableTreeNode("I'm waiting for your call") );
top.add(unread = new DefaultMutableTreeNode("Unread Mail"));
top.add(personal = new DefaultMutableTreeNode("Personal"));
top.add(business = new DefaultMutableTreeNode("Business"));
top.add(spam = new DefaultMutableTreeNode("Spam"));
unread.add(new DefaultMutableTreeNode("Buy Stuff Now"));
unread.add(new DefaultMutableTreeNode("Read Me Now"));
unread.add(new DefaultMutableTreeNode("Hot Offer"));
unread.add(new DefaultMutableTreeNode("Re: Re: Thank You"));
unread.add(new DefaultMutableTreeNode("Fwd: Good Joke"));
personal.add(new DefaultMutableTreeNode("Hi"));
personal.add(new DefaultMutableTreeNode("Good to hear from you"));
personal.add(new DefaultMutableTreeNode("Re: Thank You"));
business.add(new DefaultMutableTreeNode("Thanks for your order"));
business.add(new DefaultMutableTreeNode("Price Quote"));
business.add(new DefaultMutableTreeNode("Here is the invoice"));
business.add(new DefaultMutableTreeNode(
"Project Metal: delivered on time"));
business.add(new DefaultMutableTreeNode("Your salary raise approved"));
spam.add(new DefaultMutableTreeNode("Buy Now"));
spam.add(new DefaultMutableTreeNode("Make $$$ Now"));
spam.add(new DefaultMutableTreeNode("HOT HOT HOT"));
spam.add(new DefaultMutableTreeNode("Buy Now"));
spam.add(new DefaultMutableTreeNode("Don't Miss This"));
spam.add(new DefaultMutableTreeNode("Opportunity in Precious Metals"));
spam.add(new DefaultMutableTreeNode("Buy Now"));
spam.add(new DefaultMutableTreeNode("Last Chance"));
spam.add(new DefaultMutableTreeNode("Buy Now"));
spam.add(new DefaultMutableTreeNode("Make $$$ Now"));
spam.add(new DefaultMutableTreeNode("To Hot To Handle"));
spam.add(new DefaultMutableTreeNode("I'm waiting for your call"));
JTree tree = new JTree(top);
JScrollPane treeScroller = new JScrollPane(tree);
treeScroller.setBackground(tree.getBackground());
setContentPane(treeScroller);
setSize( 325, 200);
setLocation( 75, 75);
setSize(325, 200);
setLocation(75, 75);
}
}
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,50 +29,70 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.metal.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
/**
* This is dialog which allows users to choose preferences
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class MetalworksPrefs extends JDialog {
@SuppressWarnings("serial")
public final class MetalworksPrefs extends JDialog {
public MetalworksPrefs(JFrame f) {
super(f, "Preferences", true);
JPanel container = new JPanel();
container.setLayout( new BorderLayout() );
container.setLayout(new BorderLayout());
JTabbedPane tabs = new JTabbedPane();
JPanel filters = buildFilterPanel();
JPanel conn = buildConnectingPanel();
tabs.addTab( "Filters", null, filters );
tabs.addTab( "Connecting", null, conn );
tabs.addTab("Filters", null, filters);
tabs.addTab("Connecting", null, conn);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout ( new FlowLayout(FlowLayout.RIGHT) );
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
CancelPressed();
}});
buttonPanel.add( cancel );
}
});
buttonPanel.add(cancel);
JButton ok = new JButton("OK");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
OKPressed();
}});
buttonPanel.add( ok );
}
});
buttonPanel.add(ok);
getRootPane().setDefaultButton(ok);
container.add(tabs, BorderLayout.CENTER);
......@@ -85,12 +105,12 @@ public class MetalworksPrefs extends JDialog {
public JPanel buildFilterPanel() {
JPanel filters = new JPanel();
filters.setLayout( new GridLayout(1, 0) );
filters.setLayout(new GridLayout(1, 0));
JPanel spamPanel = new JPanel();
spamPanel.setLayout(new ColumnLayout());
spamPanel.setBorder( new TitledBorder("Spam") );
spamPanel.setBorder(new TitledBorder("Spam"));
ButtonGroup spamGroup = new ButtonGroup();
JRadioButton file = new JRadioButton("File in Spam Folder");
JRadioButton delete = new JRadioButton("Auto Delete");
......@@ -106,7 +126,7 @@ public class MetalworksPrefs extends JDialog {
JPanel autoRespond = new JPanel();
autoRespond.setLayout(new ColumnLayout());
autoRespond.setBorder( new TitledBorder("Auto Response") );
autoRespond.setBorder(new TitledBorder("Auto Response"));
ButtonGroup respondGroup = new ButtonGroup();
JRadioButton none = new JRadioButton("None");
......@@ -129,10 +149,10 @@ public class MetalworksPrefs extends JDialog {
public JPanel buildConnectingPanel() {
JPanel connectPanel = new JPanel();
connectPanel.setLayout( new ColumnLayout() );
connectPanel.setLayout(new ColumnLayout());
JPanel protoPanel = new JPanel();
JLabel protoLabel = new JLabel ("Protocol");
JLabel protoLabel = new JLabel("Protocol");
JComboBox protocol = new JComboBox();
protocol.addItem("SMTP");
protocol.addItem("IMAP");
......@@ -141,7 +161,7 @@ public class MetalworksPrefs extends JDialog {
protoPanel.add(protocol);
JPanel attachmentPanel = new JPanel();
JLabel attachmentLabel = new JLabel ("Attachments");
JLabel attachmentLabel = new JLabel("Attachments");
JComboBox attach = new JComboBox();
attach.addItem("Download Always");
attach.addItem("Ask size > 1 Meg");
......@@ -152,7 +172,7 @@ public class MetalworksPrefs extends JDialog {
JCheckBox autoConn = new JCheckBox("Auto Connect");
JCheckBox compress = new JCheckBox("Use Compression");
autoConn.setSelected( true );
autoConn.setSelected(true);
connectPanel.add(protoPanel);
connectPanel.add(attachmentPanel);
......@@ -161,18 +181,16 @@ public class MetalworksPrefs extends JDialog {
return connectPanel;
}
protected void centerDialog() {
Dimension screenSize = this.getToolkit().getScreenSize();
Dimension size = this.getSize();
screenSize.height = screenSize.height/2;
screenSize.width = screenSize.width/2;
size.height = size.height/2;
size.width = size.width/2;
screenSize.height = screenSize.height / 2;
screenSize.width = screenSize.width / 2;
size.height = size.height / 2;
size.width = size.width / 2;
int y = screenSize.height - size.height;
int x = screenSize.width - size.width;
this.setLocation(x,y);
this.setLocation(x, y);
}
public void CancelPressed() {
......@@ -182,16 +200,17 @@ public class MetalworksPrefs extends JDialog {
public void OKPressed() {
this.setVisible(false);
}
}
class ColumnLayout implements LayoutManager {
int xInset = 5;
int yInset = 5;
int yGap = 2;
public void addLayoutComponent(String s, Component c) {}
public void addLayoutComponent(String s, Component c) {
}
public void layoutContainer(Container c) {
Insets insets = c.getInsets();
......@@ -199,10 +218,10 @@ class ColumnLayout implements LayoutManager {
Component[] children = c.getComponents();
Dimension compSize = null;
for (int i = 0; i < children.length; i++) {
compSize = children[i].getPreferredSize();
children[i].setSize(compSize.width, compSize.height);
children[i].setLocation( xInset + insets.left, height);
for (Component child : children) {
compSize = child.getPreferredSize();
child.setSize(compSize.width, compSize.height);
child.setLocation(xInset + insets.left, height);
height += compSize.height + yGap;
}
......@@ -215,19 +234,20 @@ class ColumnLayout implements LayoutManager {
Component[] children = c.getComponents();
Dimension compSize = null;
for (int i = 0; i < children.length; i++) {
compSize = children[i].getPreferredSize();
for (Component child : children) {
compSize = child.getPreferredSize();
height += compSize.height + yGap;
width = Math.max(width, compSize.width + insets.left + insets.right + xInset*2);
width = Math.max(width, compSize.width + insets.left + insets.right + xInset
* 2);
}
height += insets.bottom;
return new Dimension( width, height);
return new Dimension(width, height);
}
public Dimension preferredLayoutSize(Container c) {
return minimumLayoutSize(c);
}
public void removeLayoutComponent(Component c) {}
public void removeLayoutComponent(Component c) {
}
}
/*
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,17 +29,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.StringTokenizer;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.io.*;
import java.util.*;
/**
* This class allows you to load a theme from a file.
......@@ -57,29 +55,26 @@ import java.util.*;
* but it could easily be extended to load fonts - or even icons.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class PropertiesMetalTheme extends DefaultMetalTheme {
private String name = "Custom Theme";
private ColorUIResource primary1;
private ColorUIResource primary2;
private ColorUIResource primary3;
private ColorUIResource secondary1;
private ColorUIResource secondary2;
private ColorUIResource secondary3;
private ColorUIResource black;
private ColorUIResource white;
/**
* pass an inputstream pointing to a properties file.
* Colors will be initialized to be the same as the DefaultMetalTheme,
* and then any colors provided in the properties file will override that.
*/
public PropertiesMetalTheme( InputStream stream ) {
public PropertiesMetalTheme(InputStream stream) {
initColors();
loadProperties(stream);
}
......@@ -120,7 +115,7 @@ public class PropertiesMetalTheme extends DefaultMetalTheme {
Object colorString = null;
colorString = prop.get("primary1");
if (colorString != null){
if (colorString != null) {
primary1 = parseColor(colorString.toString());
}
......@@ -161,18 +156,50 @@ public class PropertiesMetalTheme extends DefaultMetalTheme {
}
public String getName() { return name; }
@Override
public String getName() {
return name;
}
@Override
protected ColorUIResource getPrimary1() {
return primary1;
}
@Override
protected ColorUIResource getPrimary2() {
return primary2;
}
@Override
protected ColorUIResource getPrimary3() {
return primary3;
}
protected ColorUIResource getPrimary1() { return primary1; }
protected ColorUIResource getPrimary2() { return primary2; }
protected ColorUIResource getPrimary3() { return primary3; }
@Override
protected ColorUIResource getSecondary1() {
return secondary1;
}
protected ColorUIResource getSecondary1() { return secondary1; }
protected ColorUIResource getSecondary2() { return secondary2; }
protected ColorUIResource getSecondary3() { return secondary3; }
@Override
protected ColorUIResource getSecondary2() {
return secondary2;
}
protected ColorUIResource getBlack() { return black; }
protected ColorUIResource getWhite() { return white; }
@Override
protected ColorUIResource getSecondary3() {
return secondary3;
}
@Override
protected ColorUIResource getBlack() {
return black;
}
@Override
protected ColorUIResource getWhite() {
return white;
}
/**
* parse a comma delimited list of 3 strings into a Color
......
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,22 +29,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import java.awt.*;
import java.beans.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
/**
* This class listens for UISwitches, and updates a given component.
*
* @author Steve Wilson
* @author Alexander Kouznetsov
*/
public class UISwitchListener implements PropertyChangeListener {
JComponent componentToSwitch;
public UISwitchListener(JComponent c) {
......
......@@ -5,9 +5,9 @@
</HEAD>
<BODY>
<H1>Java L&F Credits</H1>
<H1>Java L&amp;F Credits</H1>
<P>The Java L&F Engineering team:</P>
<P>The Java L&amp;F Engineering team:</P>
<UL>
<LI>Mike Albers
......@@ -22,12 +22,12 @@
<LI>Harry Vertelney
</UL>
<P>The Java L&F Designer:</P>
<P>The Java L&amp;F Designer:</P>
<UL>
<LI>Chris Ryan
</UL>
<P><A HREF="toc.html"><IMG SRC="back.gif" WIDTH="42" HEIGHT="22" ALIGN="BOTTOM" NATURALSIZEFLAG="3" BORDER="0">Back</A>
<P><A HREF="toc.html"><IMG alt="Back" SRC="back.gif" WIDTH="42" HEIGHT="22" ALIGN="BOTTOM" BORDER="0">Back</A>
</BODY>
</HTML>
......@@ -7,11 +7,11 @@
<BODY>
<H1>
About the Java L&F</H1>
The Java Look and Feel is a cross-platform look & feel being provided by Javasoft.
Here is some information about the Java L&F you might find useful.
About the Java L&amp;F</H1>
The Java Look and Feel is a cross-platform look &amp; feel being provided by Javasoft.
Here is some information about the Java L&amp;F you might find useful.
<P>The Java L&F implements all of the basic Swing functionality,
<P>The Java L&amp;F implements all of the basic Swing functionality,
but also extends it in several areas including:
<UL>
<LI>
......@@ -27,27 +27,27 @@ Toolbars</LI>
Trees</LI>
</UL>
</P>
<P/>
<H1>
Themes</H1>
<P>One of the first things we learned while implementing the Java L&F
<P>One of the first things we learned while implementing the Java L&amp;F
was than many developers feel very strongly about how colors are used in
their software. To help accommodate this we created a Theme mechanism
which allows a developer to easily specify the default colors, fonts and
icons used by the L&F.</P>
icons used by the L&amp;F.</P>
<P>The theme mechanism is designed to allow developers to create
their own themes. For an example of this, see the themes
which are included with Metalworks. Note, like all of the L&F packages,
which are included with Metalworks. Note, like all of the L&amp;F packages,
the metal package is not yet frozen and the theme mechanism may change as
we get developer feedback on how to improve it.</P>
<H1>
Sliders</H1>
<P>There are several areas where the Java L&F introduces some optional
<P>There are several areas where the Java L&amp;F introduces some optional
"value-added" features above the base line capabilities of swing.&nbsp;
One is the option of Filled Sliders. These are ideal for things like
volume controls. To access the Java L&F "value-added" features you
volume controls. To access the Java L&amp;F "value-added" features you
pass in a token to the component's putClientProperty method.&nbsp;Here
is an example:</P>
......@@ -60,12 +60,12 @@ slider.putClientProperty("JSlider.isFilled",
<P>Note that if a UI such as Windows or Motif encounters a property such as
JSlider.fill which is does not understand that property will be ignored.&nbsp;
Thus you don't have to worry about problems which could arise if you switch
to a different L&F.</P>
to a different L&amp;F.</P>
<H1>
ToolBars</H1>
<P>Many popular applications support "roll-over" effects on buttons in toolbars.
The Java L&F provides an easy way to do this. Here is a code snippit:</P>
The Java L&amp;F provides an easy way to do this. Here is a code snippit:</P>
<PRE>
JToolBar toolbar = new JToolBar();<BR>
......@@ -82,7 +82,7 @@ is a nice effect for many applications.</P>
<H1>
Trees</H1>
<P>Java L&F allows you to control the line style used in the JTree component. Here are some code snippits:</P>
<P>Java L&amp;F allows you to control the line style used in the JTree component. Here are some code snippits:</P>
<PRE>
JTree myTree = new JTree();
......@@ -101,6 +101,6 @@ myTree.putClientProperty("JTree.lineStyle",
"Horizontal");
</PRE>
<P><A HREF="toc.html"><IMG SRC="back.gif" BORDER=0 NATURALSIZEFLAG="3" HEIGHT=22 WIDTH=42 ALIGN=BOTTOM>Back</A>
<P><A HREF="toc.html"><IMG alt="Back" SRC="back.gif" BORDER=0 HEIGHT=22 WIDTH=42 ALIGN=BOTTOM>Back</A>
</BODY>
</HTML>
......@@ -8,7 +8,7 @@
<H1>
About Metalworks</H1>
Metalworks is a simple Swing-based simulated email application. It shows off several features of Swing including: JInternalFrame, JTabbedPane, JFileChooser, JEditorPane and JRadioButtonMenuItem. It is optimized to work with the Java Look & Feel and shows use of several Java L&F specific features including themes.
Metalworks is a simple Swing-based simulated email application. It shows off several features of Swing including: JInternalFrame, JTabbedPane, JFileChooser, JEditorPane and JRadioButtonMenuItem. It is optimized to work with the Java Look &amp; Feel and shows use of several Java L&amp;F specific features including themes.
<H1>
Metalworks Features</H1>
The functionality of the Metalworks demo is minimal, and many controls are non-functional. They are only intended to show how to construct the UI for such interfaces. Things that do work in the Metalworks demo include:
......@@ -28,6 +28,6 @@ The functionality of the Metalworks demo is minimal, and many controls are non-f
&nbsp;
<P><A HREF="toc.html"><IMG SRC="back.gif" BORDER=0 NATURALSIZEFLAG="3" HEIGHT=22 WIDTH=42 ALIGN=BOTTOM>Back</A>
<P><A HREF="toc.html"><IMG alt="Back" SRC="back.gif" BORDER=0 HEIGHT=22 WIDTH=42 ALIGN=BOTTOM>Back</A>
</BODY>
</HTML>
......@@ -5,7 +5,7 @@
</HEAD>
<BODY>
<H1><IMG SRC="duke.gif" WIDTH="98" HEIGHT="98" ALIGN="MIDDLE" NATURALSIZEFLAG="3">About Swing</H1>
<H1><IMG alt="About Swing" SRC="duke.gif" WIDTH="98" HEIGHT="98" ALIGN="MIDDLE">About Swing</H1>
<P>&nbsp;</P>
......@@ -17,6 +17,6 @@ will give users the ability to switch the look and feel of an application
without restarting it and without the developer having to subclass the entire
component set.</P>
<P><A HREF="toc.html"><IMG SRC="back.gif" WIDTH="42" HEIGHT="22" ALIGN="BOTTOM" NATURALSIZEFLAG="3" BORDER="0">Back</A>
<P><A HREF="toc.html"><IMG alt="Back" SRC="back.gif" WIDTH="42" HEIGHT="22" ALIGN="BOTTOM" BORDER="0">Back</A>
</BODY>
</HTML>
......@@ -5,7 +5,7 @@
</HEAD>
<BODY>
<H1><IMG SRC="javalogo.gif" WIDTH="52" HEIGHT="88" ALIGN="MIDDLE" NATURALSIZEFLAG="3">Metalworks Help</H1>
<H1><IMG alt="Help" SRC="javalogo.gif" WIDTH="52" HEIGHT="88" ALIGN="MIDDLE">Metalworks Help</H1>
<P>Welcome to the Metalworks Help files. These are actually HTML files which
you are viewing with the Swing JEditorPane component. Pretty cool, eh? Were
......@@ -18,7 +18,7 @@ possible. Click on the links below for more information.</P>
<UL>
<LI><A HREF="metalworks.html">About Metalworks</A>
<LI><A HREF="metal.html">About Java L&F</A>
<LI><A HREF="metal.html">About Java L&amp;F</A>
<LI><A HREF="swing.html">About Swing</A>
<LI><A HREF="credits.html">Credits</A>
</UL>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册