jdk/src/share/demo/jfc/Metalworks/MetalworksFrame.java
author tbell
Fri, 27 Feb 2009 10:54:11 -0800
changeset 2091 7faffd237305
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2004 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *   - Neither the name of Sun Microsystems nor the names of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.swing.plaf.metal.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  * This is the main container frame for the Metalworks demo app
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  * @author Steve Wilson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public class MetalworksFrame extends JFrame {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    JMenuBar menuBar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    JDesktopPane desktop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    JInternalFrame toolPalette;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    JCheckBoxMenuItem showToolPaletteMenuItem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static final Integer DOCLAYER = new Integer(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static final Integer TOOLLAYER = new Integer(6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static final Integer HELPLAYER = new Integer(7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    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";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public MetalworksFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        super("Metalworks");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        final int inset = 50;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        setBounds ( inset, inset, screenSize.width - inset*2, screenSize.height - inset*2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        buildContent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        buildMenus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        this.addWindowListener(new WindowAdapter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                               public void windowClosing(WindowEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                                   quit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                               }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        UIManager.addPropertyChangeListener(new UISwitchListener((JComponent)getRootPane()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    protected void buildMenus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        menuBar = new JMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        menuBar.setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        JMenu file = buildFileMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        JMenu edit = buildEditMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        JMenu views = buildViewsMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        JMenu speed = buildSpeedMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        JMenu help = buildHelpMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        // load a theme from a text file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        MetalTheme myTheme = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            InputStream istream = getClass().getResourceAsStream("/resources/MyTheme.theme");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            myTheme =  new PropertiesMetalTheme(istream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        } catch (NullPointerException e) {System.out.println(e);}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        // build an array of themes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        MetalTheme[] themes = { new OceanTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                                new DefaultMetalTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                                new GreenMetalTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                                new AquaMetalTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                new KhakiMetalTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                                new DemoMetalTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                new ContrastMetalTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                                new BigContrastMetalTheme(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                myTheme };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        // put the themes in a menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        JMenu themeMenu = new MetalThemeMenu("Theme", themes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        menuBar.add(file);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        menuBar.add(edit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        menuBar.add(views);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        menuBar.add(themeMenu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        menuBar.add(speed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        menuBar.add(help);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        setJMenuBar(menuBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    protected JMenu buildFileMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        JMenu file = new JMenu("File");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        JMenuItem newWin = new JMenuItem("New");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        JMenuItem open = new JMenuItem("Open");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        JMenuItem quit = new JMenuItem("Quit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        newWin.addActionListener(new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                               public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                                   newDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                               }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        open.addActionListener(new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                               public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                   openDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                               }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        quit.addActionListener(new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                               public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                   quit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                               }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        file.add(newWin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        file.add(open);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        file.addSeparator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        file.add(quit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return file;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    protected JMenu buildEditMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        JMenu edit = new JMenu("Edit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        JMenuItem undo = new JMenuItem("Undo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        JMenuItem copy = new JMenuItem("Copy");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        JMenuItem cut = new JMenuItem("Cut");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        JMenuItem paste = new JMenuItem("Paste");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        JMenuItem prefs = new JMenuItem("Preferences...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        undo.setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        copy.setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        cut.setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        paste.setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        prefs.addActionListener(new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                               public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                   openPrefsWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                               }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        edit.add(undo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        edit.addSeparator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        edit.add(cut);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        edit.add(copy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        edit.add(paste);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        edit.addSeparator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        edit.add(prefs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        return edit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    protected JMenu buildViewsMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        JMenu views = new JMenu("Views");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        JMenuItem inBox = new JMenuItem("Open In-Box");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        JMenuItem outBox = new JMenuItem("Open Out-Box");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        outBox.setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        inBox.addActionListener(new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                               public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                                   openInBox();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                               }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        views.add(inBox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        views.add(outBox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return views;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     protected JMenu buildSpeedMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        JMenu speed = new JMenu("Drag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        JRadioButtonMenuItem live = new JRadioButtonMenuItem("Live");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        JRadioButtonMenuItem outline = new JRadioButtonMenuItem("Outline");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        JRadioButtonMenuItem slow = new JRadioButtonMenuItem("Old and Slow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        ButtonGroup group = new ButtonGroup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        group.add(live);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        group.add(outline);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        group.add(slow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        live.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        slow.addActionListener(new ActionListener(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                               public void actionPerformed(ActionEvent e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                // for right now I'm saying if you set the mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                                 // to something other than a specified mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                                 // it will revert to the old way
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                 // This is mostly for comparison's sake
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                               desktop.setDragMode(-1);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        live.addActionListener(new ActionListener(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                         public void actionPerformed(ActionEvent e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                         desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        outline.addActionListener(new ActionListener(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                         public void actionPerformed(ActionEvent e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                         desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);}});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        speed.add(live);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        speed.add(outline);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        speed.add(slow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        return speed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    protected JMenu buildHelpMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        JMenu help = new JMenu("Help");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        JMenuItem about = new JMenuItem("About Metalworks...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        JMenuItem openHelp = new JMenuItem("Open Help Window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        about.addActionListener(new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                showAboutBox();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        openHelp.addActionListener(new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                               public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                   openHelpWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                               }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        help.add(about);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        help.add(openHelp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return help;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    protected void buildContent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        desktop = new JDesktopPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        getContentPane().add(desktop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public void quit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        System.exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public void newDocument() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        JInternalFrame doc = new MetalworksDocumentFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        desktop.add(doc, DOCLAYER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            doc.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            doc.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        } catch (java.beans.PropertyVetoException e2) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    public void openDocument() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        JFileChooser chooser = new JFileChooser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        chooser.showOpenDialog(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    public void openHelpWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        JInternalFrame help = new MetalworksHelp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        desktop.add(help, HELPLAYER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            help.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            help.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        } catch (java.beans.PropertyVetoException e2) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    public void showAboutBox() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        JOptionPane.showMessageDialog(this, ABOUTMSG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public void openPrefsWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        MetalworksPrefs dialog = new MetalworksPrefs(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        dialog.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public void openInBox() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        JInternalFrame doc = new MetalworksInBox();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        desktop.add(doc, DOCLAYER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            doc.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            doc.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        } catch (java.beans.PropertyVetoException e2) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
}