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