usr/src/java/util/org/opensolaris/os/vp/util/swing/GUIUtil.java
author Stephen Talley <stephen.talley@oracle.com>
Thu, 03 Feb 2011 14:10:29 -0500
changeset 647 ddbb04508ea4
parent 591 7c5752b99fd6
permissions -rw-r--r--
17819 nit roundup
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
    23
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
219
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 213
diff changeset
    26
package org.opensolaris.os.vp.util.swing;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    28
import java.awt.*;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    29
import java.awt.event.*;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    30
import java.io.IOException;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    31
import java.lang.reflect.InvocationTargetException;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    32
import java.util.*;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    33
import java.util.List;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    34
import javax.swing.*;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    35
import javax.swing.border.Border;
219
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 213
diff changeset
    36
import org.opensolaris.os.vp.util.misc.*;
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 473
diff changeset
    37
import org.opensolaris.os.vp.util.misc.finder.Finder;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    38
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    39
public class GUIUtil {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    40
    //
148
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    41
    // Inner classes
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    42
    //
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    43
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    44
    public static interface HasMnemonic {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    45
	String getText();
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    46
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    47
	void setMnemonic(int i);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    48
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    49
	void setMnemonicIndex(int i);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    50
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    51
	void setText(String text);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    52
    }
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
    53
222
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    54
    public static class MnemonicAction implements HasMnemonic {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    55
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    56
	// Instance data
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    57
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    58
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    59
	private Action action;
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    60
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    61
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    62
	// Constructors
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    63
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    64
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    65
	public MnemonicAction(Action action) {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    66
	    this.action = action;
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    67
	}
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    68
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    69
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    70
	// HasMnemonic methods
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    71
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    72
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    73
	@Override
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    74
	public String getText() {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    75
	    Object text = action.getValue(Action.NAME);
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    76
	    return text == null ? null : text.toString();
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    77
	}
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    78
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    79
	@Override
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    80
	public void setMnemonic(int i) {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    81
	    action.putValue(Action.MNEMONIC_KEY, i);
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    82
	}
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    83
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    84
	@Override
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    85
	public void setMnemonicIndex(int i) {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    86
	    action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, i);
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    87
	}
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    88
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    89
	@Override
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    90
	public void setText(String text) {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    91
	    action.putValue(Action.NAME, text);
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    92
	}
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    93
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    94
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    95
	// MnemonicAction methods
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    96
	//
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    97
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    98
	public Action getAction() {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    99
	    return action;
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   100
	}
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   101
    }
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   102
148
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   103
    public static class MnemonicButton implements HasMnemonic {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   104
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   105
	// Instance data
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   106
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   107
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   108
	private AbstractButton button;
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   109
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   110
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   111
	// Constructors
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   112
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   113
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   114
	public MnemonicButton(AbstractButton button) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   115
	    this.button = button;
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   116
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   117
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   118
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   119
	// HasMnemonic methods
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   120
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   121
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   122
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   123
	public String getText() {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   124
	    return button.getText();
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   125
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   126
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   127
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   128
	public void setMnemonic(int i) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   129
	    button.setMnemonic(i);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   130
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   131
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   132
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   133
	public void setMnemonicIndex(int i) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   134
	    button.setDisplayedMnemonicIndex(i);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   135
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   136
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   137
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   138
	public void setText(String text) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   139
	    button.setText(text);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   140
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   141
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   142
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   143
	// MnemonicButton methods
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   144
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   145
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   146
	public AbstractButton getButton() {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   147
	    return button;
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   148
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   149
    }
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   150
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   151
    public static class MnemonicLabel implements HasMnemonic {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   152
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   153
	// Instance data
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   154
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   155
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   156
	private JLabel label;
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   157
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   158
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   159
	// Constructors
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   160
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   161
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   162
	public MnemonicLabel(JLabel label) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   163
	    this.label = label;
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   164
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   165
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   166
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   167
	// HasMnemonic methods
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   168
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   169
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   170
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   171
	public String getText() {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   172
	    return label.getText();
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   173
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   174
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   175
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   176
	public void setMnemonic(int i) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   177
	    label.setDisplayedMnemonic(i);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   178
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   179
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   180
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   181
	public void setMnemonicIndex(int i) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   182
	    label.setDisplayedMnemonicIndex(i);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   183
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   184
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   185
	@Override
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   186
	public void setText(String text) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   187
	    label.setText(text);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   188
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   189
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   190
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   191
	// MnemonicLabel methods
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   192
	//
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   193
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   194
	public JLabel getLabel() {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   195
	    return label;
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   196
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   197
    }
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   198
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   199
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   200
    // Static data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   201
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   202
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   203
    public static final Border BORDER_LINE =
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   204
	BorderFactory.createLineBorder(Color.GRAY, 1);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   205
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   206
    public static final String PROPERTY_COMPONENT_SPACING =
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   207
	"toolkit.component.spacing";
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   208
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   209
    public static final String PROPERTY_BUTTON_SPACING =
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   210
	"toolkit.button.spacing";
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   211
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   212
    public static final TypedPropertiesWrapper prefs =
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   213
	new TypedPropertiesWrapper();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   214
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   215
    static {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   216
	try {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   217
	    Properties defaultPrefs = new Properties();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   218
	    defaultPrefs.load(
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   219
		Finder.getResource("runtime.properties").openStream());
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   220
	    prefs.getPropertiesList().add(defaultPrefs);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   221
	} catch (IOException e) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   222
	    // Unlikely -- the resource should always exist and be accessible
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   223
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   224
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   225
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   226
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   227
    // Static methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   228
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   229
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   230
    /**
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   231
     * Adds the given {@code AWTKeyStroke}s to the given {@code Component}'s
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   232
     * list of focus traversal keys.
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   233
     *
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   234
     * @param	    comp
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   235
     *		    the {@code Component}
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   236
     *
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   237
     * @param	    forward
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   238
     *		    {@code true} to make {@code keyStrokes} traverse forward,
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   239
     *		    {@code false} to traverse backward
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   240
     *
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   241
     * @param	    keyStrokes
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   242
     *		    the {@code AWTKeyStroke}s
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   243
     */
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   244
    public static void addFocusTraversalKeys(Component comp, boolean forward,
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   245
	AWTKeyStroke... keyStrokes) {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   246
	modifyFocusTraversalKeys(comp, forward, true, keyStrokes);
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   247
    }
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   248
148
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   249
    public static void adjustForMnemonic(HasMnemonic obj) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   250
	String text = obj.getText();
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   251
	String[] groups = TextUtil.match(text, "(.*?)_(([a-zA-Z0-9]).*)");
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   252
	if (groups != null) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   253
	    obj.setText(groups[1] + groups[2]);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   254
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   255
	    String mnemonic = groups[3].toUpperCase();
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   256
	    KeyStroke mnemonicKey = KeyStroke.getKeyStroke(mnemonic);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   257
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   258
	    if (mnemonicKey != null) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   259
		int mnemonicKeyCode = mnemonicKey.getKeyCode();
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   260
		obj.setMnemonic(mnemonicKeyCode);
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   261
		obj.setMnemonicIndex(groups[1].length());
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   262
	    }
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   263
	}
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   264
    }
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   265
222
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   266
    public static void adjustForMnemonic(Action action) {
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   267
	adjustForMnemonic(new MnemonicAction(action));
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   268
    }
6b70286da0e2 6903 GUIUtil should adjust javax.swing.Actions for mnemonics too
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   269
148
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   270
    public static void adjustForMnemonic(AbstractButton button) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   271
	adjustForMnemonic(new MnemonicButton(button));
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   272
    }
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   273
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   274
    public static void adjustForMnemonic(JLabel label) {
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   275
	adjustForMnemonic(new MnemonicLabel(label));
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   276
    }
d38efdeead46 4358 sysid: user creation screen needs refinement
Stephen Talley <stephen.talley@sun.com>
parents: 107
diff changeset
   277
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   278
    public static Border createCompoundBorder(Border... borders) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   279
	Border border = null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   280
	for (int i = 0; i < borders.length; i++) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   281
	    border = i == 0 ? borders[i] :
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   282
		BorderFactory.createCompoundBorder(border, borders[i]);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   283
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   284
	return border;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   285
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   286
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   287
    /**
98
b5e809d65d1e 3710 ObjectsPanel should be more robust and distinct from SettingsPanel
Stephen Talley <stephen.talley@sun.com>
parents: 92
diff changeset
   288
     * Creates and returns a JTextField of the {@link #getTextFieldWidth default
b5e809d65d1e 3710 ObjectsPanel should be more robust and distinct from SettingsPanel
Stephen Talley <stephen.talley@sun.com>
parents: 92
diff changeset
   289
     * width}.
b5e809d65d1e 3710 ObjectsPanel should be more robust and distinct from SettingsPanel
Stephen Talley <stephen.talley@sun.com>
parents: 92
diff changeset
   290
     */
b5e809d65d1e 3710 ObjectsPanel should be more robust and distinct from SettingsPanel
Stephen Talley <stephen.talley@sun.com>
parents: 92
diff changeset
   291
    public static JTextField createTextField() {
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   292
	return new JTextField(getTextFieldWidth());
98
b5e809d65d1e 3710 ObjectsPanel should be more robust and distinct from SettingsPanel
Stephen Talley <stephen.talley@sun.com>
parents: 92
diff changeset
   293
    }
b5e809d65d1e 3710 ObjectsPanel should be more robust and distinct from SettingsPanel
Stephen Talley <stephen.talley@sun.com>
parents: 92
diff changeset
   294
b5e809d65d1e 3710 ObjectsPanel should be more robust and distinct from SettingsPanel
Stephen Talley <stephen.talley@sun.com>
parents: 92
diff changeset
   295
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   296
     * Get the default spacing between buttons, as on a toolbar.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   297
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   298
    public static int getButtonGap() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   299
	return prefs.getInt("toolkit.button.spacing");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   300
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   301
173
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   302
    /**
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   303
     * Get the default height for button icons.
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   304
     */
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   305
    public static int getButtonIconHeight() {
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   306
	return prefs.getInt("toolkit.button.icon.height");
173
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   307
    }
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   308
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   309
    public static String getClippedString(
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   310
	String text, FontMetrics metrics, int width) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   311
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   312
	if (text == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   313
	    return text;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   314
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   315
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   316
	int sWidth = metrics.stringWidth(text);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   317
	if (sWidth <= width) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   318
	    return text;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   319
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   320
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   321
	String ellipsis = "...";
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   322
	width -= metrics.stringWidth(ellipsis);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   323
	char[] chars = text.toCharArray();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   324
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   325
	int i;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   326
	for (i = chars.length - 1; i >= 0 && sWidth > width; i--) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   327
	    sWidth -= metrics.charWidth(chars[i]);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   328
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   329
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   330
	return text.substring(0, i + 1) + ellipsis;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   331
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   332
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   333
    public static Border getEmptyBorder() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   334
	int gap = getGap();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   335
	return BorderFactory.createEmptyBorder(gap, gap, gap, gap);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   336
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   337
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   338
    public static Border getEmptyHalfBorder() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   339
	int gap = getHalfGap();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   340
	return BorderFactory.createEmptyBorder(gap, gap, gap, gap);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   341
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   342
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   343
    /**
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   344
     * Gets an icon for the given message type.  An attempt will first be made
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   345
     * to retrieve a look-and-feel-specific icon from the {@code JOptionPane}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   346
     * class.  However, some looks and feels (like GTK) don't expose these icons
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   347
     * via the API; in this case local defaults will be returned.
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   348
     *
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   349
     * @param	    messageType
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   350
     *		    JOptionPane.ERROR_MESSAGE,
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   351
     *		    JOptionPane.INFORMATION_MESSAGE,
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   352
     *		    JOptionPane.WARNING_MESSAGE, or
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   353
     *		    JOptionPane.QUESTION_MESSAGE.
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   354
     *
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   355
     * @return	    an {@code Icon}, or {@code null} if no icon could be found
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   356
     *		    for the given message type
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   357
     */
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   358
    public static Icon getIcon(int messageType) {
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   359
	Icon icon = null;
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   360
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   361
	switch (messageType) {
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   362
	    case JOptionPane.ERROR_MESSAGE:
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   363
		icon = UIManager.getIcon("OptionPane.errorIcon");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   364
		if (icon == null) {
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   365
		    icon = Finder.getIcon("images/dialog/dialog-error.png");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   366
		}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   367
		break;
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   368
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   369
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   370
	    case JOptionPane.INFORMATION_MESSAGE:
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   371
		icon = UIManager.getIcon("OptionPane.informationIcon");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   372
		if (icon == null) {
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   373
		    icon = Finder.getIcon(
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   374
			"images/dialog/dialog-information.png");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   375
		}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   376
		break;
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   377
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   378
	    case JOptionPane.WARNING_MESSAGE:
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   379
		icon = UIManager.getIcon("OptionPane.warningIcon");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   380
		if (icon == null) {
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   381
		    icon = Finder.getIcon(
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   382
			"images/dialog/dialog-warning.png");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   383
		}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   384
		break;
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   385
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   386
	    case JOptionPane.QUESTION_MESSAGE:
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   387
		icon = UIManager.getIcon("OptionPane.questionIcon");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   388
		if (icon == null) {
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   389
		    icon = Finder.getIcon(
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   390
			"images/dialog/dialog-question.png");
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   391
		}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   392
		break;
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   393
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   394
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   395
	return icon;
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   396
    }
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   397
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   398
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   399
     * Get the default spacing between components.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   400
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   401
    public static int getGap() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   402
	return prefs.getInt("toolkit.component.spacing");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   403
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   404
173
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   405
    public static int getHalfGap() {
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   406
	return getGap() / 2;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   407
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   408
173
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   409
    /**
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   410
     * Get the default height for menu icons.
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   411
     */
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   412
    public static int getMenuIconHeight() {
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   413
	return prefs.getInt("toolkit.menu.icon.height");
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   414
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   415
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   416
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   417
     * Gets the preferred size of the given {@code Window}.  If the given {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   418
     * Window} is a {@code JFrame} or a {@code JDialog}, and its glass pane is
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   419
     * visible, the glass pane's preferred size will be accounted for as well
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   420
     * ({@code Window.getPreferredSize} does not take the glass pane into
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   421
     * consideration).
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   422
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   423
    public static Dimension getPreferredSize(Window window) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   424
	Dimension pSize = window.getPreferredSize();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   425
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   426
	Component glass = null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   427
	Component content = null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   428
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   429
	if (window instanceof JFrame) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   430
	    JFrame frame = (JFrame)window;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   431
	    glass = frame.getGlassPane();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   432
	    content = frame.getContentPane();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   433
	} else if (window instanceof JDialog) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   434
	    JDialog dialog = (JDialog)window;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   435
	    glass = dialog.getGlassPane();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   436
	    content = dialog.getContentPane();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   437
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   438
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   439
	if (glass != null && glass.isVisible()) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   440
	    Dimension cpSize = content.getPreferredSize();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   441
	    content.setPreferredSize(glass.getPreferredSize());
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   442
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   443
	    Dimension newPSize = window.getPreferredSize();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   444
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   445
	    pSize.width = Math.max(pSize.width, newPSize.width);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   446
	    pSize.height = Math.max(pSize.height, newPSize.height);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   447
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   448
	    // Restore previous preferred size, if any
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   449
	    content.setPreferredSize(cpSize);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   450
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   451
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   452
	return pSize;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   453
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   454
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   455
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   456
     * Get the default scroll unit increment.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   457
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   458
    public static int getScrollableUnitIncrement() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   459
	return prefs.getInt("toolkit.scroll.increment.unit");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   460
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   461
173
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   462
    /**
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   463
     * Get the default width for a textfield.
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   464
     */
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   465
    public static int getTextFieldWidth() {
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   466
	return prefs.getInt("toolkit.textfield.width");
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   467
    }
6ad4fdfc56f0 2512 IconFinder should check for themed Gnome icons first
Stephen Talley <stephen.talley@sun.com>
parents: 148
diff changeset
   468
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   469
    public static int getTextXOffset(AbstractButton c) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   470
	int xoffset = c.getPreferredSize().width;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   471
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   472
	Border b = c.getBorder();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   473
	if (b != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   474
	    xoffset -= b.getBorderInsets(c).right;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   475
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   476
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   477
//	Insets m = c.getMargin();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   478
//	if (m != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   479
//	    xoffset -= m.right;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   480
//	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   481
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   482
	String text = c.getText();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   483
	if (text != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   484
	    xoffset -= c.getFontMetrics(c.getFont()).stringWidth(text);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   485
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   486
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   487
	return xoffset;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   488
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   489
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   490
    public static Border getTitledBorder(String title) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   491
	return BorderFactory.createCompoundBorder(
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   492
	    BorderFactory.createTitledBorder(
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   493
	    BorderFactory.createEtchedBorder(), title), getEmptyBorder());
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   494
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   495
99
e92e19939254 3711 Restore toolbar margin standardization
Stephen Talley <stephen.talley@sun.com>
parents: 98
diff changeset
   496
    /**
e92e19939254 3711 Restore toolbar margin standardization
Stephen Talley <stephen.talley@sun.com>
parents: 98
diff changeset
   497
     * Get the default margin for toolbar buttons.
e92e19939254 3711 Restore toolbar margin standardization
Stephen Talley <stephen.talley@sun.com>
parents: 98
diff changeset
   498
     */
e92e19939254 3711 Restore toolbar margin standardization
Stephen Talley <stephen.talley@sun.com>
parents: 98
diff changeset
   499
    public static int getToolBarButtonMargin() {
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   500
	return prefs.getInt("toolkit.toolbar.button.margin");
99
e92e19939254 3711 Restore toolbar margin standardization
Stephen Talley <stephen.talley@sun.com>
parents: 98
diff changeset
   501
    }
e92e19939254 3711 Restore toolbar margin standardization
Stephen Talley <stephen.talley@sun.com>
parents: 98
diff changeset
   502
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   503
    public static TypedPropertiesWrapper getUIPreferences() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   504
	return prefs;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   505
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   506
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   507
    /**
306
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   508
     * Get the default vertical spacing between a label and its {@code
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   509
     * Component} below it.
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   510
     */
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   511
    public static int getVerticalLabelGap() {
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   512
	return prefs.getInt("toolkit.vertical.label.spacing");
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   513
    }
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   514
b08061f1d961 9379 integrate visual design icons and feedback
Stephen Talley <stephen.talley@sun.com>
parents: 222
diff changeset
   515
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   516
     * Grows the given {@code Window} if its preferred size exceeds its actual
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   517
     * size.  Will not shrink the {@code Window}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   518
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   519
    public static void growIfNecessary(Window window) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   520
	Dimension size = window.getSize();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   521
	Dimension pSize = getPreferredSize(window);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   522
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   523
	window.setSize(Math.max(size.width, pSize.width),
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   524
	    Math.max(size.height, pSize.height));
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   525
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   526
83
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   527
    public static void installKeyBinding(JComponent c, int condition,
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   528
	String actionName, Action action, KeyStroke... keyStrokes) {
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   529
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   530
	InputMap iMap = c.getInputMap(condition);
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   531
	ActionMap aMap = c.getActionMap();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   532
83
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   533
	for (KeyStroke keyStroke : keyStrokes) {
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   534
	    iMap.put(keyStroke, actionName);
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   535
	    aMap.put(actionName, action);
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   536
	}
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   537
    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   538
83
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   539
    public static void installKeyBinding(JComponent c, int condition,
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   540
	String actionName, Action action, int... keyStrokes) {
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   541
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   542
	KeyStroke[] array = new KeyStroke[keyStrokes.length];
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   543
	for (int i = 0; i < array.length; i++) {
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   544
	    array[i] = KeyStroke.getKeyStroke(keyStrokes[i], 0);
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   545
	}
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   546
6d541f5783df 3564 Focus requests throughout UI should be standardized
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   547
	installKeyBinding(c, condition, actionName, action, array);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   548
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   549
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   550
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   551
     * Invokes the given {@code Runnable} on the AWT event dispatching thread
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   552
     * (which could be the current thread).  This addresses two
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   553
     * disadvantages/annoyances to {@code EventQueue.invokeAndWait}:
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   554
     * <ol>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   555
     *	 <li>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   556
     *	   Any {@code RuntimeException}s or {@code Error}s thrown by the given
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   557
     *	   {@code Runnable} are thrown in the current thread, rather than as an
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   558
     *	   {@code InvocationTargetException}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   559
     *	 </li>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   560
     *	 <li>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   561
     *	   If the AWT event dispatching thread is interrupted while the given
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   562
     *	   {@code Runnable} is running, it will be re-run until it completes.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   563
     *	   If this behavior is not desired, the given {@code Runnable} should
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   564
     *	   account for this possibility.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   565
     *	 </li>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   566
     * <ol>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   567
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   568
     * @param	    runnable
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   569
     *		    a {@code Runnable} to run
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   570
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   571
    public static void invokeAndWait(final Runnable runnable) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   572
	if (EventQueue.isDispatchThread()) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   573
	    runnable.run();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   574
	} else {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   575
	    while (true) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   576
		try {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   577
		    EventQueue.invokeAndWait(runnable);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   578
		    break;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   579
		} catch (InvocationTargetException e) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   580
		    Throwable cause = e.getCause();
375
a368eea114ba 12302 asynchronously-thrown Throwables should have blocking thread's stack trace appended for debuggability
Stephen Talley <stephen.talley@sun.com>
parents: 306
diff changeset
   581
		    ThrowableUtil.appendStackTrace(cause);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   582
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   583
		    if (cause instanceof RuntimeException) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   584
			throw (RuntimeException)cause;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   585
		    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   586
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   587
		    if (cause instanceof Error) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   588
			throw (Error)cause;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   589
		    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   590
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   591
		    // It should not be possible to be here -- any Throwable
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   592
		    // thrown by run() should have been a RunTimeException or an
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   593
		    // Error, since run throws no checked Exceptions.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   594
		    assert (false);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   595
		} catch (InterruptedException e) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   596
		    // Not bloody likely
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   597
		}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   598
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   599
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   600
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   601
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   602
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   603
     * See {@link #invokeAndWait(java.lang.Runnable)}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   604
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   605
     * @return	    the returned object of the given {@code TypedRunnable}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   606
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   607
    public static <T> T invokeAndWait(final TypedRunnable<T> runnable) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   608
	final List<T> t = new ArrayList<T>(1);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   609
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   610
	invokeAndWait(
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   611
	    new Runnable() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   612
		@Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   613
		public void run() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   614
		    t.add(runnable.run());
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   615
		}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   616
	    });
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   617
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   618
	return t.get(0);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   619
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   620
88
c66eeb2196c3 2518 Double-clicking on selection list should move item
Stephen Talley <stephen.talley@sun.com>
parents: 83
diff changeset
   621
    public static boolean isModifierKeyPressed(InputEvent e) {
c66eeb2196c3 2518 Double-clicking on selection list should move item
Stephen Talley <stephen.talley@sun.com>
parents: 83
diff changeset
   622
	return e.isShiftDown() || e.isControlDown() || e.isAltDown() ||
c66eeb2196c3 2518 Double-clicking on selection list should move item
Stephen Talley <stephen.talley@sun.com>
parents: 83
diff changeset
   623
	    e.isMetaDown() || e.isAltGraphDown();
c66eeb2196c3 2518 Double-clicking on selection list should move item
Stephen Talley <stephen.talley@sun.com>
parents: 83
diff changeset
   624
    }
c66eeb2196c3 2518 Double-clicking on selection list should move item
Stephen Talley <stephen.talley@sun.com>
parents: 83
diff changeset
   625
89
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   626
    /**
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   627
     * Returns {@code true} if the given {@code MouseEvent} represents a mouse
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   628
     * click with the given number of clicks, button 1, with no modifier keys
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   629
     * pressed, or {@code false} otherwise.
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   630
     */
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   631
    public static boolean isUnmodifiedClick(MouseEvent e, int clickCount) {
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   632
	return e.getID() == MouseEvent.MOUSE_CLICKED && e.getButton() == 1 &&
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   633
	    e.getClickCount() == clickCount && !isModifierKeyPressed(e);
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   634
    }
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   635
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   636
    public static void propagate(MouseEvent e, Component c) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   637
	Point p = SwingUtilities.convertPoint(e.getComponent(),
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   638
	    e.getX(), e.getY(), c);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   639
434
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   640
	MouseEvent e2;
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   641
	if (e instanceof MouseWheelEvent) {
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   642
            e2 = new MouseWheelEvent(c, e.getID(), e.getWhen(),
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   643
                e.getModifiers(), p.x, p.y, e.getClickCount(),
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   644
                e.isPopupTrigger(), ((MouseWheelEvent)e).getScrollType(),
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   645
                ((MouseWheelEvent)e).getScrollAmount(),
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   646
                ((MouseWheelEvent)e).getWheelRotation());
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   647
	} else {
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   648
            e2 = new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiers(),
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   649
		p.x, p.y, e.getClickCount(), e.isPopupTrigger());
13b742005e3d 10214 tooltips still flicker, interfere with scrolling
Stephen Talley <stephen.talley@sun.com>
parents: 375
diff changeset
   650
	}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   651
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   652
	c.dispatchEvent(e2);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   653
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   654
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   655
    /**
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   656
     * Removes the given {@code AWTKeyStroke}s from the given {@code
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   657
     * Component}'s list of focus traversal keys.
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   658
     *
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   659
     * @param	    comp
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   660
     *		    the {@code Component}
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   661
     *
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   662
     * @param	    forward
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   663
     *		    {@code true} if {@code keyStrokes} traverse forward, {@code
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   664
     *		    false} if backward
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   665
     *
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   666
     * @param	    keyStrokes
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   667
     *		    the {@code AWTKeyStroke}s
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   668
     */
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   669
    public static void removeFocusTraversalKeys(Component comp, boolean forward,
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   670
	AWTKeyStroke... keyStrokes) {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   671
	modifyFocusTraversalKeys(comp, forward, false, keyStrokes);
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   672
    }
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   673
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   674
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   675
     * Turn on text antialiasing if appropriate for this platform.  Technically
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   676
     * this should follow the conventions that Swing uses (matching this setting
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   677
     * to the user's desktop settings), but since Swing doesn't expose this
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   678
     * functionality, turn it on here unconditionally.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   679
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   680
    public static void setAARendering(Graphics2D g) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   681
	g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   682
	    RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   683
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   684
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   685
    public static void setBorderFromFont(JComponent c) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   686
	FontMetrics metrics = c.getFontMetrics(c.getFont());
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   687
	int top = metrics.getDescent();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   688
	int left = metrics.charWidth(' ');
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   689
	c.setBorder(BorderFactory.createEmptyBorder(top, left, top, left));
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   690
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   691
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   692
    public static void setEnableStateOnSelect(final AbstractButton button,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   693
	final boolean recursive, final boolean enabled,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   694
	final Component... toEnable) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   695
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   696
	ItemListener l = new ItemListener() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   697
	    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   698
	    public void itemStateChanged(ItemEvent e) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   699
		boolean state = !(button.isSelected() ^ enabled);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   700
		for (Component c : toEnable) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   701
		    if (recursive) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   702
			setEnabledRecursive(c, state);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   703
		    } else {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   704
			c.setEnabled(state);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   705
		    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   706
		}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   707
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   708
	};
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   709
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   710
	button.addItemListener(l);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   711
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   712
	// Set initial state
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   713
	l.itemStateChanged(null);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   714
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   715
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   716
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   717
     * Sets the enabled status of the given {@code Component}'s descendants, if
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   718
     * it is a {@code Container}, then of the given {@code Component} itself.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   719
     * <p>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   720
     * If a {@code Container} implementing {@code DescendantEnabler} is
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   721
     * encountered along the way, recursion into the {@code Component}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   722
     * hierarchy is aborted.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   723
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   724
    public static void setEnabledRecursive(Component parent, boolean enabled) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   725
	if (parent instanceof Container &&
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   726
	    !(parent instanceof DescendantEnabler)) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   727
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   728
	    for (Component c : ((Container)parent).getComponents()) {
89
80a62bf31dfb 3636 Standardize event checking for mouse clicks
Stephen Talley <stephen.talley@sun.com>
parents: 88
diff changeset
   729
		setEnabledRecursive((Container)c, enabled);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   730
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   731
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   732
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   733
	// A disabled JPanel is ugly
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   734
	if (enabled || parent instanceof DescendantEnabler ||
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   735
	    !(parent instanceof JPanel)) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   736
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   737
	    parent.setEnabled(enabled);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   738
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   739
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   740
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   741
    /**
107
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   742
     * Sets the left and right margin of an {@code AbstractButton} in a
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   743
     * L&amp;F-independent manner (some L&amp;Fs set this value in the margin,
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   744
     * while others ignore this property and use the border instead).
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   745
     */
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   746
    public static void setHorizontalMargin(AbstractButton button, int hMargin) {
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   747
	Insets margin = button.getMargin();
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   748
	margin.left = margin.right = hMargin;
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   749
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   750
	Border empty = BorderFactory.createEmptyBorder(
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   751
	    margin.top, margin.left, margin.bottom, margin.right);
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   752
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   753
	Border outer = button.getBorder();
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   754
	Border compound = BorderFactory.createCompoundBorder(outer, empty);
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   755
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   756
	button.setMargin(new Insets(0, 0, 0, 0));
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   757
	button.setBorder(compound);
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   758
    }
2c575b368b4b 3841 toolbar buttons have spacing irregularities across different L&amp;Fs
Stephen Talley <stephen.talley@sun.com>
parents: 100
diff changeset
   759
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   760
    public static void setMinorFont(Component comp) {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   761
	Font font = comp.getFont();
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   762
	font = font.deriveFont(font.getSize() * .85f);
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   763
	comp.setFont(font);
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   764
    }
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   765
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   766
    public static void setUIPreferences(Properties p) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   767
	List<Properties> pList = prefs.getPropertiesList();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   768
	if (pList.size() > 1) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   769
	    pList.remove(1);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   770
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   771
	pList.add(p);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   772
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   773
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   774
    /**
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   775
     * Sets whether the given {@code Component} uses tab and shift-tab as
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   776
     * forward/backward focus traversal keys.
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   777
     */
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   778
    public static void setUseStandardFocusTraversalKeys(Component comp,
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   779
	boolean use) {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   780
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   781
	modifyFocusTraversalKeys(comp, true, use, KeyStroke.getKeyStroke(
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   782
	    KeyEvent.VK_TAB, 0));
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   783
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   784
	modifyFocusTraversalKeys(comp, false, use, KeyStroke.getKeyStroke(
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   785
	    KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK));
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   786
    }
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   787
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   788
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   789
     * Shows a confirmation message dialog.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   790
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   791
     * @param	    component
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   792
     *		    a {@code Component} contained within a {@code Frame} for
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   793
     *		    which the dialog will be modal, or {@code null} to display a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   794
     *		    non-modal dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   795
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   796
     * @param	    title
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   797
     *		    the title to display in the dialog, or {@code null} to use a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   798
     *		    default
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   799
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   800
     * @param	    optionType
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   801
     *		    a static constant from the {@code JOptionPane} class: {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   802
     *		    YES_NO_OPTION}, {@code YES_NO_CANCEL_OPTION}, or {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   803
     *		    OK_CANCEL_OPTION}, or {@code null} to use the default
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   804
     *		    ({@code OK_CANCEL_OPTION})
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   805
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   806
     * @param	    message
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   807
     *		    the message to display in the dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   808
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   809
     * @return	    an integer indicating the option selected by the user
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   810
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   811
    public static int showConfirmation(Component component, String title,
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   812
	Object message, Integer optionType) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   813
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   814
	if (title == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   815
	    title = Finder.getString("dialog.title.confirm");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   816
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   817
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   818
	JOptionPane pane = new ExtOptionPane(
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   819
	    message, JOptionPane.QUESTION_MESSAGE);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   820
	pane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   821
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   822
	JDialog dialog = pane.createDialog(component, title);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   823
	dialog.setVisible(true);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   824
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   825
	Object selection = pane.getValue();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   826
	if (selection == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   827
	    return JOptionPane.CLOSED_OPTION;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   828
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   829
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   830
	return (Integer)selection;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   831
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   832
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   833
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   834
     * Shows an error message dialog.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   835
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   836
     * @param	    component
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   837
     *		    a {@code Component} contained within a {@code Frame} for
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   838
     *		    which the dialog will be modal, or {@code null} to display a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   839
     *		    non-modal dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   840
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   841
     * @param	    title
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   842
     *		    the title to display in the dialog, or {@code null} to use a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   843
     *		    default
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   844
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   845
     * @param	    message
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   846
     *		    the message to display in the dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   847
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   848
    public static void showError(Component component, String title,
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   849
	Object message) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   850
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   851
	if (message != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   852
	    if (title == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   853
		title = Finder.getString("dialog.title.error");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   854
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   855
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   856
	    showOptionPane(JOptionPane.ERROR_MESSAGE, component, title,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   857
		message);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   858
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   859
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   860
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   861
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   862
     * Shows an info message dialog.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   863
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   864
     * @param	    component
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   865
     *		    a {@code Component} contained within a {@code Frame} for
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   866
     *		    which the dialog will be modal, or {@code null} to display a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   867
     *		    non-modal dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   868
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   869
     * @param	    title
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   870
     *		    the title to display in the dialog, or {@code null} to use a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   871
     *		    default
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   872
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   873
     * @param	    message
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   874
     *		    the message to display in the dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   875
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   876
    public static void showInfo(Component component, String title,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   877
	String message) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   878
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   879
	if (title == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   880
	    title = Finder.getString("dialog.title.info");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   881
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   882
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   883
	showOptionPane(JOptionPane.INFORMATION_MESSAGE, component, title,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   884
	    message);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   885
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   886
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   887
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   888
     * Shows a width-constrained {@code JOptionPane} with the specified
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   889
     * parameters.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   890
     *
100
c70d5233a531 3712 Javadoc errors
Stephen Talley <stephen.talley@sun.com>
parents: 99
diff changeset
   891
     * @see	    ExtOptionPane
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   892
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   893
    public static void showOptionPane(int messageType, Component component,
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   894
	String title, Object message) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   895
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 75
diff changeset
   896
	JOptionPane pane = new ExtOptionPane(message, messageType);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   897
	JDialog dialog = pane.createDialog(component, title);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   898
	dialog.setVisible(true);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   899
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   900
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   901
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   902
     * Shows an warning message dialog.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   903
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   904
     * @param	    component
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   905
     *		    a {@code Component} contained within a {@code Frame} for
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   906
     *		    which the dialog will be modal, or {@code null} to display a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   907
     *		    non-modal dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   908
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   909
     * @param	    title
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   910
     *		    the title to display in the dialog, or {@code null} to use a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   911
     *		    default
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   912
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   913
     * @param	    message
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   914
     *		    the message to display in the dialog
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   915
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   916
    public static void showWarning(Component component, String title,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   917
	String message) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   918
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   919
	if (title == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   920
	    title = Finder.getString("dialog.title.warning");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   921
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   922
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   923
	showOptionPane(JOptionPane.WARNING_MESSAGE, component, title, message);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   924
    }
213
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   925
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   926
    //
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   927
    // Private static methods
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   928
    //
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   929
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   930
    private static void modifyFocusTraversalKeys(Component comp,
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   931
	boolean forward, boolean add, AWTKeyStroke... keyStrokes) {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   932
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   933
	int dir = forward ? KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS :
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   934
	    KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS;
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   935
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   936
	Set<AWTKeyStroke> keys = new HashSet<AWTKeyStroke>(
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   937
	    comp.getFocusTraversalKeys(dir));
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   938
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   939
	for (AWTKeyStroke key : keyStrokes) {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   940
	    if (add) {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   941
		keys.add(key);
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   942
	    } else {
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   943
		keys.remove(key);
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   944
	    }
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   945
	}
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   946
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   947
	comp.setFocusTraversalKeys(dir, keys);
1a03dafcb738 6411 time: VP needs a time/date panel
Stephen Talley <stephen.talley@sun.com>
parents: 198
diff changeset
   948
    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   949
}