src/demo/share/jfc/Metalworks/MetalworksDocumentFrame.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.Insets;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    47
import java.awt.LayoutManager;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    48
import java.util.ArrayList;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    49
import java.util.Iterator;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    50
import java.util.List;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    51
import javax.swing.JComponent;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    52
import javax.swing.JInternalFrame;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    53
import javax.swing.JLabel;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    54
import javax.swing.JPanel;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    55
import javax.swing.JScrollPane;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    56
import javax.swing.JTextArea;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    57
import javax.swing.JTextField;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    58
import javax.swing.border.EmptyBorder;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
/**
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    62
 * This is a subclass of JInternalFrame which displays documents.
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    63
 *
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    64
 * @author Steve Wilson
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    65
 */
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    66
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
public class MetalworksDocumentFrame extends JInternalFrame {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    static int openFrameCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    static final int offset = 30;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public MetalworksDocumentFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        super("", true, true, true, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        openFrameCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        setTitle("Untitled Message " + openFrameCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        JPanel top = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        top.setBorder(new EmptyBorder(10, 10, 10, 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        top.setLayout(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        top.add(buildAddressPanel(), BorderLayout.NORTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    82
        JTextArea content = new JTextArea(15, 30);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    83
        content.setBorder(new EmptyBorder(0, 5, 0, 5));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        content.setLineWrap(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        JScrollPane textScroller = new JScrollPane(content,
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    89
                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    90
                JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    91
        top.add(textScroller, BorderLayout.CENTER);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        setContentPane(top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        pack();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    96
        setLocation(offset * openFrameCount, offset * openFrameCount);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private JPanel buildAddressPanel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        JPanel p = new JPanel();
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   102
        p.setLayout(new LabeledPairLayout());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        JLabel toLabel = new JLabel("To: ", JLabel.RIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        JTextField toField = new JTextField(25);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        p.add(toLabel, "label");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        p.add(toField, "field");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        JLabel subLabel = new JLabel("Subj: ", JLabel.RIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        JTextField subField = new JTextField(25);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        p.add(subLabel, "label");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        p.add(subField, "field");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        JLabel ccLabel = new JLabel("cc: ", JLabel.RIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        JTextField ccField = new JTextField(25);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        p.add(ccLabel, "label");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        p.add(ccField, "field");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   126
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    class LabeledPairLayout implements LayoutManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   129
        List<Component> labels = new ArrayList<Component>();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   130
        List<Component> fields = new ArrayList<Component>();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   131
        int yGap = 2;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   132
        int xGap = 2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   134
        public void addLayoutComponent(String s, Component c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   135
            if (s.equals("label")) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   136
                labels.add(c);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   137
            } else {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   138
                fields.add(c);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   139
            }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   140
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   142
        public void layoutContainer(Container c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   143
            Insets insets = c.getInsets();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   145
            int labelWidth = 0;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   146
            for (Component comp : labels) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   147
                labelWidth = Math.max(labelWidth, comp.getPreferredSize().width);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   148
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   150
            int yPos = insets.top;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   152
            Iterator<Component> fieldIter = fields.listIterator();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   153
            Iterator<Component> labelIter = labels.listIterator();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   154
            while (labelIter.hasNext() && fieldIter.hasNext()) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   155
                JComponent label = (JComponent) labelIter.next();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   156
                JComponent field = (JComponent) fieldIter.next();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   157
                int height = Math.max(label.getPreferredSize().height, field.
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   158
                        getPreferredSize().height);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   159
                label.setBounds(insets.left, yPos, labelWidth, height);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   160
                field.setBounds(insets.left + labelWidth + xGap,
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   161
                        yPos,
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   162
                        c.getSize().width - (labelWidth + xGap + insets.left
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   163
                        + insets.right),
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   164
                        height);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   165
                yPos += (height + yGap);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   166
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   168
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   170
        public Dimension minimumLayoutSize(Container c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   171
            Insets insets = c.getInsets();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   173
            int labelWidth = 0;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   174
            for (Component comp : labels) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   175
                labelWidth = Math.max(labelWidth, comp.getPreferredSize().width);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   176
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   178
            int yPos = insets.top;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   180
            Iterator<Component> labelIter = labels.listIterator();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   181
            Iterator<Component> fieldIter = fields.listIterator();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   182
            while (labelIter.hasNext() && fieldIter.hasNext()) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   183
                Component label = labelIter.next();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   184
                Component field = fieldIter.next();
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   185
                int height = Math.max(label.getPreferredSize().height, field.
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   186
                        getPreferredSize().height);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   187
                yPos += (height + yGap);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   188
            }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   189
            return new Dimension(labelWidth * 3, yPos);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   190
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   192
        public Dimension preferredLayoutSize(Container c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   193
            Dimension d = minimumLayoutSize(c);
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   194
            d.width *= 2;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   195
            return d;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   196
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   198
        public void removeLayoutComponent(Component c) {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   199
        }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   200
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
}