13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.tools.jconsole;
27
28 import java.awt.*;
29 import java.awt.event.*;
30
31 import javax.swing.*;
32
33 import static javax.swing.JLayeredPane.*;
34 import static sun.tools.jconsole.Resources.*;
35
36 /**
37 * Used instead of JDialog in a JDesktopPane/JInternalFrame environment.
38 */
39 @SuppressWarnings("serial")
40 public class InternalDialog extends JInternalFrame {
41 protected JLabel statusBar;
42
43 public InternalDialog(JConsole jConsole, String title, boolean modal) {
44 super(title, true, true, false, false);
45
46 setLayer(PALETTE_LAYER);
47 putClientProperty("JInternalFrame.frameType", "optionDialog");
48
49 jConsole.getDesktopPane().add(this);
50
51
52 getActionMap().put("cancel", new AbstractAction() {
53 public void actionPerformed(ActionEvent evt) {
54 setVisible(false);
56 statusBar.setText("");
57 }
58 }
59 });
60 InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
61 inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
62 }
63
64 public void setLocationRelativeTo(Component c) {
65 setLocation((c.getWidth() - getWidth()) / 2,
66 (c.getHeight() - getHeight()) / 2);
67 }
68
69 protected class MastheadIcon implements Icon {
70 // Important: Assume image background is white!
71 private ImageIcon leftIcon =
72 new ImageIcon(InternalDialog.class.getResource("resources/masthead-left.png"));
73 private ImageIcon rightIcon =
74 new ImageIcon(InternalDialog.class.getResource("resources/masthead-right.png"));
75
76 private Font font = Font.decode(getText("Masthead.font"));
77 private int gap = 10;
78 private String title;
79
80 public MastheadIcon(String title) {
81 this.title = title;
82 }
83
84 public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
85 // Clone the Graphics object
86 g = g.create();
87
88 // Ignore x to make sure we fill entire component width
89 x = 0;
90 int width = c.getWidth();
91 int lWidth = leftIcon.getIconWidth();
92 int rWidth = rightIcon.getIconWidth();
93 int height = getIconHeight();
94 int textHeight = g.getFontMetrics(font).getAscent();
95
96 g.setColor(Color.white);
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.tools.jconsole;
27
28 import java.awt.*;
29 import java.awt.event.*;
30
31 import javax.swing.*;
32
33 import sun.tools.jconsole.resources.Messages;
34
35 import static javax.swing.JLayeredPane.*;
36
37 /**
38 * Used instead of JDialog in a JDesktopPane/JInternalFrame environment.
39 */
40 @SuppressWarnings("serial")
41 public class InternalDialog extends JInternalFrame {
42 protected JLabel statusBar;
43
44 public InternalDialog(JConsole jConsole, String title, boolean modal) {
45 super(title, true, true, false, false);
46
47 setLayer(PALETTE_LAYER);
48 putClientProperty("JInternalFrame.frameType", "optionDialog");
49
50 jConsole.getDesktopPane().add(this);
51
52
53 getActionMap().put("cancel", new AbstractAction() {
54 public void actionPerformed(ActionEvent evt) {
55 setVisible(false);
57 statusBar.setText("");
58 }
59 }
60 });
61 InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
62 inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
63 }
64
65 public void setLocationRelativeTo(Component c) {
66 setLocation((c.getWidth() - getWidth()) / 2,
67 (c.getHeight() - getHeight()) / 2);
68 }
69
70 protected class MastheadIcon implements Icon {
71 // Important: Assume image background is white!
72 private ImageIcon leftIcon =
73 new ImageIcon(InternalDialog.class.getResource("resources/masthead-left.png"));
74 private ImageIcon rightIcon =
75 new ImageIcon(InternalDialog.class.getResource("resources/masthead-right.png"));
76
77 private Font font = Font.decode(Messages.MASTHEAD_FONT);
78 private int gap = 10;
79 private String title;
80
81 public MastheadIcon(String title) {
82 this.title = title;
83 }
84
85 public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
86 // Clone the Graphics object
87 g = g.create();
88
89 // Ignore x to make sure we fill entire component width
90 x = 0;
91 int width = c.getWidth();
92 int lWidth = leftIcon.getIconWidth();
93 int rWidth = rightIcon.getIconWidth();
94 int height = getIconHeight();
95 int textHeight = g.getFontMetrics(font).getAscent();
96
97 g.setColor(Color.white);
|