src/demo/share/jfc/Metalworks/MetalworksPrefs.java
author ysuenaga
Wed, 13 Nov 2019 10:27:06 +0900
changeset 59045 846fee5ea75e
parent 47216 71c04702a3d5
permissions -rw-r--r--
8233785: Incorrect JDK version is reported in hs_err log Reviewed-by: dholmes, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
     2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
2
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
10292
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    32
/*
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    33
 * This source code is provided to illustrate the usage of a given feature
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    34
 * or technique and has been deliberately simplified. Additional steps
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    35
 * required for a production-quality application, such as security checks,
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    36
 * input validation and proper error handling, might not be present in
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    37
 * this sample code.
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    38
 */
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    39
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    40
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    42
import java.awt.BorderLayout;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    43
import java.awt.Component;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    44
import java.awt.Container;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    45
import java.awt.Dimension;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    46
import java.awt.FlowLayout;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    47
import java.awt.GridLayout;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    48
import java.awt.Insets;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    49
import java.awt.LayoutManager;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    50
import java.awt.event.ActionEvent;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    51
import java.awt.event.ActionListener;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    52
import javax.swing.ButtonGroup;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    53
import javax.swing.JButton;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    54
import javax.swing.JCheckBox;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    55
import javax.swing.JComboBox;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    56
import javax.swing.JDialog;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    57
import javax.swing.JFrame;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    58
import javax.swing.JLabel;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    59
import javax.swing.JPanel;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    60
import javax.swing.JRadioButton;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    61
import javax.swing.JTabbedPane;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    62
import javax.swing.UIManager;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    63
import javax.swing.border.TitledBorder;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
/**
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    67
 * This is dialog which allows users to choose preferences
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    68
 *
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    69
 * @author Steve Wilson
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    70
 * @author Alexander Kouznetsov
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    71
 */
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    72
@SuppressWarnings("serial")
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    73
public final class MetalworksPrefs extends JDialog {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public MetalworksPrefs(JFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        super(f, "Preferences", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        JPanel container = new JPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    78
        container.setLayout(new BorderLayout());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        JTabbedPane tabs = new JTabbedPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        JPanel filters = buildFilterPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        JPanel conn = buildConnectingPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    83
        tabs.addTab("Filters", null, filters);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    84
        tabs.addTab("Connecting", null, conn);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        JPanel buttonPanel = new JPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    88
        buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        JButton cancel = new JButton("Cancel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        cancel.addActionListener(new ActionListener() {
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    91
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    92
            public void actionPerformed(ActionEvent e) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    93
                CancelPressed();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    94
            }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    95
        });
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    96
        buttonPanel.add(cancel);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        JButton ok = new JButton("OK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        ok.addActionListener(new ActionListener() {
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    99
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   100
            public void actionPerformed(ActionEvent e) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   101
                OKPressed();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   102
            }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   103
        });
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   104
        buttonPanel.add(ok);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        getRootPane().setDefaultButton(ok);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        container.add(tabs, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        container.add(buttonPanel, BorderLayout.SOUTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        getContentPane().add(container);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        centerDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        UIManager.addPropertyChangeListener(new UISwitchListener(container));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public JPanel buildFilterPanel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        JPanel filters = new JPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   117
        filters.setLayout(new GridLayout(1, 0));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        JPanel spamPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        spamPanel.setLayout(new ColumnLayout());
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   122
        spamPanel.setBorder(new TitledBorder("Spam"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        ButtonGroup spamGroup = new ButtonGroup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        JRadioButton file = new JRadioButton("File in Spam Folder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        JRadioButton delete = new JRadioButton("Auto Delete");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        JRadioButton bomb = new JRadioButton("Reverse Mail-Bomb");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        spamGroup.add(file);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        spamGroup.add(delete);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        spamGroup.add(bomb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        spamPanel.add(file);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        spamPanel.add(delete);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        spamPanel.add(bomb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        file.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        filters.add(spamPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        JPanel autoRespond = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        autoRespond.setLayout(new ColumnLayout());
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   138
        autoRespond.setBorder(new TitledBorder("Auto Response"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        ButtonGroup respondGroup = new ButtonGroup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        JRadioButton none = new JRadioButton("None");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        JRadioButton vaca = new JRadioButton("Send Vacation Message");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        JRadioButton thx = new JRadioButton("Send Thank You Message");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        respondGroup.add(none);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        respondGroup.add(vaca);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        respondGroup.add(thx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        autoRespond.add(none);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        autoRespond.add(vaca);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        autoRespond.add(thx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        none.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        filters.add(autoRespond);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return filters;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public JPanel buildConnectingPanel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        JPanel connectPanel = new JPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   161
        connectPanel.setLayout(new ColumnLayout());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        JPanel protoPanel = new JPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   164
        JLabel protoLabel = new JLabel("Protocol");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        JComboBox protocol = new JComboBox();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        protocol.addItem("SMTP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        protocol.addItem("IMAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        protocol.addItem("Other...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        protoPanel.add(protoLabel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        protoPanel.add(protocol);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        JPanel attachmentPanel = new JPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   173
        JLabel attachmentLabel = new JLabel("Attachments");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        JComboBox attach = new JComboBox();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        attach.addItem("Download Always");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        attach.addItem("Ask size > 1 Meg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        attach.addItem("Ask size > 5 Meg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        attach.addItem("Ask Always");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        attachmentPanel.add(attachmentLabel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        attachmentPanel.add(attach);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        JCheckBox autoConn = new JCheckBox("Auto Connect");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        JCheckBox compress = new JCheckBox("Use Compression");
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   184
        autoConn.setSelected(true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        connectPanel.add(protoPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        connectPanel.add(attachmentPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        connectPanel.add(autoConn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        connectPanel.add(compress);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        return connectPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    protected void centerDialog() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        Dimension screenSize = this.getToolkit().getScreenSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        Dimension size = this.getSize();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   196
        screenSize.height = screenSize.height / 2;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   197
        screenSize.width = screenSize.width / 2;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   198
        size.height = size.height / 2;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   199
        size.width = size.width / 2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        int y = screenSize.height - size.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        int x = screenSize.width - size.width;
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   202
        this.setLocation(x, y);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public void CancelPressed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        this.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public void OKPressed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        this.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   212
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
class ColumnLayout implements LayoutManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   217
    int xInset = 5;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   218
    int yInset = 5;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   219
    int yGap = 2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   221
    public void addLayoutComponent(String s, Component c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   222
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   224
    public void layoutContainer(Container c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   225
        Insets insets = c.getInsets();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   226
        int height = yInset + insets.top;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   228
        Component[] children = c.getComponents();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   229
        Dimension compSize = null;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   230
        for (Component child : children) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   231
            compSize = child.getPreferredSize();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   232
            child.setSize(compSize.width, compSize.height);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   233
            child.setLocation(xInset + insets.left, height);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   234
            height += compSize.height + yGap;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   235
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   237
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   239
    public Dimension minimumLayoutSize(Container c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   240
        Insets insets = c.getInsets();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   241
        int height = yInset + insets.top;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   242
        int width = 0 + insets.left + insets.right;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   244
        Component[] children = c.getComponents();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   245
        Dimension compSize = null;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   246
        for (Component child : children) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   247
            compSize = child.getPreferredSize();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   248
            height += compSize.height + yGap;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   249
            width = Math.max(width, compSize.width + insets.left + insets.right + xInset
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   250
                    * 2);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   251
        }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   252
        height += insets.bottom;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   253
        return new Dimension(width, height);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   254
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   256
    public Dimension preferredLayoutSize(Container c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   257
        return minimumLayoutSize(c);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   258
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   260
    public void removeLayoutComponent(Component c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   261
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
}